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
50
51
52
53
54
|
#!/usr/bin/env python
def prot(condon):
if condon in ['GCU', 'GCC', 'GCA', 'GCG']:
return 'A'
elif condon in ['CGU', 'CGC', 'CGA', 'CGG', 'AGA', 'AGG']:
return 'R'
elif condon in ['AAU', 'AAC']:
return 'N'
elif condon in ['GAU', 'GAC']:
return 'D'
elif condon in ['UGU', 'UGC']:
return 'C'
elif condon in ['CAA', 'CAG']:
return 'Q'
elif condon in ['GAA', 'GAG']:
return 'E'
elif condon in ['GGU', 'GGC', 'GGA', 'GGG']:
return 'G'
elif condon in ['CAU', 'CAC']:
return 'H'
elif condon in ['UUA', 'UUG', 'CUU', 'CUC', 'CUA', 'CUG']:
return 'L'
elif condon in ['AUU', 'AUC', 'AUA']:
return 'I'
elif condon in ['AAA', 'AAG']:
return 'K'
elif condon in ['AUG']:
return 'M'
elif condon in ['UUU', 'UUC']:
return 'F'
elif condon in ['CCU', 'CCC', 'CCA', 'CCG']:
return 'P'
elif condon in ['UCU', 'UCC', 'UCA', 'UCG', 'AGU', 'AGC']:
return 'S'
elif condon in ['ACU', 'ACC', 'ACA', 'ACG']:
return 'T'
elif condon in ['UGG']:
return 'W'
elif condon in ['UAU', 'UAC']:
return 'Y'
elif condon in ['GUU', 'GUC', 'GUA', 'GUG']:
return 'V'
elif condon in ['AUG', 'UAA', 'UGA', 'UAG']:
return ''
else:
print('Not proper condon input.')
with open('rosalind_prot.txt') as f:
RNA_string = f.readline().strip()
p_len = int(len(RNA_string)/3)
prots = [prot(RNA_string[i*3:i*3+3]) for i in range(p_len)]
prot_string = ''.join(prots)
print(prot_string)
|