tap-developability 2.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tap_developability/CDR_Profiler/CDR_Assigner.py +96 -0
- tap_developability/CDR_Profiler/__init__.py +0 -0
- tap_developability/Hydrophobicity_and_Charge_Profiler/Common/PDBUtils.py +187 -0
- tap_developability/Hydrophobicity_and_Charge_Profiler/Common/__init__.py +0 -0
- tap_developability/Hydrophobicity_and_Charge_Profiler/Hydrophobicity_and_Charge_Assigner.py +814 -0
- tap_developability/Hydrophobicity_and_Charge_Profiler/__init__.py +0 -0
- tap_developability/Hydrophobicity_and_Charge_Profiler/dat/Hydrophobics.txt +20 -0
- tap_developability/Hydrophobicity_and_Charge_Profiler/surface.py +126 -0
- tap_developability/Plotters/CDRLen_D3_Template.py +3 -0
- tap_developability/Plotters/PNC_D3_Template.py +3 -0
- tap_developability/Plotters/PPC_D3_Template.py +3 -0
- tap_developability/Plotters/PSH_D3_Template.py +3 -0
- tap_developability/Plotters/SFvCSP_D3_Template.py +3 -0
- tap_developability/Plotters/__init__.py +26 -0
- tap_developability/__init__.py +0 -0
- tap_developability/cli.py +470 -0
- tap_developability/structure/__init__.py +0 -0
- tap_developability/structure/pdb_remove_hydrogens.py +28 -0
- tap_developability/structure/process_pdb.py +311 -0
- tap_developability/structure/sequence_liabilities.py +74 -0
- tap_developability/thresholds.py +91 -0
- tap_developability-2.0.1.dist-info/METADATA +202 -0
- tap_developability-2.0.1.dist-info/RECORD +26 -0
- tap_developability-2.0.1.dist-info/WHEEL +4 -0
- tap_developability-2.0.1.dist-info/entry_points.txt +3 -0
- tap_developability-2.0.1.dist-info/licenses/LICENCE +11 -0
|
@@ -0,0 +1,814 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import sys
|
|
3
|
+
from .Common.PDBUtils import PDBchain
|
|
4
|
+
from .surface import side_chain_accessibility
|
|
5
|
+
import pickle
|
|
6
|
+
import numpy as np
|
|
7
|
+
from importlib.resources import files
|
|
8
|
+
|
|
9
|
+
##################################################################################
|
|
10
|
+
#FUNCTION to REMOVE INSERTION CODES from NUMBERING
|
|
11
|
+
#
|
|
12
|
+
def stripInsertionCode(res):
|
|
13
|
+
insertion = ""
|
|
14
|
+
icode = ['Z','X','C','V','B','N','M','L','K','J','H','G','F','D','S','A','W','Q','E','R','T','Y','U','I','O','P'] #eg. 100A -> 100, 100B -> 100...
|
|
15
|
+
for q in icode:
|
|
16
|
+
if res.endswith(q): #if last letter is non-numical
|
|
17
|
+
#print res
|
|
18
|
+
res,insertion = res[0:(len(res)-1)],q #strip it
|
|
19
|
+
#print res,insertion
|
|
20
|
+
return res,insertion
|
|
21
|
+
|
|
22
|
+
##################################################################################
|
|
23
|
+
#FUNCTION to CHECK if a RESIDUE is a CDR RESIDUE (+/- 2) in Chothia/IMGT
|
|
24
|
+
|
|
25
|
+
def is_CDR(res,deff):
|
|
26
|
+
|
|
27
|
+
_res,ins = stripInsertionCode(res)
|
|
28
|
+
for CDR in definitions[deff]:
|
|
29
|
+
if _res in definitions[deff][CDR]:
|
|
30
|
+
return CDR
|
|
31
|
+
return False
|
|
32
|
+
|
|
33
|
+
##################################################################################
|
|
34
|
+
#FUNCTION to CHECK if a RESIDUE is a SPECIFIC CDR RESIDUE (+/-2) in Chothia/IMGT
|
|
35
|
+
|
|
36
|
+
def is_partic_CDR(res,deff,cdr_id):
|
|
37
|
+
|
|
38
|
+
_res,ins = stripInsertionCode(res)
|
|
39
|
+
if _res in definitions[deff][str(cdr_id)]:
|
|
40
|
+
return cdr_id
|
|
41
|
+
return False
|
|
42
|
+
|
|
43
|
+
##################################################################################
|
|
44
|
+
#PREREQUISITES#
|
|
45
|
+
|
|
46
|
+
#Classifying residues by hydrophobicity
|
|
47
|
+
Naive_HH = {
|
|
48
|
+
'ALA': 'B',
|
|
49
|
+
'ARG': 'C',
|
|
50
|
+
'ASN': 'U',
|
|
51
|
+
'ASP': 'C',
|
|
52
|
+
'CYS': 'S',
|
|
53
|
+
'GLU': 'C',
|
|
54
|
+
'GLN': 'U',
|
|
55
|
+
'GLY': 'S',
|
|
56
|
+
'HIS': 'C',
|
|
57
|
+
'ILE': 'H',
|
|
58
|
+
'LEU': 'H',
|
|
59
|
+
'LYS': 'C',
|
|
60
|
+
'MET': 'B',
|
|
61
|
+
'PHE': 'H',
|
|
62
|
+
'PRO': 'S',
|
|
63
|
+
'SER': 'U',
|
|
64
|
+
'THR': 'U',
|
|
65
|
+
'TRP': 'H',
|
|
66
|
+
'TYR': 'H',
|
|
67
|
+
'VAL': 'H'}
|
|
68
|
+
|
|
69
|
+
coloring = {'H':100,'C':25,'U':50,'S':75}
|
|
70
|
+
|
|
71
|
+
#Three letter:One letter translation table
|
|
72
|
+
AAtable = {
|
|
73
|
+
'ALA': 'A',
|
|
74
|
+
'ARG': 'R',
|
|
75
|
+
'ASN': 'N',
|
|
76
|
+
'ASP': 'D',
|
|
77
|
+
'CYS': 'C',
|
|
78
|
+
'GLU': 'E',
|
|
79
|
+
'GLN': 'Q',
|
|
80
|
+
'GLY': 'G',
|
|
81
|
+
'HIS': 'H',
|
|
82
|
+
'ILE': 'I',
|
|
83
|
+
'LEU': 'L',
|
|
84
|
+
'LYS': 'K',
|
|
85
|
+
'MET': 'M',
|
|
86
|
+
'PHE': 'F',
|
|
87
|
+
'PRO': 'P',
|
|
88
|
+
'SER': 'S',
|
|
89
|
+
'THR': 'T',
|
|
90
|
+
'TRP': 'W',
|
|
91
|
+
'TYR': 'Y',
|
|
92
|
+
'VAL': 'V'}
|
|
93
|
+
|
|
94
|
+
#CDR Definitions - Chothia/IMGT +2 on either side...
|
|
95
|
+
|
|
96
|
+
definitions = {
|
|
97
|
+
"chothia" : {"L1" : ["L22","L23","L24", "L25", "L26", "L27", "L28", "L29", "L30", "L31", "L32", "L33", "L34","L35","L36"],
|
|
98
|
+
"L2" : ["L48","L49","L50", "L51", "L52", "L53", "L54", "L55", "L56","L57","L58"],
|
|
99
|
+
"L3" : ["L87","L88","L89", "L90", "L91", "L92", "L93", "L94", "L95", "L96", "L97","L98","L99"],
|
|
100
|
+
"H1" : ["H24","H25","H26", "H27", "H28", "H29", "H30", "H31", "H32","H33","H34"],
|
|
101
|
+
"H2" : ["H50","H51","H52", "H53", "H54", "H55", "H56","H57","H58"] ,
|
|
102
|
+
"H3" : ["H93","H94","H95", "H96", "H97", "H98", "H99", "H100", "H101", "H102","H103","H104"]},
|
|
103
|
+
"imgt" : {"L1" : ["L25","L26","L27","L28","L29","L30","L31","L32","L33","L34","L35","L36","L37","L38","L39","L40"],
|
|
104
|
+
"L2" : ["L54","L55","L56","L57","L58","L59","L60","L61","L62","L63","L64","L65","L66", "L67"],
|
|
105
|
+
"L3" : ["L103","L104","L105","L106","L107","L108","L109","L110","L111","L112","L113","L114","L115","L116","L117","L118","L119"],
|
|
106
|
+
"H1" : ["H25","H26","H27","H28","H29","H30","H31","H32","H33","H34","H35","H36","H37","H38","H39","H40"],
|
|
107
|
+
"H2" : ["H54","H55","H56","H57","H58","H59","H60","H61","H62","H63","H64","H65","H66", "H67"],
|
|
108
|
+
"H3" : ["H103","H104","H105","H106","H107","H108","H109","H110","H111","H112","H113","H114","H115","H116","H117","H118","H119"]
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
#############################################################################################
|
|
113
|
+
#NORMALISES HYDROPHOBICITY to a Z-SCORE#
|
|
114
|
+
|
|
115
|
+
def normalize(matrix,index):
|
|
116
|
+
|
|
117
|
+
vals = []
|
|
118
|
+
|
|
119
|
+
for residue in matrix:
|
|
120
|
+
vals.append(matrix[residue][index]) #adds the appropriate hydrophobicity value H(R,S), unnormalised hydrophobicity R in scoring scheme S
|
|
121
|
+
|
|
122
|
+
annotation = dict()
|
|
123
|
+
|
|
124
|
+
mu = np.mean(vals) #compute mean of the list
|
|
125
|
+
sigma = np.std(vals) #compute sd of the list
|
|
126
|
+
|
|
127
|
+
for residue in matrix:
|
|
128
|
+
|
|
129
|
+
#Normalizing to between 1 and 2
|
|
130
|
+
annotation[residue]= ((matrix[residue][index]+(0-min(vals)))/((max(vals)-min(vals))))+1.0
|
|
131
|
+
|
|
132
|
+
return annotation
|
|
133
|
+
|
|
134
|
+
############################################################################################
|
|
135
|
+
#FUNCTION to EVALUATE CHARGE of RESIDUES#
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
#######################################################################################
|
|
139
|
+
#MORE PREREQUISITES
|
|
140
|
+
|
|
141
|
+
#Which of the three classes do we belong to: positive, negative, or hydrophobic (or none)?
|
|
142
|
+
residue_classes = ['hydrophobic','positive','negative']
|
|
143
|
+
|
|
144
|
+
#######################################################################################
|
|
145
|
+
#PRIMARY ANNOTATING FUNCTION#
|
|
146
|
+
|
|
147
|
+
def CreateAnnotation(annotation_index,which_ph,input_file,output_file,chains,numbering_scheme,output_path,verbose=True):
|
|
148
|
+
|
|
149
|
+
#Load In All Hydrophobicity Information from hydrophobics.txt
|
|
150
|
+
|
|
151
|
+
hydrophobics = dict()
|
|
152
|
+
|
|
153
|
+
for line in files(__package__).joinpath('dat', 'Hydrophobics.txt').read_text().splitlines():
|
|
154
|
+
line = line.strip().split('\t')
|
|
155
|
+
hydrophobics[line[0].upper()] = (float(line[1]),float(line[2]),float(line[3]),float(line[4]),float(line[5])) #key = ALA,ILE etc. value = tuple with 5 separate scores
|
|
156
|
+
|
|
157
|
+
#Normalize the hydrophobics
|
|
158
|
+
|
|
159
|
+
hydrophobicity_annotation = normalize(hydrophobics,annotation_index) #calls up a function to normalise the scores within requested scoring system
|
|
160
|
+
|
|
161
|
+
#STEP 1. Get the surface-exposed residues: the relative accessibility (%) and the total area of each side chain
|
|
162
|
+
|
|
163
|
+
asa, asa_area = side_chain_accessibility(input_file)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
#STEP 2: Evaluate Hydrophobicity-Scaled Accessible Surface Areas (HASAs) and Charges
|
|
167
|
+
|
|
168
|
+
ab_structure = {'H':PDBchain(input_file,'H'),'L':PDBchain(input_file,'L')} #Load in the ab heavy and light chains in following format
|
|
169
|
+
heavy_fv_charge = 0
|
|
170
|
+
light_fv_charge = 0
|
|
171
|
+
h1_charge = 0
|
|
172
|
+
h2_charge = 0
|
|
173
|
+
h3_charge = 0
|
|
174
|
+
l1_charge = 0
|
|
175
|
+
l2_charge = 0
|
|
176
|
+
l3_charge = 0
|
|
177
|
+
|
|
178
|
+
num_cdr_charged = 0
|
|
179
|
+
num_heavy_fv_charged = 0
|
|
180
|
+
num_light_fv_charged = 0
|
|
181
|
+
|
|
182
|
+
residues = dict()
|
|
183
|
+
|
|
184
|
+
for chain in ['H','L']:
|
|
185
|
+
for elem in sorted(ab_structure[chain].residues):
|
|
186
|
+
|
|
187
|
+
typ = ab_structure[chain].residues[elem].res_type #Assign the residue a type
|
|
188
|
+
|
|
189
|
+
r_elem = {'res':ab_structure[chain].residues[elem],'typ':typ,'charge':0} #store this type, add future properties
|
|
190
|
+
bfact = 0
|
|
191
|
+
res_asa = 0
|
|
192
|
+
res_asa_area = 0
|
|
193
|
+
|
|
194
|
+
try:
|
|
195
|
+
res_asa = asa[chain][str(elem[0])+elem[1]] #Looks up the accessibility of residue H4, for example
|
|
196
|
+
res_asa_area = asa_area[chain][str(elem[0])+elem[1]] #Looks up as above, but in the area dictionary
|
|
197
|
+
|
|
198
|
+
except KeyError:
|
|
199
|
+
sys.stderr.write("ASA ERROR: %s" % input_file) #Write these messages to standard error for diagnosis
|
|
200
|
+
#sys.stderr.write(" Method: %d\n" % annotation) #Write these messages to standard error for diagnosis
|
|
201
|
+
#quit()
|
|
202
|
+
|
|
203
|
+
if res_asa < 7.5: #If residue is buried (accessible surface area of less than 7.5, ignore.
|
|
204
|
+
continue
|
|
205
|
+
|
|
206
|
+
r_elem['asa'] = res_asa #Populates residue dictionary with asa score
|
|
207
|
+
r_elem['asa_sum'] = res_asa_area #Populates residue diction with asa area score
|
|
208
|
+
if np.isnan(r_elem['asa_sum']) == True:
|
|
209
|
+
if verbose: print("NAN Residue Detected: "+r_elem['typ'],chain,elem[0]+elem[1])
|
|
210
|
+
break
|
|
211
|
+
r_elem['hydrophobic'] = float(hydrophobicity_annotation[typ]) #Looks up normalised hydrophobicity score for this residue, populates residue dictionary.
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
residues[(chain,elem)] = r_elem #Finally collates all residues in the ab together, key is chain and number and value is their property dictionary
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
#Define CDR neighborhood- so as not to calculate CDRs only...
|
|
218
|
+
cdr_vicinity = []
|
|
219
|
+
|
|
220
|
+
#Salt Bridge List, for second iteration...
|
|
221
|
+
sb_list = []
|
|
222
|
+
num_saltbridges = 0
|
|
223
|
+
|
|
224
|
+
#Calculate cdrs and their neighbors.
|
|
225
|
+
number_cdr_residues = 0
|
|
226
|
+
number_heavy_fv_residues = 0
|
|
227
|
+
number_light_fv_residues = 0
|
|
228
|
+
|
|
229
|
+
for r1 in residues:
|
|
230
|
+
numbering = r1[0]+str(r1[1][0]) #residues dictionary has tuple keys: (chain,elem); so eg. H111, no insertion code
|
|
231
|
+
#print "**********"+str(residues[r1]['typ'])+"-"+str(r1[0])+str(r1[1][0])+"**********"
|
|
232
|
+
if is_CDR(numbering,numbering_scheme)==False:
|
|
233
|
+
if r1[0] == "H":
|
|
234
|
+
#print AAtable[str(residues[r1]['typ'])]
|
|
235
|
+
if AAtable[str(residues[r1]['typ'])] == "D" or AAtable[str(residues[r1]['typ'])] == "E":
|
|
236
|
+
heavy_fv_charge = heavy_fv_charge - 1
|
|
237
|
+
num_heavy_fv_charged += 1
|
|
238
|
+
residues[r1]['negative'] = -1
|
|
239
|
+
residues[r1]['charge'] = -1
|
|
240
|
+
elif AAtable[str(residues[r1]['typ'])] == "R" or AAtable[str(residues[r1]['typ'])] == "K":
|
|
241
|
+
heavy_fv_charge = heavy_fv_charge + 1
|
|
242
|
+
num_heavy_fv_charged += 1
|
|
243
|
+
residues[r1]['positive'] = 1
|
|
244
|
+
residues[r1]['charge'] = 1
|
|
245
|
+
elif AAtable[str(residues[r1]['typ'])] == "H":
|
|
246
|
+
heavy_fv_charge = heavy_fv_charge + 0.1 #appropriate at pH 7.4 according to Henderson-Hasselbalch. Could generalise method to any given pH.
|
|
247
|
+
num_heavy_fv_charged += 1
|
|
248
|
+
residues[r1]['positive'] = 0.1
|
|
249
|
+
residues[r1]['charge'] = 0.1
|
|
250
|
+
|
|
251
|
+
number_heavy_fv_residues += 1
|
|
252
|
+
|
|
253
|
+
if verbose:
|
|
254
|
+
print(str(r1),str(residues[r1]['typ']),"Heavy Fv Charge is: ",heavy_fv_charge)
|
|
255
|
+
|
|
256
|
+
continue
|
|
257
|
+
|
|
258
|
+
elif r1[0] == "L":
|
|
259
|
+
if AAtable[str(residues[r1]['typ'])] == "D" or AAtable[str(residues[r1]['typ'])] == "E":
|
|
260
|
+
light_fv_charge = light_fv_charge - 1
|
|
261
|
+
num_light_fv_charged += 1
|
|
262
|
+
residues[r1]['negative'] = -1
|
|
263
|
+
residues[r1]['charge'] = -1
|
|
264
|
+
elif AAtable[str(residues[r1]['typ'])] == "R" or AAtable[str(residues[r1]['typ'])] == "K":
|
|
265
|
+
light_fv_charge = light_fv_charge + 1
|
|
266
|
+
num_light_fv_charged += 1
|
|
267
|
+
residues[r1]['positive'] = 1
|
|
268
|
+
residues[r1]['charge'] = 1
|
|
269
|
+
elif AAtable[str(residues[r1]['typ'])] == "H":
|
|
270
|
+
light_fv_charge = light_fv_charge + 0.1
|
|
271
|
+
num_light_fv_charged += 1
|
|
272
|
+
residues[r1]['positive'] = 0.1
|
|
273
|
+
residues[r1]['charge'] = 0.1
|
|
274
|
+
|
|
275
|
+
number_light_fv_residues += 1
|
|
276
|
+
|
|
277
|
+
if verbose:
|
|
278
|
+
print(str(r1),str(residues[r1]['typ']),"Light Fv Charge is: ",light_fv_charge)
|
|
279
|
+
|
|
280
|
+
continue
|
|
281
|
+
|
|
282
|
+
else:
|
|
283
|
+
#print AAtable[str(residues[r1]['typ'])]
|
|
284
|
+
if r1[0] == "L":
|
|
285
|
+
if is_partic_CDR(numbering,numbering_scheme,"L1")=="L1":
|
|
286
|
+
if AAtable[str(residues[r1]['typ'])] == "D" or AAtable[str(residues[r1]['typ'])] == "E":
|
|
287
|
+
l1_charge = l1_charge - 1
|
|
288
|
+
num_cdr_charged += 1
|
|
289
|
+
residues[r1]['negative'] = -1
|
|
290
|
+
residues[r1]['charge'] = -1
|
|
291
|
+
elif AAtable[str(residues[r1]['typ'])] == "R" or AAtable[str(residues[r1]['typ'])] == "K":
|
|
292
|
+
l1_charge = l1_charge + 1
|
|
293
|
+
num_cdr_charged += 1
|
|
294
|
+
residues[r1]['positive'] = 1
|
|
295
|
+
residues[r1]['charge'] = 1
|
|
296
|
+
elif AAtable[str(residues[r1]['typ'])] == "H":
|
|
297
|
+
l1_charge = l1_charge + 0.1 #appropriate at pH 7.4 according to Henderson-Hasselbalch. Could generalise method to any given pH by evaluating this equation.
|
|
298
|
+
residues[r1]['positive'] = 0.1
|
|
299
|
+
residues[r1]['charge'] = 0.1
|
|
300
|
+
num_cdr_charged += 1
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
if is_partic_CDR(numbering,numbering_scheme,"L2")=="L2":
|
|
304
|
+
if AAtable[str(residues[r1]['typ'])] == "D" or AAtable[str(residues[r1]['typ'])] == "E":
|
|
305
|
+
l2_charge = l2_charge - 1
|
|
306
|
+
num_cdr_charged += 1
|
|
307
|
+
residues[r1]['negative'] = -1
|
|
308
|
+
residues[r1]['charge'] = -1
|
|
309
|
+
elif AAtable[str(residues[r1]['typ'])] == "R" or AAtable[str(residues[r1]['typ'])] == "K":
|
|
310
|
+
l2_charge = l2_charge + 1
|
|
311
|
+
num_cdr_charged += 1
|
|
312
|
+
residues[r1]['positive'] = 1
|
|
313
|
+
residues[r1]['charge'] = 1
|
|
314
|
+
elif AAtable[str(residues[r1]['typ'])] == "H":
|
|
315
|
+
l2_charge = l2_charge + 0.1 #appropriate at pH 7.4 according to Henderson-Hasselbalch. Could generalise method to any given pH by evaluating this equation.
|
|
316
|
+
residues[r1]['positive'] = 0.1
|
|
317
|
+
residues[r1]['charge'] = 0.1
|
|
318
|
+
num_cdr_charged += 1
|
|
319
|
+
|
|
320
|
+
if is_partic_CDR(numbering,numbering_scheme,"L3")=="L3":
|
|
321
|
+
if AAtable[str(residues[r1]['typ'])] == "D" or AAtable[str(residues[r1]['typ'])] == "E":
|
|
322
|
+
l3_charge = l3_charge - 1
|
|
323
|
+
num_cdr_charged += 1
|
|
324
|
+
residues[r1]['negative'] = -1
|
|
325
|
+
residues[r1]['charge'] = -1
|
|
326
|
+
elif AAtable[str(residues[r1]['typ'])] == "R" or AAtable[str(residues[r1]['typ'])] == "K":
|
|
327
|
+
l3_charge = l3_charge + 1
|
|
328
|
+
num_cdr_charged += 1
|
|
329
|
+
residues[r1]['positive'] = 1
|
|
330
|
+
residues[r1]['charge'] = 1
|
|
331
|
+
elif AAtable[str(residues[r1]['typ'])] == "H":
|
|
332
|
+
l3_charge = l3_charge + 0.1 #appropriate at pH 7.4 according to Henderson-Hasselbalch. Could generalise method to any given pH by evaluating this equation.
|
|
333
|
+
residues[r1]['positive'] = 0.1
|
|
334
|
+
residues[r1]['charge'] = 0.1
|
|
335
|
+
num_cdr_charged += 1
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
if AAtable[str(residues[r1]['typ'])] == "D" or AAtable[str(residues[r1]['typ'])] == "E":
|
|
339
|
+
light_fv_charge = light_fv_charge - 1
|
|
340
|
+
num_light_fv_charged += 1
|
|
341
|
+
residues[r1]['negative'] = -1
|
|
342
|
+
residues[r1]['charge'] = -1
|
|
343
|
+
elif AAtable[str(residues[r1]['typ'])] == "R" or AAtable[str(residues[r1]['typ'])] == "K":
|
|
344
|
+
light_fv_charge = light_fv_charge + 1
|
|
345
|
+
num_light_fv_charged += 1
|
|
346
|
+
residues[r1]['positive'] = 1
|
|
347
|
+
residues[r1]['charge'] = 1
|
|
348
|
+
elif AAtable[str(residues[r1]['typ'])] == "H":
|
|
349
|
+
light_fv_charge = light_fv_charge + 0.1
|
|
350
|
+
num_light_fv_charged += 1
|
|
351
|
+
residues[r1]['positive'] = 0.1
|
|
352
|
+
residues[r1]['charge'] = 0.1
|
|
353
|
+
number_light_fv_residues += 1
|
|
354
|
+
|
|
355
|
+
if verbose:
|
|
356
|
+
print(str(r1),str(residues[r1]['typ']),"Light Fv Charge is: ",light_fv_charge)
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
elif r1[0] == "H":
|
|
360
|
+
if is_partic_CDR(numbering,numbering_scheme,"H1")=="H1":
|
|
361
|
+
if AAtable[str(residues[r1]['typ'])] == "D" or AAtable[str(residues[r1]['typ'])] == "E":
|
|
362
|
+
h1_charge = h1_charge - 1
|
|
363
|
+
num_cdr_charged += 1
|
|
364
|
+
residues[r1]['negative'] = -1
|
|
365
|
+
residues[r1]['charge'] = -1
|
|
366
|
+
elif AAtable[str(residues[r1]['typ'])] == "R" or AAtable[str(residues[r1]['typ'])] == "K":
|
|
367
|
+
h1_charge = h1_charge + 1
|
|
368
|
+
num_cdr_charged += 1
|
|
369
|
+
residues[r1]['positive'] = 1
|
|
370
|
+
residues[r1]['charge'] = 1
|
|
371
|
+
elif AAtable[str(residues[r1]['typ'])] == "H":
|
|
372
|
+
h1_charge = h1_charge + 0.1 #appropriate at pH 7.4 according to Henderson-Hasselbalch. Could generalise method to any given pH by evaluating this equation.
|
|
373
|
+
num_cdr_charged += 1
|
|
374
|
+
residues[r1]['positive'] = 0.1
|
|
375
|
+
residues[r1]['charge'] = 0.1
|
|
376
|
+
|
|
377
|
+
if is_partic_CDR(numbering,numbering_scheme,"H2")=="H2":
|
|
378
|
+
if AAtable[str(residues[r1]['typ'])] == "D" or AAtable[str(residues[r1]['typ'])] == "E":
|
|
379
|
+
h2_charge = h2_charge - 1
|
|
380
|
+
num_cdr_charged += 1
|
|
381
|
+
residues[r1]['negative'] = -1
|
|
382
|
+
residues[r1]['charge'] = -1
|
|
383
|
+
elif AAtable[str(residues[r1]['typ'])] == "R" or AAtable[str(residues[r1]['typ'])] == "K":
|
|
384
|
+
h2_charge = h2_charge + 1
|
|
385
|
+
num_cdr_charged += 1
|
|
386
|
+
residues[r1]['positive'] = 1
|
|
387
|
+
residues[r1]['charge'] = 1
|
|
388
|
+
elif AAtable[str(residues[r1]['typ'])] == "H":
|
|
389
|
+
h2_charge = h2_charge + 0.1 #appropriate at pH 7.4 according to Henderson-Hasselbalch. Could generalise method to any given pH by evaluating this equation.
|
|
390
|
+
num_cdr_charged += 1
|
|
391
|
+
residues[r1]['positive'] = 0.1
|
|
392
|
+
residues[r1]['charge'] = 0.1
|
|
393
|
+
|
|
394
|
+
if is_partic_CDR(numbering,numbering_scheme,"H3")=="H3":
|
|
395
|
+
if AAtable[str(residues[r1]['typ'])] == "D" or AAtable[str(residues[r1]['typ'])] == "E":
|
|
396
|
+
h3_charge = h3_charge - 1
|
|
397
|
+
num_cdr_charged += 1
|
|
398
|
+
residues[r1]['negative'] = -1
|
|
399
|
+
residues[r1]['charge'] = -1
|
|
400
|
+
elif AAtable[str(residues[r1]['typ'])] == "R" or AAtable[str(residues[r1]['typ'])] == "K":
|
|
401
|
+
h3_charge = h3_charge + 1
|
|
402
|
+
num_cdr_charged += 1
|
|
403
|
+
residues[r1]['positive'] = 1
|
|
404
|
+
residues[r1]['charge'] = 1
|
|
405
|
+
elif AAtable[str(residues[r1]['typ'])] == "H":
|
|
406
|
+
h3_charge = h3_charge + 0.1 #appropriate at pH 7.4 according to Henderson-Hasselbalch. Could generalise method to any given pH by evaluating this equation.
|
|
407
|
+
num_cdr_charged += 1
|
|
408
|
+
residues[r1]['positive'] = 0.1
|
|
409
|
+
residues[r1]['charge'] = 0.1
|
|
410
|
+
|
|
411
|
+
if AAtable[str(residues[r1]['typ'])] == "D" or AAtable[str(residues[r1]['typ'])] == "E":
|
|
412
|
+
heavy_fv_charge = heavy_fv_charge - 1
|
|
413
|
+
num_heavy_fv_charged += 1
|
|
414
|
+
residues[r1]['negative'] = -1
|
|
415
|
+
residues[r1]['charge'] = -1
|
|
416
|
+
elif AAtable[str(residues[r1]['typ'])] == "R" or AAtable[str(residues[r1]['typ'])] == "K":
|
|
417
|
+
heavy_fv_charge = heavy_fv_charge + 1
|
|
418
|
+
num_heavy_fv_charged += 1
|
|
419
|
+
residues[r1]['positive'] = 1
|
|
420
|
+
residues[r1]['charge'] = 1
|
|
421
|
+
elif AAtable[str(residues[r1]['typ'])] == "H":
|
|
422
|
+
heavy_fv_charge = heavy_fv_charge + 0.1 #appropriate at pH 7.4 according to Henderson-Hasselbalch. Could generalise method to any given pH.
|
|
423
|
+
num_heavy_fv_charged += 1
|
|
424
|
+
residues[r1]['positive'] = 0.1
|
|
425
|
+
residues[r1]['charge'] = 0.1
|
|
426
|
+
number_heavy_fv_residues += 1
|
|
427
|
+
|
|
428
|
+
if verbose:
|
|
429
|
+
print(str(r1),str(residues[r1]['typ']),"Heavy Fv Charge is: ",heavy_fv_charge)
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
number_cdr_residues += 1
|
|
433
|
+
|
|
434
|
+
if r1 not in cdr_vicinity:
|
|
435
|
+
cdr_vicinity.append(r1) #build up cdr vicinity list, populated with resiudes that comprise the CDR +/- 2
|
|
436
|
+
"""
|
|
437
|
+
print "Net L1 Charge is: ",l1_charge
|
|
438
|
+
print "Net L2 Charge is: ",l2_charge
|
|
439
|
+
print "Net L3 Charge is: ",l3_charge
|
|
440
|
+
print "Net H1 Charge is: ",h1_charge
|
|
441
|
+
print "Net H2 Charge is: ",h2_charge
|
|
442
|
+
print "Net H3 Charge is: ",h3_charge
|
|
443
|
+
print "Net Heavy Fv Charge is: ",heavy_fv_charge
|
|
444
|
+
print "Net Light Fv Charge is: ",light_fv_charge
|
|
445
|
+
"""
|
|
446
|
+
for r2 in residues:
|
|
447
|
+
|
|
448
|
+
#Skip if we are the same residue or if the other is a CDR as well!
|
|
449
|
+
if r1 == r2 or r2 in cdr_vicinity:
|
|
450
|
+
continue
|
|
451
|
+
|
|
452
|
+
#If we are here, we know r1 is CDR and r2 is not. So let's measure whether r2 is also in the neighborhood...
|
|
453
|
+
res1 = residues[r1]['res']
|
|
454
|
+
res2 = residues[r2]['res']
|
|
455
|
+
d = res2.distance(res1,res2) #Works out the lowest pairwise distance between all atoms in both residues
|
|
456
|
+
|
|
457
|
+
if d < 4.0: #Arbitrary cutoff distance, here 4.0A, to assign non-CDR residue as being in the "CDR neighbourhood".
|
|
458
|
+
if r2 not in cdr_vicinity:
|
|
459
|
+
cdr_vicinity.append(r2) #Add this one if not already in the list!
|
|
460
|
+
|
|
461
|
+
#print residues
|
|
462
|
+
|
|
463
|
+
if number_light_fv_residues != 0:
|
|
464
|
+
if verbose:
|
|
465
|
+
print("\nWe have ",len(cdr_vicinity)," residues in the CDR vicinity of which ",number_cdr_residues,' are genuine CDR residues.')
|
|
466
|
+
print("A total of ",len(residues),' residues have been recorded.')
|
|
467
|
+
|
|
468
|
+
#On this iteration, with both H and L in our residues dictionary, look for salt bridges and neutralise charge if we find they exist...
|
|
469
|
+
print("\nChecking for possible salt bridges using a distance cutoff of 3.2A between formally, oppositely charged residues.\n")
|
|
470
|
+
for r1 in residues:
|
|
471
|
+
for r2 in residues:
|
|
472
|
+
if r1 == r2:
|
|
473
|
+
continue
|
|
474
|
+
|
|
475
|
+
res1 = residues[r1]['res']
|
|
476
|
+
res2 = residues[r2]['res']
|
|
477
|
+
|
|
478
|
+
donors = ["LYS","ARG"] #not using histidine as only infrequently positively charged at pH 7.4
|
|
479
|
+
acceptors = ["ASP","GLU"]
|
|
480
|
+
|
|
481
|
+
if res1.res_type in donors:
|
|
482
|
+
if res2.res_type in acceptors:
|
|
483
|
+
d = res1.sb_distance(res1,res2)
|
|
484
|
+
#print r1[0],r1[1][0],r1[1][1],r2[0],r2[1][0],r2[1][1]
|
|
485
|
+
if d < 3.2: #Literature recommended cutoff for salt bridge formation
|
|
486
|
+
residues[r1]['positive'] = 0
|
|
487
|
+
residues[r1]['charge'] = 0
|
|
488
|
+
residues[r1]['hydrophobic'] = hydrophobicity_annotation["GLY"]
|
|
489
|
+
residues[r2]['negative'] = 0
|
|
490
|
+
residues[r2]['charge'] = 0 #Neutralise all charges - assume in permanent salt bridge so not physiologically relevant
|
|
491
|
+
residues[r2]['hydrophobic'] = hydrophobicity_annotation["GLY"]
|
|
492
|
+
sb_list.append((str(r1[0])+str(r1[1][0])+str(r1[1][1])+": "+str(res1.res_type),str(r2[0])+str(r2[1][0])+str(r2[1][1])+": "+str(res2.res_type),str("{0:.4f}".format(d))))
|
|
493
|
+
num_saltbridges += 1
|
|
494
|
+
|
|
495
|
+
#We will collect the following data:
|
|
496
|
+
#1. The number of CDR residues.
|
|
497
|
+
#2. The number of residues in CDR vicinity.
|
|
498
|
+
#3. The number of residues on the surface.
|
|
499
|
+
#4. The surface area of the entire molecule [v]
|
|
500
|
+
#5. The hydrophobicity-weighted surface area (HASA) of the entire molecule [v]
|
|
501
|
+
#6. The Adjacency matrix of the entire molecule
|
|
502
|
+
#7. Overall Fv Charge
|
|
503
|
+
#8. Charge for each CDR
|
|
504
|
+
#9. Fraction of Charged Residues in the Fv
|
|
505
|
+
#10. Fraction of Charged Residues across CDRs
|
|
506
|
+
|
|
507
|
+
# Calculate the TOTAL surface area (Total ASA)
|
|
508
|
+
total_area = 0.0
|
|
509
|
+
|
|
510
|
+
#Hydrophobicity-scaled surface area (Total HASA)
|
|
511
|
+
h_asa_total = 0.0
|
|
512
|
+
|
|
513
|
+
#Charge-scaled surface area (Total CASA)
|
|
514
|
+
c_asa_total = 0.0
|
|
515
|
+
|
|
516
|
+
#Charge-scaled surface area (Heavy Fv Only)
|
|
517
|
+
c_asa_heavyfv_total = 0.0
|
|
518
|
+
|
|
519
|
+
#Charge-scaled surface area (Light Fv Only)
|
|
520
|
+
c_asa_lightfv_total = 0.0
|
|
521
|
+
|
|
522
|
+
for r1 in residues:
|
|
523
|
+
total_area+=residues[r1]['asa_sum']
|
|
524
|
+
h_asa_total+=residues[r1]['asa_sum']*residues[r1]['hydrophobic'] #Directly multiply each residue's (all residues) asa by its hydrophobicity score (linear measure!)
|
|
525
|
+
c_asa_total+=residues[r1]['asa_sum']*residues[r1]['charge'] #Directly multiply each residue's (all residues) asa by its charge (linear measure!)
|
|
526
|
+
#print c_asa_total,r1,residues[r1]['typ']
|
|
527
|
+
if r1[0] == "H":
|
|
528
|
+
c_asa_heavyfv_total += residues[r1]['asa_sum']*residues[r1]['charge']
|
|
529
|
+
elif r1[0] == "L":
|
|
530
|
+
c_asa_lightfv_total += residues[r1]['asa_sum']*residues[r1]['charge']
|
|
531
|
+
|
|
532
|
+
#Calculate CDR-only surface area (CDR ASA)
|
|
533
|
+
cdr_area = 0.0
|
|
534
|
+
|
|
535
|
+
#Calcualte the CDR-only (CDR vicinity) hydrophobicity-scaled surface area (CDR HASA)
|
|
536
|
+
h_asa_cdr = 0.0
|
|
537
|
+
|
|
538
|
+
#Charge-scaled surface area(CDR CASA)
|
|
539
|
+
c_asa_cdr = 0.0
|
|
540
|
+
|
|
541
|
+
#Charge-scaled heavy CDR surface area (HCDR CASA)
|
|
542
|
+
c_asa_hcdr = 0.0
|
|
543
|
+
|
|
544
|
+
#Charge-scaled light CDR surface area (LCDR CASA)
|
|
545
|
+
c_asa_lcdr = 0.0
|
|
546
|
+
|
|
547
|
+
#Only look at the residues in the immediate vicinity of the CDRs
|
|
548
|
+
for r1 in cdr_vicinity:
|
|
549
|
+
|
|
550
|
+
cdr_area+=residues[r1]['asa_sum']
|
|
551
|
+
h_asa_cdr+=residues[r1]['asa_sum']*residues[r1]['hydrophobic'] #Directly multiply each residue's (CDR vicinity residues) asa by its hydrophobicity score (linear!)
|
|
552
|
+
c_asa_cdr+=residues[r1]['asa_sum']*residues[r1]['charge'] #Directly multiply each residue's (CDR vicinity residues) asa by its charge (linear!)
|
|
553
|
+
if r1[0] == "H":
|
|
554
|
+
c_asa_hcdr += residues[r1]['asa_sum']*residues[r1]['charge']
|
|
555
|
+
elif r1[0] == "L":
|
|
556
|
+
c_asa_lcdr += residues[r1]['asa_sum']*residues[r1]['charge']
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
#####NEW CALCULATION OF NET CHARGE#####
|
|
561
|
+
new_hfv_charge = 0
|
|
562
|
+
new_lfv_charge = 0
|
|
563
|
+
|
|
564
|
+
for r1 in residues:
|
|
565
|
+
if r1[0] == "H":
|
|
566
|
+
if residues[r1]['charge'] != 0:
|
|
567
|
+
if verbose:
|
|
568
|
+
print(str(r1),residues[r1]['typ'],residues[r1]['charge'])
|
|
569
|
+
new_hfv_charge += residues[r1]['charge']
|
|
570
|
+
elif r1[0] == "L":
|
|
571
|
+
if residues[r1]['charge'] != 0:
|
|
572
|
+
if verbose:
|
|
573
|
+
print(str(r1),residues[r1]['typ'],residues[r1]['charge'])
|
|
574
|
+
new_lfv_charge += residues[r1]['charge']
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
if number_light_fv_residues != 0 and verbose:
|
|
578
|
+
print("\nSUMMARY HYDROPHOBICITY AND CHARGE RESULTS:\n")
|
|
579
|
+
|
|
580
|
+
print("ABSOLUTE SURFACE AREA VALUES")
|
|
581
|
+
print("The Total Absolute Surface Area of your Fv is: ",total_area)
|
|
582
|
+
print("The CDR Vicinity Absolute Surface Area of your Fv is: ",cdr_area)
|
|
583
|
+
|
|
584
|
+
print("\nLINEARLY-WEIGHTED HYDROPHOBICITY AND CHARGE")
|
|
585
|
+
print("The Total LINEARLY Surface-weighted Hydrophobicity of your Fv is: ",h_asa_total)
|
|
586
|
+
print("The CDR LINEARLY Surface-weighted Hydrophobicity of your Fv is: ",h_asa_cdr)
|
|
587
|
+
print("The Total LINEARLY Surface-weighted Charge of your Fv is: ",c_asa_total)
|
|
588
|
+
print("The CDR LINEARLY Surface-weighted Charge of your Fv is: ",c_asa_cdr)
|
|
589
|
+
"""
|
|
590
|
+
print "\nSEQUENCE-DETERMINED CHARGE PROPERTIES"
|
|
591
|
+
print "Net L1 Charge of your Fv is: ",l1_charge
|
|
592
|
+
print "Net L2 Charge of your Fv is: ",l2_charge
|
|
593
|
+
print "Net L3 Charge of your Fv is: ",l3_charge
|
|
594
|
+
print "Net H1 Charge of your Fv is: ",h1_charge
|
|
595
|
+
print "Net H2 Charge of your Fv is: ",h2_charge
|
|
596
|
+
print "Net H3 Charge of your Fv is: ",h3_charge
|
|
597
|
+
print "Net Heavy CDR Charge of your Fv is: ",str(float(sum([h1_charge,h2_charge,h3_charge])))
|
|
598
|
+
print "Net Light CDR Charge of your Fv is: ",str(float(sum([l1_charge,l2_charge,l3_charge])))
|
|
599
|
+
print "Net CDR Charge of your Fv is: ",str(float(sum([l1_charge,l2_charge,l3_charge,h1_charge,h2_charge,h3_charge])))
|
|
600
|
+
"""
|
|
601
|
+
print("Net Heavy Fv Charge of your Fv is: ",new_hfv_charge)
|
|
602
|
+
print("Net Light Fv Charge of your Fv is: ",new_lfv_charge)
|
|
603
|
+
print("Number of Charged CDR Residues in your Fv is: "+str(num_cdr_charged)+"/"+str(number_cdr_residues))
|
|
604
|
+
print("Number of Charged Heavy Fv Residues in your Fv is: "+str(num_heavy_fv_charged)+"/"+str(number_heavy_fv_residues))
|
|
605
|
+
print("Number of Charged Light Fv Residues in your Fv is: "+str(num_light_fv_charged)+"/"+str(number_light_fv_residues))
|
|
606
|
+
print("Fraction of Charged CDR Residues in your Fv is: ",str(float(num_cdr_charged)/float(number_cdr_residues)))
|
|
607
|
+
print("Fraction of Charged Heavy Fv Residues in your Fv is: ",str(float(num_heavy_fv_charged)/float(number_heavy_fv_residues)))
|
|
608
|
+
print("Fraction of Charged Light Fv Residues in your Fv is: ",str(float(num_light_fv_charged)/float(number_light_fv_residues)))
|
|
609
|
+
print("Number of Salt Bridges in your Fv is: ", str(num_saltbridges))
|
|
610
|
+
print("Salt bridge components: " + str(sb_list))
|
|
611
|
+
|
|
612
|
+
###################################################################################################
|
|
613
|
+
|
|
614
|
+
#ADJACENCY MATRIX FOR THE ENTIRE MOLECULE
|
|
615
|
+
|
|
616
|
+
adj_matrix = dict()
|
|
617
|
+
for i in residue_classes: #Hydrophobic, Positively Charged, or Negatively Charged
|
|
618
|
+
adj_matrix[i] = dict()
|
|
619
|
+
for j in residue_classes:
|
|
620
|
+
adj_matrix[i][j] = 0
|
|
621
|
+
|
|
622
|
+
for r1 in residues:
|
|
623
|
+
for r2 in residues:
|
|
624
|
+
if r1 != r2: #pairwise comparisons of residues (r1 must be different to r2)
|
|
625
|
+
|
|
626
|
+
res1 = residues[r1]['res']
|
|
627
|
+
res2 = residues[r2]['res']
|
|
628
|
+
d = res2.distance(res1,res2) #calculate the distance between each residue (COMs?)
|
|
629
|
+
|
|
630
|
+
#Adjacency matrix looks only at values within 7.5 A of each other.
|
|
631
|
+
|
|
632
|
+
if d > 7.5:
|
|
633
|
+
continue #ignore pairwise combination if over 7.5A apart
|
|
634
|
+
|
|
635
|
+
for c1 in residue_classes:
|
|
636
|
+
for c2 in residue_classes:
|
|
637
|
+
if c1==c2: #Only interested in patches of the same type of interaction (eg. hydrophob, +ve charge or -ve charge)
|
|
638
|
+
if c1 in residues[r1] and c2 in residues[r2]:
|
|
639
|
+
#The Coulombic measure.
|
|
640
|
+
coulombic_score = (residues[r1][c1]*residues[r2][c2])/(d*d)
|
|
641
|
+
adj_matrix[c1][c2] += coulombic_score #THIS IS THE TOTAL PATCH HYDROPHOBICITY SCORE!
|
|
642
|
+
#ADJACENCY MATRIX FOR JUST THE CDRs
|
|
643
|
+
|
|
644
|
+
adj_matrix_cdr = dict()
|
|
645
|
+
for i in residue_classes:
|
|
646
|
+
adj_matrix_cdr[i] = dict()
|
|
647
|
+
for j in residue_classes:
|
|
648
|
+
adj_matrix_cdr[i][j] = 0
|
|
649
|
+
|
|
650
|
+
for r1 in cdr_vicinity:
|
|
651
|
+
for r2 in cdr_vicinity:
|
|
652
|
+
if r1 != r2: #As above, but just for residues in the CDR vicinity
|
|
653
|
+
|
|
654
|
+
res1 = residues[r1]['res']
|
|
655
|
+
res2 = residues[r2]['res']
|
|
656
|
+
d = res2.distance(res1,res2)
|
|
657
|
+
|
|
658
|
+
#Adjacency matrix looks only at values within 7.5 A from each other.
|
|
659
|
+
|
|
660
|
+
if d > 7.5:
|
|
661
|
+
continue #ignore pairwise combination if >7.5A apart
|
|
662
|
+
|
|
663
|
+
for c1 in residue_classes:
|
|
664
|
+
for c2 in residue_classes:
|
|
665
|
+
if c1 == c2: #Only interested in patches of the same type of interaction (eg. hydrophob, +ve charge or -ve charge)
|
|
666
|
+
if c1 in residues[r1] and c2 in residues[r2]:
|
|
667
|
+
#The Coulombic measure.
|
|
668
|
+
coulombic_score = (residues[r1][c1]*residues[r2][c2])/(d*d)
|
|
669
|
+
adj_matrix_cdr[c1][c2] +=coulombic_score #THIS IS THE CDR PATCH HYDROPHOBICITY SCORE!
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
if number_light_fv_residues != 0 and verbose:
|
|
673
|
+
print("\nPATCH-WEIGHTED HYDROPHOBICITY")
|
|
674
|
+
print("The Total PATCH Surface-weighted Hydrophobicity of your Fv is: ",adj_matrix['hydrophobic']['hydrophobic'])
|
|
675
|
+
print("The CDR PATCH Surface-weighted Hydrophobicity of your Fv is: ",adj_matrix_cdr['hydrophobic']['hydrophobic'])
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
##########################################################################################################
|
|
680
|
+
|
|
681
|
+
#Full statistics used for calculations.
|
|
682
|
+
if number_light_fv_residues != 0:
|
|
683
|
+
if verbose:
|
|
684
|
+
print(cdr_vicinity)
|
|
685
|
+
stats = dict()
|
|
686
|
+
stats[annotation_index] = dict()
|
|
687
|
+
stats[annotation_index]['Patch_Hydrophob_CDR'] = float("{0:.4f}".format(adj_matrix_cdr['hydrophobic']['hydrophobic'])) #CDR Vicinity Patch HASA
|
|
688
|
+
stats[annotation_index]['Patch_Hydrophob_Total'] = float("{0:.4f}".format(adj_matrix['hydrophobic']['hydrophobic'])) #Total Patch HASA
|
|
689
|
+
stats[annotation_index]['Patch_Pos_Charge_CDR'] = float("{0:.4f}".format(adj_matrix_cdr['positive']['positive'])) #CDR Vicinity Patch +CASA
|
|
690
|
+
stats[annotation_index]['Patch_Pos_Charge_Total'] = float("{0:.4f}".format(adj_matrix['positive']['positive'])) #Total Patch +CASA
|
|
691
|
+
stats[annotation_index]['Patch_Neg_Charge_CDR'] = float("{0:.4f}".format(adj_matrix_cdr['negative']['negative'])) #CDR Vicinity Patch -CASA
|
|
692
|
+
stats[annotation_index]['Patch_Neg_Charge_Total'] = float("{0:.4f}".format(adj_matrix['negative']['negative'])) #Total Patch -CASA
|
|
693
|
+
|
|
694
|
+
stats[annotation_index]['Total_Accessible_Surface_Area'] = float("{0:.4f}".format(total_area)) #Total ASA
|
|
695
|
+
stats[annotation_index]['CDR_Vicinity_Accessible_Surface_Area'] = float("{0:.4f}".format(cdr_area)) #CDR Vicinity ASA
|
|
696
|
+
stats[annotation_index]['Linear_Hydrophob_Total'] = float("{0:.4f}".format(h_asa_total)) #Total Linear HASA
|
|
697
|
+
stats[annotation_index]['Linear_Hydrophob_CDR'] = float("{0:.4f}".format(h_asa_cdr)) #CDR Linear HASA
|
|
698
|
+
stats[annotation_index]['Linear_Charge_Total'] = float("{0:.4f}".format(c_asa_total)) #Total Linear CASA
|
|
699
|
+
stats[annotation_index]['Linear_Charge_CDR'] = float("{0:.4f}".format(c_asa_cdr)) #CDR Linear CASA
|
|
700
|
+
stats[annotation_index]['Linear_Charge_HCDR'] = float("{0:.4f}".format(c_asa_hcdr)) #HCDR Linear CASA
|
|
701
|
+
stats[annotation_index]['Linear_Charge_LCDR'] = float("{0:.4f}".format(c_asa_lcdr)) #LCDR Linear CASA
|
|
702
|
+
|
|
703
|
+
stats[annotation_index]['Linear_Heavy_Fv_Charge'] = float("{0:.4f}".format(c_asa_heavyfv_total))
|
|
704
|
+
stats[annotation_index]['Linear_Light_Fv_Charge'] = float("{0:.4f}".format(c_asa_lightfv_total))
|
|
705
|
+
|
|
706
|
+
stats[annotation_index]['Number_Residues_Solvent_Exposed'] = len(residues) #Number of solvent assessible residues
|
|
707
|
+
stats[annotation_index]['Number_CDR_Residues'] = number_cdr_residues #Number of CDR residues
|
|
708
|
+
stats[annotation_index]['Number_CDR_Vicinity_Residues'] = len(cdr_vicinity) #Total number of residues in the CDR vicinity
|
|
709
|
+
|
|
710
|
+
stats[annotation_index]['Number_Heavy_Fv_Residues'] = number_heavy_fv_residues
|
|
711
|
+
stats[annotation_index]['Number_Light_Fv_Residues'] = number_light_fv_residues
|
|
712
|
+
stats[annotation_index]['Number of Predicted Salt Bridges'] = num_saltbridges
|
|
713
|
+
stats[annotation_index]['Salt Bridge Participants'] = sb_list
|
|
714
|
+
|
|
715
|
+
stats[annotation_index]['Proportion Charged CDR Residues'] = float("{0:.4f}".format(float(num_cdr_charged)/float(number_cdr_residues)))
|
|
716
|
+
stats[annotation_index]['Proportion Charged Heavy Fv Residues'] = float("{0:.4f}".format(float(num_heavy_fv_charged)/float(number_heavy_fv_residues)))
|
|
717
|
+
stats[annotation_index]['Proportion Charged Light Fv Residues'] = float("{0:.4f}".format(float(num_light_fv_charged)/float(number_light_fv_residues)))
|
|
718
|
+
"""
|
|
719
|
+
stats[annotation_index]['Net H1 Charge'] = h1_charge
|
|
720
|
+
stats[annotation_index]['Net H2 Charge'] = h2_charge
|
|
721
|
+
stats[annotation_index]['Net H3 Charge'] = h3_charge
|
|
722
|
+
stats[annotation_index]['Net L1 Charge'] = l1_charge
|
|
723
|
+
stats[annotation_index]['Net L2 Charge'] = l2_charge
|
|
724
|
+
stats[annotation_index]['Net L3 Charge'] = l3_charge
|
|
725
|
+
stats[annotation_index]['Net Heavy CDR Charge'] = float("{0:.1f}".format(sum([h1_charge,h2_charge,h3_charge])))
|
|
726
|
+
stats[annotation_index]['Net Light CDR Charge'] = float("{0:.1f}".format(sum([l1_charge,l2_charge,l3_charge])))
|
|
727
|
+
stats[annotation_index]['Net Overall CDR Charge'] = float("{0:.1f}".format(sum([h1_charge,h2_charge,h3_charge,l1_charge,l2_charge,l3_charge])))
|
|
728
|
+
"""
|
|
729
|
+
stats[annotation_index]['Net Heavy Fv Charge'] = float("{0:.1f}".format(new_hfv_charge))
|
|
730
|
+
stats[annotation_index]['Net Light Fv Charge'] = float("{0:.1f}".format(new_lfv_charge))
|
|
731
|
+
stats[annotation_index]['SFvCSP'] = float("{0:.2f}".format(new_hfv_charge*new_lfv_charge))
|
|
732
|
+
|
|
733
|
+
pickle.dump(stats,open(output_file,'wb')) #Write the stats dictionary to a pickle file, non-binary format
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
#WRITE THE ANNOTATED PDB FILE!
|
|
737
|
+
|
|
738
|
+
string_compat_cdrvic = []
|
|
739
|
+
for q in cdr_vicinity:
|
|
740
|
+
new_tup = (q[0],(str(q[1][0]),q[1][1]))
|
|
741
|
+
string_compat_cdrvic.append(new_tup)
|
|
742
|
+
|
|
743
|
+
gen_imgt_cdrs = ['27','28','29','30','31','32','33','34','35','36','37','38','56','57','58','59','60','61','62','63','64','65','105','106','107','108','109','110','111','112','113','114','115','116','117']
|
|
744
|
+
|
|
745
|
+
if verbose:
|
|
746
|
+
print(string_compat_cdrvic)
|
|
747
|
+
|
|
748
|
+
with open(input_file,"r") as f:
|
|
749
|
+
with open(input_file[:-4] + "_Annotated.pdb","w") as fo:
|
|
750
|
+
for line in f.readlines():
|
|
751
|
+
if line[0:4] == "ATOM":
|
|
752
|
+
line = line.strip()
|
|
753
|
+
residue_id = str(line[23:27].replace(" ",""))
|
|
754
|
+
res,ins = stripInsertionCode(residue_id)
|
|
755
|
+
#print res,ins
|
|
756
|
+
res_tuple = (line[21],(res,ins))
|
|
757
|
+
#print res_tuple
|
|
758
|
+
#print string_compat_cdrvic
|
|
759
|
+
|
|
760
|
+
if res in gen_imgt_cdrs:
|
|
761
|
+
fo.write("HETATM"+line[6:55])
|
|
762
|
+
else:
|
|
763
|
+
fo.write(line[0:55])
|
|
764
|
+
|
|
765
|
+
#if res_tuple in string_compat_cdrvic:
|
|
766
|
+
# fo.write("HETATM"+line[6:55])
|
|
767
|
+
#else:
|
|
768
|
+
# fo.write(line[0:55])
|
|
769
|
+
|
|
770
|
+
if res_tuple in string_compat_cdrvic:
|
|
771
|
+
if verbose:
|
|
772
|
+
print(res, ins, res_tuple, "yes")
|
|
773
|
+
if line[17:20] == "LYS" or line[17:20] == "ARG":
|
|
774
|
+
fo.write(" 1.00 ")
|
|
775
|
+
elif line[17:20] == "HIS":
|
|
776
|
+
fo.write(" 0.10 ")
|
|
777
|
+
elif line[17:20] == "GLU" or line[17:20] == "ASP":
|
|
778
|
+
fo.write("-1.00 ")
|
|
779
|
+
else:
|
|
780
|
+
fo.write(" 0 ")
|
|
781
|
+
fo.write("{0:.3f}".format(hydrophobicity_annotation[line[17:20]])+"\n")
|
|
782
|
+
else:
|
|
783
|
+
if verbose:
|
|
784
|
+
print(res, ins, res_tuple, "no")
|
|
785
|
+
print("is not in the CDR vic")
|
|
786
|
+
fo.write(" 0 0\n")
|
|
787
|
+
|
|
788
|
+
#print stats
|
|
789
|
+
return stats
|
|
790
|
+
|
|
791
|
+
##############################################################################
|
|
792
|
+
#CODE STARTS HERE#
|
|
793
|
+
|
|
794
|
+
if __name__ == '__main__':
|
|
795
|
+
|
|
796
|
+
#HYDROPHOBICITY SCORING SYSTEMS
|
|
797
|
+
#0: Gravy - Kyte & Doolttle (1982)
|
|
798
|
+
#1: Wimley & White (1996)
|
|
799
|
+
#2: Hessa et al. (2005)
|
|
800
|
+
#3: Eisenberg & McLachlan (1986)
|
|
801
|
+
#4: Black & Mould (1990)
|
|
802
|
+
|
|
803
|
+
#USAGE:
|
|
804
|
+
#python Annotator.py [hydrophobic scoring system] [input_file] [ab chains] [region_definition] [output_file]
|
|
805
|
+
#python Annotator.py 0 examples/cristian.pdb IG results.txt
|
|
806
|
+
|
|
807
|
+
pH = 7.4 #physiological, here predetermined but could be made an argument
|
|
808
|
+
annotation = sys.argv[1] #scoring system
|
|
809
|
+
input_file = sys.argv[2] #input file name
|
|
810
|
+
chains = sys.argv[3] #Usually IG
|
|
811
|
+
region_definition = sys.argv[4] #Chothia or IMGT
|
|
812
|
+
output_file = sys.argv[5] #output file name
|
|
813
|
+
|
|
814
|
+
CreateAnnotation(int(annotation),float(pH),input_file,output_file,chains,region_definition) #Start Main Code
|