Skip to content
Permalink
6d5cc671f5
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
77 lines (65 sloc) 1.42 KB
#!/usr/bin/python
import sys
rna={}
f=open('rna_table.txt','rU')
for line in f:
x=line.split()
codons=x[0::2]
acids=x[1::2]
rna_new=dict(zip(codons,acids))
rna.update(rna_new)
f.close()
f=open('rosalind_orf.txt','rU')
import string
import sys
value,key,s="","",{}
maxt, max="",0.0
with open("rosalind_orf.txt","rU") as f:
for x in f:
if x[0]!=">":
value=value+x.strip()
else:
if key!="": s[key]=value
key=x[1:].strip()
s=""
sc=""
# crude translation to RNA from DNA
for x in value:
if x=="T":
s+="U"
sc+="A"
if x=="A":
s+=x
sc+="U"
if x=="G":
s+=x
sc+="C"
if x=="C":
s+=x
sc+="G"
proteins={}
p=""
for offset in range(0,3):
for i in range(offset,len(s)-3,3):
if s[i:i+3]=="AUG":
p="M"
for j in range(i+3,len(s)-3,3):
if rna[s[j:j+3]]=='Stop':
proteins[p]=1
p=""
break
p=p+rna[s[j:j+3]]
s=sc[::-1]
p=""
for offset in range(0,3):
for i in range(offset,len(s)-3,3):
if s[i:i+3]=="AUG":
p="M"
for j in range(i+3,len(s)-3,3):
if rna[s[j:j+3]]=='Stop':
proteins[p]=1
p=""
break
p=p+rna[s[j:j+3]]
for x in proteins.keys():
print x