-
Notifications
You must be signed in to change notification settings - Fork 0
/
14. Inferring mRNA from protein
56 lines (36 loc) · 1.89 KB
/
14. Inferring mRNA from 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
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
55
56
#!/usr/bin/env python
#PROBLEM
#===========
#For positive integers a and n, a modulo n (written amodn in shorthand) is the remainder when a is divided by n. For example, 29mod11=7 because 29=11×2+7.
#Modular arithmetic is the study of addition, subtraction, multiplication, and division with respect to the modulo operation. We say that a and b are
#congruent modulo n if amodn=bmodn; in this case, we use the notation a≡bmodn.
#Two useful facts in modular arithmetic are that if a≡bmodn and c≡dmodn, then a+c≡b+dmodn and a×c≡b×dmodn. To check your understanding of these rules,
#you may wish to verify these relationships for a=29, b=73, c=10, d=32, and n=11.
#As you will see in this exercise, some Rosalind problems will ask for a (very large) integer solution modulo a smaller number to avoid the computational
#pitfalls that arise with storing such large numbers.
#Given: A protein string of length at most 1000 aa.
#Return: The total number of different RNA strings from which the protein could have been translated, modulo 1,000,000. (Don't neglect importance of stop codon.)
#Sample Dataset
#MA
#Sample Output
#12
#===========
#CODE
protein_seq = input("Enter your protein sequence:")
combinato = 1
for i in protein_seq:
if i == "W" or i == "M":
combinato = combinato*1
elif i == "F" or i == "Y" or i == "C" or i == "H" or i == "Q" or i == "N" or i == "K" or i == "D" or i == "E":
combinato = combinato*2
elif i == "I":
combinato = combinato*3
elif i == "P" or i == "T" or i == "V" or i == "A" or i == "G":
combinato = combinato*4
elif i == "L" or i == "S" or i == "R":
combinato = combinato*6
else:
print("There is an error")
modulus_result = (combinato*3) % 1000000
print("The number of possible combinations is", combinato*3)
print("The result in modulo 1000000 is", modulus_result)