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
53 lines (38 sloc) 914 Bytes
import string
import sys
from collections import OrderedDict
comp={'A':'T','T':'A','G':'C','C':'G'}
value,key="",""
s=OrderedDict({})
with open("rosalind_splc.txt","rU") as f:
for x in f:
if x[0]!=">":
value=value+x.strip()
else:
if key!="":
s[key]=value
value=""
key=x[1:].strip()
s[key]=value
f.close()
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()
dna=s.values()[0]
for value in s.values()[1:]:
while value in dna:
j=dna.find(value)
t=len(value)
dna=dna[0:j]+dna[j+t:]
dna=dna.replace("T","U")
for i in range(0,len(dna),3):
if rna[dna[i:i+3]]=='Stop':
sys.stdout.write('\n')
break
sys.stdout.write(rna[dna[i:i+3]]),