-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rna.py
49 lines (39 loc) · 1.69 KB
/
Rna.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
print("Please input DNA strand")
dna = input()
# RNA codon table
rna_codon = {"UUU" : "F", "CUU" : "L", "AUU" : "I", "GUU" : "V",
"UUC" : "F", "CUC" : "L", "AUC" : "I", "GUC" : "V",
"UUA" : "L", "CUA" : "L", "AUA" : "I", "GUA" : "V",
"UUG" : "L", "CUG" : "L", "AUG" : "M", "GUG" : "V",
"UCU" : "S", "CCU" : "P", "ACU" : "T", "GCU" : "A",
"UCC" : "S", "CCC" : "P", "ACC" : "T", "GCC" : "A",
"UCA" : "S", "CCA" : "P", "ACA" : "T", "GCA" : "A",
"UCG" : "S", "CCG" : "P", "ACG" : "T", "GCG" : "A",
"UAU" : "Y", "CAU" : "H", "AAU" : "N", "GAU" : "D",
"UAC" : "Y", "CAC" : "H", "AAC" : "N", "GAC" : "D",
"UAA" : "STOP", "CAA" : "Q", "AAA" : "K", "GAA" : "E",
"UAG" : "STOP", "CAG" : "Q", "AAG" : "K", "GAG" : "E",
"UGU" : "C", "CGU" : "R", "AGU" : "S", "GGU" : "G",
"UGC" : "C", "CGC" : "R", "AGC" : "S", "GGC" : "G",
"UGA" : "STOP", "CGA" : "R", "AGA" : "R", "GGA" : "G",
"UGG" : "W", "CGG" : "R", "AGG" : "R", "GGG" : "G"
}
rna = ""
for i in dna:
if i == "T":
rna += "U"
else:
rna += i
print("RNA strand", rna)
print("Would you like to convert to protein sequence? Yes/No")
def generate_protein():
protein_string = ""
for i in range(0, len(rna)-(3+len(rna)%3), 3):
if rna_codon[rna[i:i+3]] == "STOP" :
break
protein_string += rna_codon[rna[i:i+3]]
# Print the protein string
print( "Protein String: ", protein_string)
if input().lower() == "yes":
generate_protein()
# source: https://towardsdatascience.com/starting-off-in-bioinformatics-rna-transcription-and-translation-aaa7a91db031