#!/usr/bin/env python
from selector import Selector
from yaro import Yaro
rootdir = '/var/www/mywebsite/htdocs/'
def index(req):
return open(rootdir+'form.html').read()
def _chargeandprop(AAseq):
protseq = AAseq.upper()
charge = -0.002
cp = 0
AACharge = {"C":-.045,"D":-.999,"E":-.998,"H":.091,
"K":1,"R":1,"Y":-.001}
for aa in protseq:
charge += AACharge.get(aa,0)
if aa in AACharge:
cp += 1
prop = 100.*cp/len(AAseq)
return (charge,prop)
def netc(req):
seq = req.form.get('seq','')
title = req.form.get('title','')
prop = req.form.get('prop','')
charge,propval = _chargeandprop(seq)
yield "<html><body>Job title: %s<br/>"%title+\
"Your sequence is:<br/>%s<br/>"%seq+\
"Net charge: %s<br/>"%charge
if prop=="y":
yield "Proportion of charged AA: %.2f"%propval
yield "<br/></body></html>"
s = Selector(wrap=Yaro)
s.add('/', GET=index)
s.add('/netc', POST=netc)
application = s