-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTranslating RNA into Protein
28 lines (26 loc) · 1.15 KB
/
Translating RNA into Protein
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
map = {"UUU":"F", "UUC":"F", "UUA":"L", "UUG":"L", # this is a map (dictionary) of all RNA triplets
"UCU":"S", "UCC":"S", "UCA":"S", "UCG":"S",
"UAU":"Y", "UAC":"Y", "UAA":"Stop", "UAG":"Stop",
"UGU":"C", "UGC":"C", "UGA":"Stop", "UGG":"W",
"CUU":"L", "CUC":"L", "CUA":"L", "CUG":"L",
"CCU":"P", "CCC":"P", "CCA":"P", "CCG":"P",
"CAU":"H", "CAC":"H", "CAA":"Q", "CAG":"Q",
"CGU":"R", "CGC":"R", "CGA":"R", "CGG":"R",
"AUU":"I", "AUC":"I", "AUA":"I", "AUG":"M",
"ACU":"T", "ACC":"T", "ACA":"T", "ACG":"T",
"AAU":"N", "AAC":"N", "AAA":"K", "AAG":"K",
"AGU":"S", "AGC":"S", "AGA":"R", "AGG":"R",
"GUU":"V", "GUC":"V", "GUA":"V", "GUG":"V",
"GCU":"A", "GCC":"A", "GCA":"A", "GCG":"A",
"GAU":"D", "GAC":"D", "GAA":"E", "GAG":"E",
"GGU":"G", "GGC":"G", "GGA":"G", "GGG":"G",}
import re
file = open('rosalind_prot.txt', "r")
string = file.read()
def RNA_to_protein(rna):
s = ""
for i in re.findall("[AUGC]{3}",rna): # here re will give us a list of triplets
if map[i] == "Stop": # this is just for Rosalind so i don't print Stop codon
return s
s += map[i]
print(RNA_to_protein(string))