forked from angrygeese/HW4_Functions2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mol_formula.py
127 lines (127 loc) · 2.82 KB
/
mol_formula.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
def protein_formula(seq: str):
"Returns molecular formula of the protein"
fС = 0
fH = 0
fN = 0
fO = 0
fS = 0
for amino in seq:
if amino == "A":
fС += 3
fH += 7
fN += 1
fO += 2
fS += 0
elif amino == "R":
fС += 6
fH += 14
fN += 4
fO += 2
fS += 0
elif amino == "N":
fС += 4
fH += 8
fN += 2
fO += 3
fS += 0
elif amino == "V":
fС += 5
fH += 11
fN += 1
fO += 2
fS += 0
elif amino == "H":
fС += 6
fH += 9
fN += 3
fO += 2
fS += 0
elif amino == "G":
fС += 2
fH += 5
fN += 1
fO += 2
fS += 0
elif amino == "Q":
fС += 5
fH += 10
fN += 2
fO += 3
fS += 0
elif amino == "E":
fС += 5
fH += 9
fN += 1
fO += 4
fS += 0
elif amino == "I":
fС += 6
fH += 13
fN += 1
fO += 2
fS += 0
elif amino == "L":
fС += 6
fH += 13
fN += 1
fO += 2
fS += 0
elif amino == "K":
fС += 6
fH += 14
fN += 2
fO += 2
fS += 0
elif amino == "M":
fС += 5
fH += 11
fN += 1
fO += 2
fS += 1
elif amino == "P":
fС += 5
fH += 9
fN += 1
fO += 2
fS += 0
elif amino == "S":
fС += 3
fH += 7
fN += 1
fO += 3
fS += 0
elif amino == "Y":
fС += 9
fH += 11
fN += 1
fO += 3
fS += 0
elif amino == "T":
fС += 4
fH += 9
fN += 1
fO += 3
fS += 0
elif amino == "W":
fС += 11
fH += 12
fN += 2
fO += 2
fS += 0
elif amino == "F":
fС += 9
fH += 11
fN += 1
fO += 2
fS += 0
else:
fС += 4
fH += 7
fN += 1
fO += 4
fS += 0
if fS == 0:
aa_formula = f'С: {fС}, H: {fH}, N: {fN}, O:{fO}'
else:
aa_formula = f'С: {fС}, H: {fH}, N: {fN}, O:{fO}, S: {fS}'
return aa_formula