Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
63 lines (54 sloc) 1.27 KB
import urllib
import urllib2
from fasta import readFASTA
from collections import OrderedDict
url = 'http://www.ebi.ac.uk/Tools/services/rest/emboss_water/'
s=readFASTA("rosalind_laff.txt")
param_dict={
'email':'jeremy.teitelbaum@uconn.edu',
'title':'Local Alignment',
'matrix': 'EBLOSUM62',
'format':'markx3',
'gapopen':15,
'gapext':1,
}
param_dict['asequence']=s.values()[0]
param_dict['sid1']='A'
param_dict['bsequence']=s.values()[1]
param_dict['sid2']='B'
params = urllib.urlencode(param_dict)
response = urllib2.urlopen(url+'run/', params).read()
while urllib2.urlopen(url+'status/'+response).read()!="FINISHED":
continue
answer=urllib2.urlopen(url+'resulttypes/'+response).read()
final=urllib2.urlopen(url+'result/'+response+'/out').read()
ls= [x for x in final.split('\n') if len(x)>0]
value,key="",""
s=OrderedDict({})
j=0
for x in ls:
if x[0] in ['#',';']:
#print x
continue
if x[0]==">":
if key!="":
s[key]=value
key=x[1:].split()[0]+'-'+str(j)
j=j+1
value=""
else:
value=value+x.strip()
s[key]=value
R=''
for x in s.values()[0]:
if x!='-':
R+=x
S=''
for x in s.values()[1]:
if x!='-':
S+=x
print R
print
print S
#print
#print s.values()[1]
You can’t perform that action at this time.