-
Notifications
You must be signed in to change notification settings - Fork 0
/
protien_operations.py
115 lines (105 loc) · 2.29 KB
/
protien_operations.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
# determining the acid structure
acid = {}
acid['TTT'] = 'F'
acid['TTC'] = 'F'
acid['TTA'] = 'K'
acid['TTG'] = 'K'
acid['TCT'] = 'S'
acid['TCC'] = 'S'
acid['TCA'] = 'S'
acid['TCG'] = 'S'
acid['TAT'] = 'Y'
acid['TAC'] = 'Y'
acid['TAA'] = 'stop'
acid['TAG'] = 'stop'
acid['TGT'] = 'C'
acid['TGC'] = 'C'
acid['TGA'] = 'stop'
acid['TGG'] = 'W'
acid['CTT'] = 'K'
acid['CTC'] = 'K'
acid['CTA'] = 'K'
acid['CTG'] = 'K'
acid['CCT'] = 'P'
acid['CCC'] = 'P'
acid['CCA'] = 'P'
acid['CCG'] = 'P'
acid['CAT'] = 'H'
acid['CAC'] = 'H'
acid['CAA'] = 'Z'
acid['CAG'] = 'Z'
acid['CGT'] = 'R'
acid['CGC'] = 'R'
acid['CGA'] = 'R'
acid['CGG'] = 'R'
acid['ATT'] = 'I'
acid['ATC'] = 'I'
acid['ATA'] = 'I'
acid['ATG'] = 'M'
acid['ACT'] = 'T'
acid['ACC'] = 'T'
acid['ACA'] = 'T'
acid['ACG'] = 'T'
acid['AAT'] = 'N'
acid['AAC'] = 'N'
acid['AAA'] = 'K'
acid['AAG'] = 'K'
acid['AGT'] = 'S'
acid['AGC'] = 'S'
acid['AGA'] = 'R'
acid['AGG'] = 'R'
acid['GTT'] = 'V'
acid['GTC'] = 'V'
acid['GTA'] = 'V'
acid['GTG'] = 'V'
acid['GCT'] = 'A'
acid['GCC'] = 'A'
acid['GCA'] = 'A'
acid['GCG'] = 'A'
acid['GAT'] = 'N'
acid['GAC'] = 'N'
acid['GAA'] = 'Q'
acid['GAG'] = 'Q'
acid['GGT'] = 'G'
acid['GGC'] = 'G'
acid['GGA'] = 'G'
acid['GGG'] = 'G'
def findAcid(newlist):
replacedProtien = []
for item in newlist:
if(item.upper() in acid):
replacedProtien.append(acid[item.upper()])
else:
replacedProtien.append(NULL)
return replacedProtien
# checking wether the protien is valid or not
def isProtienValid(_str_):
if(_str_[-4:-1] == 'taa' or 'uaa' or _string_ == 'uag' or _string_ == 'uga'):
if(len(_str_) % 3 == 0): # checking for multiples of 3
return True
else:
return False
else:
return False
def splitSequence(_str_):
newarray = []
for i in range(0, len(_str_), 3):
newarray.append(_str_[i:i + 3])
return newarray
def countOccurences(_str_):
from collections import Counter
return(Counter(list(_str_)))
# counter long form
# def countOccurences(_str_):
# occurences = {
# 'a' : 0,
# 't' : 0,
# 'g' : 0,
# 'c' : 0
# }
# for item in _str_:
# if(item in occurences):
# occurences[item] += 1
# return(occurences['a'],occurences['t'],occurences['g'],occurences['c'])
if __name__ == '__main__':
print(isProtienValid('uaa'))