-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProteinParam.py
227 lines (197 loc) · 8.21 KB
/
ProteinParam.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#Various analysis classes and functions for the generation of additional properties from a given protein amino acid sequence
#imports (biopython)
import Bio
from Bio.SeqUtils import ProtParam
#Amino acid groupings
amino_acids = ['A','R','N','D','C','Q','E','G','H','I','L','K','M','F','P','O','S','T','W','Y','V']
hpho_res = ['A','G','F','I','L','M','P','V','W']
hphi_res = ['R','K','H','D','E','S','T','N','Q','C','Y']
pos_res = ['R','K','H']
neg_res = ['D','E']
aro_res = ['F','Y','W']
class SequenceAnalysis():
"""This class analyzes basic content of a given protein sequence"""
def __init__(self):
pass
def seq_length(self, sequence):
sequence = sequence.upper()
return len(sequence)
def hydrophobic_res(self, sequence):
pho_value = 0
sequence = sequence.upper()
for i in sequence:
if i in hpho_res:
pho_value += 1
return pho_value
def hydrophilic_res(self, sequence):
value = 0
sequence = sequence.upper()
for i in sequence:
if i in hphi_res:
value += 1
return value
def positive_res(self, sequence):
value = 0
sequence = sequence.upper()
for i in sequence:
if i in pos_res:
value += 1
return value
def negative_res(self, sequence):
value = 0
sequence = sequence.upper()
for i in sequence:
if i in neg_res:
value += 1
return value
def aromatic_res(self, sequence):
value = 0
sequence = sequence.upper()
for i in sequence:
if i in aro_res:
value += 1
return value
#counts number of cysteine residues
def cysteine_res(self, sequence):
value = 0
sequence = sequence.upper()
for i in sequence:
if i == 'C':
value += 1
return value
class ProteinProperties(SequenceAnalysis):
"""This class calculates various ratios and theoretical properties of the given protein sequence"""
def __init__(self):
super().__init__()
#calculates the hydrophobic ratio of the entire sequence
def hydrophobic_ratio(self, sequence):
hphobic_res = self.hydrophobic_res(sequence)
ratio = float(hphobic_res/len(sequence))
return ratio
#calculates the hydrophilic ratio of the entire sequence
def hydrophilic_ratio(self, sequence):
hphilic_res = self.hydrophilic_res(sequence)
ratio = float(hphilic_res/len(sequence))
return ratio
#calculates the hydrophobic/hydrophilic ratio of the sequence
def hydro_ratio(self, sequence):
hphobic_res = self.hydrophobic_res(sequence)
hphilic_res = self.hydrophilic_res(sequence)
ratio = float(hphobic_res/hphilic_res)
return ratio
#calculates the aromatic ratio of the entire sequence
def aromatic_ratio(self, sequence):
aro_res = self.aromatic_res(sequence)
ratio = float(aro_res/len(sequence))
return ratio
#calculates the isoelectric point of give sequence
def isoelectric_point(self, sequence):
x = ProtParam.ProteinAnalysis(sequence)
pI = x.isoelectric_point()
return pI
#calculates the alipathic index of given sequence, higher index indicates a more stable protein
def alipathic_index(self, sequence):
sequence = sequence.upper()
ali_index = float(100*sequence.count('A')/len(sequence) + 2.9*(100*sequence.count('V')/len(sequence)) + 3.9*(100*sequence.count('I')/len(sequence) + 100*sequence.count('L')/len(sequence)))
return ali_index
#estimates overall charge at specified pH (theoretical and highly dependent on physicochemical environment)
def charge_ph(self, sequence, ph=7.0):
carboxy_values = {'D':3.65,'E':4.25}
amino_values = {'K':10.53,'R':12.48,'H':6.0}
carboxy_list = [3.3]
amino_list = [7.7]
for i in sequence.upper():
if i in carboxy_values:
carboxy_list.append(carboxy_values[i])
elif i in amino_values:
amino_list.append(amino_values[i])
below = len([1 for i in carboxy_list if i >= ph])
above = len([1 for i in amino_list if i < ph])
overall_charge = above-below
return overall_charge
#calculates the MW in Daltons for sequence
def molecular_weight(self, sequence):
amino_acid_weights = {'A':89.09, 'C':121.16, 'D':133.1, 'E':147.13, 'F':165.19, 'G':75.07, 'H':155.16,
'I':131.18, 'K':146.19, 'L':131.18, 'M':149.21, 'N':132.12, 'P':115.13, 'Q':146.15,
'R':174.2, 'S':105.09, 'T':119.12, 'V':117.15, 'W':204.23, 'Y':181.19}
mw = 16.02 - (18.02*(len(sequence)-1))
for i in sequence.upper():
if i in amino_acid_weights:
mw += amino_acid_weights[i]
return mw
class ProteinMotifs(SequenceAnalysis):
"""
This class contains methods for finding certain structure, glycosylation or ligand binding motifs in the protein
sequence. Predictions are purely theoretical and it should be noted that sequence motifs can occur randomly. Also,
this list of motifs is by no means exhaustive.
"""
def __init__(self):
super().__init__()
#checks sequence for absence (0) or presence (1) of Cardin-Weintraub motif (heparin binding motif based on Cardin and Weintraub 1989)
def cardin_weintraub(self, sequence):
basic_res = ['R','K','H']
seq_mod = []
for i in sequence.upper():
if i in basic_res:
seq_mod.append('B')
elif i in hpho_res:
seq_mod.append('X')
else:
seq_mod.append('Y')
if 'XBBXBX' in ''.join(str(i) for i in seq_mod) or 'XBXBBX' in ''.join(str(i) for i in seq_mod):
motif = 1
elif 'XBBBXXBX' in ''.join(str(i) for i in seq_mod) or 'XBXXBBBX' in ''.join(str(i) for i in seq_mod):
motif = 1
else:
motif = 0
return motif
#counts number of specific Cardin-Weintraub motifs (heparin binding motif based on Cardin and Weintraub 1989)
def cardin_weintraub_number(self, sequence):
basic_res = ['R','K','H']
seq_mod = []
cw_number = 0
for i in sequence.upper():
if i in basic_res:
seq_mod.append('B')
elif i in hpho_res:
seq_mod.append('X')
else:
seq_mod.append('Y')
if 'XBBXBX' in ''.join(str(i) for i in seq_mod) or 'XBXBBX' in ''.join(str(i) for i in seq_mod):
cw_number += 1
elif 'XBBBXXBX' in ''.join(str(i) for i in seq_mod) or 'XBXXBBBX' in ''.join(str(i) for i in seq_mod):
cw_number += 1
else:
pass
return cw_number
#checks sequence for the any N-glycosylation patterns
def n_glycosylation(self, sequence):
x_residues = ['A','R','D','C','Q','E','G','H','I','L','K','M','F','O','W','Y','V']
motif_seq = ['NXS','NXT','NSS','NTS','NST','NTT']
seq_mod = []
for i in sequence.upper():
if i in x_residues:
seq_mod.append('X')
else:
seq_mod.append(i)
if i in ''.join(str(i) for i in motif_seq):
motif = 1
else:
motif = 0
return motif
#counts the number of N-glycosylation patterns
def n_glycosylation_number(self, sequence):
x_residues = ['A','R','D','C','Q','E','G','H','I','L','K','M','F','O','W','Y','V']
motif_seq = ['NXS','NXT','NSS','NTS','NST','NTT']
seq_mod = []
ng_number = 0
for i in sequence.upper():
if i in x_residues:
seq_mod.append('X')
else:
seq_mod.append(i)
if i in ''.join(str(i) for i in motif_seq):
ng_number += 1
else:
pass
return ng_number