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,311 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
|
|
4
|
+
try:
|
|
5
|
+
import anarci
|
|
6
|
+
except ModuleNotFoundError as error:
|
|
7
|
+
# Only if ANARCI itself is missing, not one of its own imports.
|
|
8
|
+
if error.name != "anarci":
|
|
9
|
+
raise
|
|
10
|
+
raise ModuleNotFoundError(
|
|
11
|
+
"TAP needs ANARCI, which is distributed through Bioconda, not PyPI. "
|
|
12
|
+
"Install it with `conda install -c conda-forge -c bioconda anarci`. "
|
|
13
|
+
"Don't install the `anarci` package from PyPI, which is not an official "
|
|
14
|
+
"release.",
|
|
15
|
+
name=error.name,
|
|
16
|
+
) from error
|
|
17
|
+
|
|
18
|
+
import numpy as np
|
|
19
|
+
from Bio.PDB import PDBParser
|
|
20
|
+
from Bio.SeqUtils import seq1
|
|
21
|
+
from antibody_utils.numbering import Position
|
|
22
|
+
from antibody_utils.regions import annotate_regions
|
|
23
|
+
from ImmuneBuilder.sequence_checks import number_sequences
|
|
24
|
+
from .sequence_liabilities import get_liabilities
|
|
25
|
+
|
|
26
|
+
def get_sequences_from_pdb(input_pdb):
|
|
27
|
+
# Run parser
|
|
28
|
+
parser = PDBParser(QUIET=True)
|
|
29
|
+
structure = parser.get_structure('struct', input_pdb)
|
|
30
|
+
|
|
31
|
+
# iterate each model, chain, and residue
|
|
32
|
+
# printing out the sequence for each chain
|
|
33
|
+
|
|
34
|
+
model_sequences = []
|
|
35
|
+
for model in structure:
|
|
36
|
+
for chain in model:
|
|
37
|
+
sequence = [seq1(residue.resname) for residue in chain]
|
|
38
|
+
model_sequences.append((chain.id, ''.join(sequence)))
|
|
39
|
+
|
|
40
|
+
return model_sequences
|
|
41
|
+
|
|
42
|
+
def get_liabilities_from_pdb(input_pdb, scheme="imgt", save=False):
|
|
43
|
+
"""
|
|
44
|
+
Get the sequence liabilities of the heavy and light chains of an input PDB
|
|
45
|
+
"""
|
|
46
|
+
if scheme != "imgt":
|
|
47
|
+
raise ValueError("Sequence liabilities are only found in IMGT numbering")
|
|
48
|
+
|
|
49
|
+
output_dir = os.path.dirname(input_pdb)
|
|
50
|
+
model_sequences = get_sequences_from_pdb(input_pdb)
|
|
51
|
+
|
|
52
|
+
# Extract liabilities for extracted sequences
|
|
53
|
+
heavy_sequence, light_sequence = model_sequences[0][1], model_sequences[1][1]
|
|
54
|
+
liabilities, n_liabilities = get_liabilities(heavy_sequence,
|
|
55
|
+
light_sequence,
|
|
56
|
+
save=save,
|
|
57
|
+
outfile= os.path.join(output_dir,"sequence_liabilities.csv"))
|
|
58
|
+
|
|
59
|
+
return {scheme: liabilities}, n_liabilities
|
|
60
|
+
|
|
61
|
+
def get_bfactors_from_pdb(input_pdb):
|
|
62
|
+
"""
|
|
63
|
+
Extract B-factor values per residue for given input PDB
|
|
64
|
+
"""
|
|
65
|
+
# Run parser
|
|
66
|
+
parser = PDBParser(QUIET=True)
|
|
67
|
+
structure = parser.get_structure('struct', input_pdb)
|
|
68
|
+
|
|
69
|
+
# Iterate each model, chain, and residue
|
|
70
|
+
# Extract chain sequences
|
|
71
|
+
bfactors = {}
|
|
72
|
+
for model in structure:
|
|
73
|
+
for chain in model:
|
|
74
|
+
bfactors[chain.id] = []
|
|
75
|
+
for residue in chain:
|
|
76
|
+
resnum, resname, bfactor = (residue.get_id(), seq1(residue.get_resname()), list(residue)[0].get_bfactor())
|
|
77
|
+
bfactors[chain.id].append((resnum, resname, bfactor))
|
|
78
|
+
|
|
79
|
+
return bfactors
|
|
80
|
+
|
|
81
|
+
def get_range( residues, chain, scheme, definition):
|
|
82
|
+
"""
|
|
83
|
+
Get the indices which correspond to CDRs for a particular definition.
|
|
84
|
+
"""
|
|
85
|
+
regions = annotate_regions([(Position(*position), aa) for position, aa in residues], chain, scheme=scheme, definition=definition)
|
|
86
|
+
ranges = []
|
|
87
|
+
framework, cdr = True, False
|
|
88
|
+
for i in range( len(residues) ):
|
|
89
|
+
reg = regions[i][2] or "" # None beyond the variable domain
|
|
90
|
+
if "cdr" in reg and framework:
|
|
91
|
+
ranges.append(i)
|
|
92
|
+
framework, cdr = False, True
|
|
93
|
+
elif "fw" in reg and cdr:
|
|
94
|
+
ranges.append(i-1)
|
|
95
|
+
framework, cdr = True, False
|
|
96
|
+
|
|
97
|
+
return ranges
|
|
98
|
+
|
|
99
|
+
def get_cdr_ranges_from_pdb(input_pdb, type = "", scheme = "imgt", definition="imgt"):
|
|
100
|
+
"""
|
|
101
|
+
Get CDR index ranges corresponding to a particular defintion given an input PDB
|
|
102
|
+
"""
|
|
103
|
+
sequences = dict(get_sequences_from_pdb(input_pdb))
|
|
104
|
+
|
|
105
|
+
cdr_ranges = {}
|
|
106
|
+
if type == "antibody":
|
|
107
|
+
available_definitions = ["kabat", "chothia", "imgt", "north", "contact"]
|
|
108
|
+
definitions_list = available_definitions if definition == "all" else [definition]
|
|
109
|
+
|
|
110
|
+
numberings = number_sequences(sequences, scheme=scheme)
|
|
111
|
+
heavy_numbering = numberings['H']
|
|
112
|
+
light_numbering = numberings['L']
|
|
113
|
+
for definition in definitions_list:
|
|
114
|
+
cdr_ranges[f"{definition}_CDRH_ranges"] = get_range(heavy_numbering, chain="H", scheme=scheme, definition=definition)
|
|
115
|
+
cdr_ranges[f"{definition}_CDRL_ranges"] = get_range(light_numbering, chain="L", scheme=scheme, definition=definition)
|
|
116
|
+
|
|
117
|
+
elif type == "nanobody":
|
|
118
|
+
available_definitions = ["kabat", "chothia", "imgt", "north", "contact"]
|
|
119
|
+
definitions_list = available_definitions if definition == "all" else [definition]
|
|
120
|
+
|
|
121
|
+
numberings = number_sequences(sequences, scheme=scheme)
|
|
122
|
+
heavy_numbering = numberings['H']
|
|
123
|
+
for definition in definitions_list:
|
|
124
|
+
cdr_ranges[f"{definition}_CDRH_ranges"] = get_range(heavy_numbering, chain="H", scheme=scheme, definition=definition)
|
|
125
|
+
|
|
126
|
+
elif type == "tcr":
|
|
127
|
+
numberings = number_sequences(sequences, scheme=scheme)
|
|
128
|
+
beta_numbering = numberings['B']
|
|
129
|
+
alpha_numbering = numberings['A']
|
|
130
|
+
cdr_ranges[f"{definition}_CDRB_ranges"] = get_range(beta_numbering, chain="H", scheme=scheme, definition="imgt")
|
|
131
|
+
cdr_ranges[f"{definition}_CDRA_ranges"] = get_range(alpha_numbering, chain="H", scheme=scheme, definition="imgt")
|
|
132
|
+
|
|
133
|
+
else:
|
|
134
|
+
print("ERROR: Not a valid model 'type'. Options are: 'antibody', 'nanobody', 'tcr'")
|
|
135
|
+
|
|
136
|
+
return cdr_ranges
|
|
137
|
+
|
|
138
|
+
def run_dssp(structurefile, type=''):
|
|
139
|
+
"""
|
|
140
|
+
Run dssp on the structurefile. This will calculate the solvent exposure and the phi/psi angles etc.
|
|
141
|
+
Requires DSSP to be in the path.
|
|
142
|
+
@param structurefile: The file to calculate the surface area with on
|
|
143
|
+
@return: A dictionary containing H and L as keys and a list of residue identifiers and dictionaries containing the properties of each residue.
|
|
144
|
+
"""
|
|
145
|
+
|
|
146
|
+
import warnings
|
|
147
|
+
|
|
148
|
+
from Bio.PDB.DSSP import DSSP
|
|
149
|
+
from Bio.PDB.PDBParser import PDBParser
|
|
150
|
+
|
|
151
|
+
def dssp(model, structurefile):
|
|
152
|
+
# DSSP 4 tries to read its input as mmCIF before falling back to PDB,
|
|
153
|
+
# and reports the failed attempt on stderr, which Biopython raises as a
|
|
154
|
+
# warning.
|
|
155
|
+
with warnings.catch_warnings():
|
|
156
|
+
warnings.filterwarnings(
|
|
157
|
+
"ignore", message=".*does not seem to be an mmCIF file"
|
|
158
|
+
)
|
|
159
|
+
return DSSP(model, structurefile)
|
|
160
|
+
|
|
161
|
+
if type == 'tcr':
|
|
162
|
+
dssp_properties = {"B":[], "A":[]}
|
|
163
|
+
# Parse the model to get a structure object
|
|
164
|
+
s = PDBParser(QUIET=True).get_structure("model", structurefile)
|
|
165
|
+
|
|
166
|
+
# Run DSSP on the model to annotate residues
|
|
167
|
+
try:
|
|
168
|
+
_ = dssp( s[0], structurefile)
|
|
169
|
+
except OSError:
|
|
170
|
+
# dssp is not installed so cannot be run.
|
|
171
|
+
return {"dssp_properties": dssp_properties, "annotation_file": None, "dssp_message": "DSSP is not in the path"}
|
|
172
|
+
|
|
173
|
+
else:
|
|
174
|
+
dssp_properties = {"H":[], "L":[]}
|
|
175
|
+
|
|
176
|
+
# Parse the model to get a structure object
|
|
177
|
+
s = PDBParser(QUIET=True).get_structure("model", structurefile)
|
|
178
|
+
|
|
179
|
+
# Run DSSP on the model to annotate residues
|
|
180
|
+
try:
|
|
181
|
+
_ = dssp( s[0], structurefile)
|
|
182
|
+
except OSError:
|
|
183
|
+
# dssp is not installed so cannot be run.
|
|
184
|
+
return {"dssp_properties": dssp_properties, "annotation_file": None, "dssp_message": "DSSP is not in the path"}
|
|
185
|
+
|
|
186
|
+
# These are not required as Biopython kindly implements it for us :)
|
|
187
|
+
# Standard solvent accessibilities for residues taken from the reference:
|
|
188
|
+
# C. Chothia, The Nature of the Accessible and Buried Surfaces in Proteins, J. Mol. Biol., 105(1975)1-14.
|
|
189
|
+
# standards={'CYS': 135, 'ASP': 150, 'SER': 115, 'ASN': 160, 'GLN': 180, 'LYS': 200,
|
|
190
|
+
# 'THR': 140, 'PRO': 145, 'HIS': 195, 'PHE': 210, 'ALA': 115, 'GLY': 75, 'ILE': 175,
|
|
191
|
+
# 'LEU': 170, 'ARG': 225, 'TRP': 255, 'VAL': 155, 'GLU': 190, 'TYR': 230, 'MET': 185}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
# Populate a dictionary of properties from dssp. These are stored in the xtra dictionary in the residue object.
|
|
195
|
+
# They loop like:
|
|
196
|
+
# {'PSI_DSSP': 142.5, 'EXP_DSSP_ASA': 88, 'EXP_DSSP_RASA': 0.44, 'SS_DSSP': 'E', 'PHI_DSSP': -148.40}
|
|
197
|
+
|
|
198
|
+
outputfile = os.path.splitext( structurefile )[0]+"_annotations.csv"
|
|
199
|
+
message=""
|
|
200
|
+
with open(outputfile , 'w' ) as fout:
|
|
201
|
+
print(",".join(["Chain","Index","Insertion","Amino Acid","Absolute Surface Area",
|
|
202
|
+
"Relative Surface Area","Secondary Structure","Phi angle","Psi angle"]), file=fout)
|
|
203
|
+
for chain in s[0]:
|
|
204
|
+
for r in chain:
|
|
205
|
+
if r.id[0] !="W":
|
|
206
|
+
dssp_properties[chain.id].append( [ r.id[1:], r.resname, r.xtra ] )
|
|
207
|
+
try:
|
|
208
|
+
print(",".join( [ chain.id, str(r.id[1]), r.id[2], seq1(r.get_resname()), "%.2f"%r.xtra['EXP_DSSP_ASA'], "%.2f"%r.xtra['EXP_DSSP_RASA'],
|
|
209
|
+
r.xtra['SS_DSSP'],"%.2f"%r.xtra['PHI_DSSP'],"%.2f"%r.xtra['PSI_DSSP'] ]), file=fout)
|
|
210
|
+
except KeyError:
|
|
211
|
+
print(",".join([chain.id, str(r.id[1]),r.id[2],"-","-","-","-","-","-"]), file=fout)
|
|
212
|
+
message = "DSSP annotations could not be calculated for at least one residue"
|
|
213
|
+
|
|
214
|
+
return {"dssp_properties": dssp_properties, "annotation_file": outputfile, "dssp_message": message}
|
|
215
|
+
|
|
216
|
+
def get_bfactors_from_pdb_per_region(input_pdb, type= '', scheme='imgt', definition='imgt'):
|
|
217
|
+
|
|
218
|
+
pdb_cdr_ranges = get_cdr_ranges_from_pdb(input_pdb, type=type, scheme=scheme, definition=definition)
|
|
219
|
+
pdb_bfactors = get_bfactors_from_pdb(input_pdb)
|
|
220
|
+
|
|
221
|
+
chain_regions_names = {}
|
|
222
|
+
chain_regions_indices = {}
|
|
223
|
+
for chain in pdb_bfactors:
|
|
224
|
+
first_indx, last_indx = pdb_bfactors[chain][0][0][1], pdb_bfactors[chain][-1][0][1]
|
|
225
|
+
chain_regions_names[chain] = [f'fw{chain.lower()}1',
|
|
226
|
+
f'cdr{chain.lower()}1',
|
|
227
|
+
f'fw{chain.lower()}2',
|
|
228
|
+
f'cdr{chain.lower()}2',
|
|
229
|
+
f'fw{chain.lower()}3',
|
|
230
|
+
f'cdr{chain.lower()}3',
|
|
231
|
+
f'fw{chain.lower()}4']
|
|
232
|
+
x = pdb_cdr_ranges[f'imgt_CDR{chain}_ranges']
|
|
233
|
+
chain_regions_indices[chain] = list(zip([first_indx]+x, x+[last_indx]))
|
|
234
|
+
|
|
235
|
+
bfactors_per_region = {}
|
|
236
|
+
for chain in chain_regions_indices:
|
|
237
|
+
for i in range(len(chain_regions_indices[chain])):
|
|
238
|
+
bfactor_values = [x[-1] for x in pdb_bfactors[chain] if x[0][1] in range(*chain_regions_indices[chain][i])]
|
|
239
|
+
prediction_score_mean = np.mean(bfactor_values)
|
|
240
|
+
prediction_score_std = np.std(bfactor_values)
|
|
241
|
+
bfactors_per_region[chain_regions_names[chain][i]] = [list(chain_regions_indices[chain][i]), prediction_score_mean, prediction_score_std]
|
|
242
|
+
|
|
243
|
+
return bfactors_per_region
|
|
244
|
+
|
|
245
|
+
def get_modelling_details(input_pdb, type="", scheme="imgt", save=False):
|
|
246
|
+
"""
|
|
247
|
+
Compile a modelling_details dict from an input PDB. This can be saved into JSON file
|
|
248
|
+
"""
|
|
249
|
+
pdb_sequences = dict(get_sequences_from_pdb(input_pdb))
|
|
250
|
+
pdb_numberings = number_sequences(pdb_sequences, scheme=scheme)
|
|
251
|
+
pdb_bfactors = get_bfactors_from_pdb(input_pdb)
|
|
252
|
+
|
|
253
|
+
modelling_details = {'scheme': scheme,
|
|
254
|
+
'sequences': pdb_sequences,
|
|
255
|
+
'prediction_scores': pdb_bfactors}
|
|
256
|
+
|
|
257
|
+
if type == "antibody":
|
|
258
|
+
pdb_liabilities, n_liabilities = get_liabilities_from_pdb(input_pdb, scheme=scheme, save=True)
|
|
259
|
+
heavy_numbering = [''.join(map(str,x[0])) for x in pdb_numberings['H']]
|
|
260
|
+
light_numbering = [''.join(map(str,x[0])) for x in pdb_numberings['L']]
|
|
261
|
+
pdb_cdr_ranges = get_cdr_ranges_from_pdb(input_pdb, type=type, scheme=scheme, definition='all')
|
|
262
|
+
pdb_bfactors_per_region = get_bfactors_from_pdb_per_region(input_pdb, type='antibody')
|
|
263
|
+
pdb_dssp_output = run_dssp(input_pdb)
|
|
264
|
+
|
|
265
|
+
modelling_details.update({'heavy_numbering': heavy_numbering,
|
|
266
|
+
'light_numbering': light_numbering,
|
|
267
|
+
'sequence_liabilities': pdb_liabilities[scheme],
|
|
268
|
+
'n_possible_seq_liabilities': n_liabilities})
|
|
269
|
+
|
|
270
|
+
elif type == "nanobody":
|
|
271
|
+
heavy_numbering = [''.join(map(str,x[0])) for x in pdb_numberings['H']]
|
|
272
|
+
pdb_cdr_ranges = get_cdr_ranges_from_pdb(input_pdb, type=type, scheme=scheme, definition='all')
|
|
273
|
+
pdb_bfactors_per_region = get_bfactors_from_pdb_per_region(input_pdb, type='nanobody')
|
|
274
|
+
pdb_dssp_output = run_dssp(input_pdb)
|
|
275
|
+
|
|
276
|
+
modelling_details.update({'heavy_numbering': heavy_numbering})
|
|
277
|
+
|
|
278
|
+
elif type == "tcr":
|
|
279
|
+
beta_numbering = [''.join(map(str,x[0])) for x in pdb_numberings['B']]
|
|
280
|
+
alpha_numbering = [''.join(map(str,x[0])) for x in pdb_numberings['A']]
|
|
281
|
+
pdb_cdr_ranges = get_cdr_ranges_from_pdb(input_pdb, type=type, scheme=scheme, definition='imgt')
|
|
282
|
+
pdb_bfactors_per_region = get_bfactors_from_pdb_per_region(input_pdb, type='tcr')
|
|
283
|
+
pdb_dssp_output = run_dssp(input_pdb, type='tcr')
|
|
284
|
+
|
|
285
|
+
modelling_details.update({'beta_numbering': beta_numbering,
|
|
286
|
+
'alpha_numbering': alpha_numbering})
|
|
287
|
+
|
|
288
|
+
else:
|
|
289
|
+
print("ERROR: Not a valid model 'type'. Options are: 'antibody', 'nanobody', 'tcr'")
|
|
290
|
+
|
|
291
|
+
modelling_details.update(pdb_cdr_ranges)
|
|
292
|
+
modelling_details.update(pdb_dssp_output)
|
|
293
|
+
modelling_details.update({'prediction_scores_per_region': pdb_bfactors_per_region})
|
|
294
|
+
|
|
295
|
+
if save:
|
|
296
|
+
output_dir = os.path.dirname(input_pdb)
|
|
297
|
+
|
|
298
|
+
# Save ANARCI numbering
|
|
299
|
+
allowed_species = ['human', 'mouse']
|
|
300
|
+
anarci.anarci(list(pdb_sequences.items()),
|
|
301
|
+
scheme=scheme, output=True,
|
|
302
|
+
outfile=os.path.join(output_dir,"numbering.txt"),
|
|
303
|
+
allowed_species=allowed_species)
|
|
304
|
+
|
|
305
|
+
# Define output filepaths
|
|
306
|
+
output_json = os.path.join(output_dir, 'modelling_details.jsonp')
|
|
307
|
+
|
|
308
|
+
with open(output_json,'w') as fp:
|
|
309
|
+
json.dump(modelling_details, fp)
|
|
310
|
+
|
|
311
|
+
return modelling_details
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""Sequence liabilities, found with antibody-utils, in ABDB's output format.
|
|
2
|
+
|
|
3
|
+
TAP's modelling details, and the SAbPred viewer that reads them, use the format
|
|
4
|
+
of ABDB's `get_liabilities`, which this reproduces.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from antibody_utils.liabilities import find_liabilities
|
|
8
|
+
from antibody_utils.numbering import number_sequence
|
|
9
|
+
|
|
10
|
+
# The liabilities, in the order of ABDB's `liabilities.csv`. The viewer colours
|
|
11
|
+
# each liability by its index in this list.
|
|
12
|
+
LIABILITY_NAMES = (
|
|
13
|
+
"Unpaired Cys (C)",
|
|
14
|
+
"N-linked glycosylation (NXS/T X not P)",
|
|
15
|
+
"Met oxidation (M)",
|
|
16
|
+
"Trp oxidation (W)",
|
|
17
|
+
"Asn deamidation (NG NS NT)",
|
|
18
|
+
"Asp isomerisation (DG DS DT DD DH)",
|
|
19
|
+
"Lysine Glycation (KE KD EK ED)",
|
|
20
|
+
"N-terminal glutamate (VH and VL) (E)",
|
|
21
|
+
"Integrin binding (RGD RYD LDV)",
|
|
22
|
+
"CD11c/CD18 binding (GPR)",
|
|
23
|
+
"Fragmentation (DP)",
|
|
24
|
+
)
|
|
25
|
+
# ABDB listed this liability's pair of matches light chain first.
|
|
26
|
+
_LIGHT_FIRST = "N-terminal glutamate (VH and VL) (E)"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_liabilities(heavy_sequence, light_sequence, save=False, outfile="sequence_liabilities.csv"):
|
|
30
|
+
"""Find the sequence liabilities in a pair of variable domains.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
heavy_sequence: The heavy-chain sequence.
|
|
34
|
+
light_sequence: The light-chain sequence.
|
|
35
|
+
save: Whether to write each liability's residues to `outfile`.
|
|
36
|
+
outfile: The CSV file to write.
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
A list of the liabilities found, each as `[name, start, end,
|
|
40
|
+
start_position, end_position, chain, index]`, where `start` and `end`
|
|
41
|
+
are the (inclusive) indices of the match in the numbered domain, the
|
|
42
|
+
positions are `[number, insertion]` IMGT positions, and `index` is the
|
|
43
|
+
liability's index in `LIABILITY_NAMES`; and the number of liabilities
|
|
44
|
+
searched for.
|
|
45
|
+
"""
|
|
46
|
+
numbered = {"H": number_sequence(heavy_sequence), "L": number_sequence(light_sequence)}
|
|
47
|
+
liabilities = find_liabilities(numbered["H"], numbered["L"])
|
|
48
|
+
|
|
49
|
+
found = []
|
|
50
|
+
for liability in liabilities:
|
|
51
|
+
entry = [
|
|
52
|
+
liability.name,
|
|
53
|
+
liability.start,
|
|
54
|
+
liability.end - 1,
|
|
55
|
+
list(liability.positions[0].to_tuple()),
|
|
56
|
+
list(liability.positions[-1].to_tuple()),
|
|
57
|
+
str(liability.chain),
|
|
58
|
+
LIABILITY_NAMES.index(liability.name),
|
|
59
|
+
]
|
|
60
|
+
if liability.name == _LIGHT_FIRST and entry[5] == "L":
|
|
61
|
+
found.insert(len(found) - 1, entry)
|
|
62
|
+
else:
|
|
63
|
+
found.append(entry)
|
|
64
|
+
|
|
65
|
+
if save:
|
|
66
|
+
with open(outfile, "w") as lfile:
|
|
67
|
+
print(",".join(["chain", "position", "aa", "liability"]), file=lfile)
|
|
68
|
+
for name, start, end, _, _, chain, _ in found:
|
|
69
|
+
domain = numbered[chain]
|
|
70
|
+
for i in range(start, end + 1):
|
|
71
|
+
position = "%d%s" % domain.positions[i].to_tuple()
|
|
72
|
+
print(",".join([chain, position, domain.sequence[i], name]), file=lfile)
|
|
73
|
+
|
|
74
|
+
return found, len(LIABILITY_NAMES)
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""The flag thresholds for TAP's metrics.
|
|
2
|
+
|
|
3
|
+
These are the single definition of TAP's thresholds, which were calibrated on the
|
|
4
|
+
variable regions of 934 post-Phase-I clinical-stage therapeutics (February 2026).
|
|
5
|
+
They are used to flag each metric and to draw the threshold lines on the web
|
|
6
|
+
application's plots.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import math
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
|
|
12
|
+
#: TAP's metrics, by the abbreviations used in its output.
|
|
13
|
+
METRICS = {
|
|
14
|
+
"L": "Total CDR Length",
|
|
15
|
+
"PSH": "Patches of Surface Hydrophobicity",
|
|
16
|
+
"PPC": "Patches of Positive Charge",
|
|
17
|
+
"PNC": "Patches of Negative Charge",
|
|
18
|
+
"SFvCSP": "Structural Fv Charge Symmetry Parameter",
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass(frozen=True)
|
|
23
|
+
class Thresholds:
|
|
24
|
+
"""The flag regions of a metric.
|
|
25
|
+
|
|
26
|
+
As their names suggest, `red_below` and `red_above` are strict, and
|
|
27
|
+
`amber_up_to` and `amber_from` are inclusive. A value is flagged red if it
|
|
28
|
+
is below `red_below` or above `red_above`; amber if it is up to and
|
|
29
|
+
including `amber_up_to`, or from `amber_from` up; and green otherwise. So
|
|
30
|
+
each amber region is closed, and a value on any threshold is flagged amber.
|
|
31
|
+
|
|
32
|
+
A metric with no lower flag regions has `red_below` and `amber_up_to` set to
|
|
33
|
+
-∞, and one with no upper flag regions has `amber_from` and `red_above` set
|
|
34
|
+
to ∞.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
red_below: int | float
|
|
38
|
+
amber_up_to: int | float
|
|
39
|
+
amber_from: int | float
|
|
40
|
+
red_above: int | float
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def flags_low(self):
|
|
44
|
+
"""Whether the metric is flagged for low values."""
|
|
45
|
+
return self.red_below > -math.inf
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def flags_high(self):
|
|
49
|
+
"""Whether the metric is flagged for high values."""
|
|
50
|
+
return self.red_above < math.inf
|
|
51
|
+
|
|
52
|
+
def flag(self, value):
|
|
53
|
+
"""Return the flag colour, "red", "amber" or "green", for a value.
|
|
54
|
+
|
|
55
|
+
A metric that could not be calculated is flagged "grey", rather than
|
|
56
|
+
falling through every comparison below to green.
|
|
57
|
+
"""
|
|
58
|
+
if value is None or math.isnan(value):
|
|
59
|
+
return "grey"
|
|
60
|
+
if value < self.red_below or value > self.red_above:
|
|
61
|
+
return "red"
|
|
62
|
+
if value <= self.amber_up_to or value >= self.amber_from:
|
|
63
|
+
return "amber"
|
|
64
|
+
return "green"
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
THRESHOLDS = {
|
|
68
|
+
"L": Thresholds(red_below=37, amber_up_to=43, amber_from=55, red_above=63),
|
|
69
|
+
"PSH": Thresholds(
|
|
70
|
+
red_below=95.68, amber_up_to=110.58, amber_from=168.23, red_above=211.99
|
|
71
|
+
),
|
|
72
|
+
"PPC": Thresholds(
|
|
73
|
+
red_below=-math.inf, amber_up_to=-math.inf, amber_from=1.13, red_above=2.81
|
|
74
|
+
),
|
|
75
|
+
"PNC": Thresholds(
|
|
76
|
+
red_below=-math.inf, amber_up_to=-math.inf, amber_from=1.538, red_above=3.853
|
|
77
|
+
),
|
|
78
|
+
# Until it was defined here, SFvCSP's amber region was written as
|
|
79
|
+
# -5.8 ≤ v ≤ -20, which is empty, so values from -20 to -5.8 were flagged
|
|
80
|
+
# green.
|
|
81
|
+
"SFvCSP": Thresholds(
|
|
82
|
+
red_below=-20.0, amber_up_to=-5.8, amber_from=math.inf, red_above=math.inf
|
|
83
|
+
),
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def assign_flag(metric, value):
|
|
88
|
+
"""Return the flag colour for a metric's value: "red", "amber" or "green", or
|
|
89
|
+
"grey" if it could not be calculated.
|
|
90
|
+
"""
|
|
91
|
+
return THRESHOLDS[metric].flag(value)
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tap-developability
|
|
3
|
+
Version: 2.0.1
|
|
4
|
+
Summary: TAP: the Therapeutic Antibody Profiler.
|
|
5
|
+
Keywords: antibody,developability,therapeutic antibodies,structural bioinformatics,bioinformatics
|
|
6
|
+
Author: Matthew I. J. Raybould, Charlotte M. Deane
|
|
7
|
+
Author-email: Matthew I. J. Raybould <opig@stats.ox.ac.uk>, Charlotte M. Deane <opig@stats.ox.ac.uk>
|
|
8
|
+
License-Expression: BSD-3-Clause
|
|
9
|
+
License-File: LICENCE
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: POSIX
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
21
|
+
Requires-Dist: antibody-utils[numbering]>=0.1.1
|
|
22
|
+
Requires-Dist: biopython>=1.83
|
|
23
|
+
Requires-Dist: freesasa
|
|
24
|
+
Requires-Dist: immunebuilder>=1.2
|
|
25
|
+
Requires-Dist: numpy
|
|
26
|
+
Requires-Dist: openmm
|
|
27
|
+
Requires-Dist: pdbfixer
|
|
28
|
+
Requires-Dist: scipy
|
|
29
|
+
Requires-Python: >=3.11
|
|
30
|
+
Project-URL: Homepage, https://opig.stats.ox.ac.uk/webapps/sabdab-sabpred/sabpred/tap
|
|
31
|
+
Project-URL: Documentation, https://github.com/oxpig/TAP#readme
|
|
32
|
+
Project-URL: Repository, https://github.com/oxpig/TAP
|
|
33
|
+
Project-URL: Issues, https://github.com/oxpig/TAP/issues
|
|
34
|
+
Project-URL: Changelog, https://github.com/oxpig/TAP/blob/master/CHANGELOG.md
|
|
35
|
+
Project-URL: Paper, https://doi.org/10.1073/pnas.1810576116
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
#######################################################################################
|
|
40
|
+
|
|
41
|
+
__/\\\\\\\\\\\\\\___/\\\\\\\\____/\\\\\\\\\\____
|
|
42
|
+
_\///////\\/////__/\\\\\\\\\\\__\//////////\\___
|
|
43
|
+
_______\/\\______/\\/////////\\_\/\\_____\/\\___
|
|
44
|
+
_______\/\\_____\/\\_______\/\\_\/\\\\\\\\\/____
|
|
45
|
+
_______\/\\_____\/\\\\\\\\\\/\\_\/////////______
|
|
46
|
+
_______\/\\_____\/\\/////////\\_\/\\____________
|
|
47
|
+
_______\/\\_____\/\\_______\/\\_\/\\____________
|
|
48
|
+
_______\/\\_____\/\\_______\/\\_\/\\____________
|
|
49
|
+
_______\///_____\///_______\///_\///____________
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
THE THERAPEUTIC ANTIBODY PROFILER
|
|
53
|
+
|
|
54
|
+
#######################################################################################
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
<div align="center">
|
|
58
|
+
|
|
59
|
+
# The Therapeutic Antibody Profiler
|
|
60
|
+
|
|
61
|
+
[](https://github.com/oxpig/TAP/actions/workflows/tests.yaml)
|
|
62
|
+
[](https://results.pre-commit.ci/latest/github/oxpig/TAP/master)
|
|
63
|
+
[](https://pypi.org/project/tap-developability/)
|
|
64
|
+
[](https://anaconda.org/bioconda/tap-developability)
|
|
65
|
+
[](LICENCE)
|
|
66
|
+
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
## About
|
|
70
|
+
|
|
71
|
+
The Therapeutic Antibody Profiler (TAP) flags antibody variable domains whose
|
|
72
|
+
properties are unusual among clinical-stage therapeutics. It models a paired
|
|
73
|
+
heavy and light chain with [ABodyBuilder2](https://github.com/oxpig/ImmuneBuilder),
|
|
74
|
+
and compares five metrics with their distributions across the variable regions
|
|
75
|
+
of post-Phase-I clinical-stage therapeutics:
|
|
76
|
+
|
|
77
|
+
| Metric | Abbreviation | From |
|
|
78
|
+
| --- | --- | --- |
|
|
79
|
+
| Total IMGT CDR length | L | The sequence |
|
|
80
|
+
| Patches of surface hydrophobicity | PSH | The model |
|
|
81
|
+
| Patches of positive charge | PPC | The model |
|
|
82
|
+
| Patches of negative charge | PNC | The model |
|
|
83
|
+
| Structural Fv charge symmetry parameter | SFvCSP | The model |
|
|
84
|
+
|
|
85
|
+
Each metric is flagged green, amber (in the extremes of the clinical-stage
|
|
86
|
+
distribution) or red (beyond it). The thresholds are defined in
|
|
87
|
+
[`thresholds.py`](src/tap_developability/thresholds.py). TAP also reports the
|
|
88
|
+
CDR sequences and the model's sequence liabilities.
|
|
89
|
+
|
|
90
|
+
TAP was developed in the _Oxford Protein Informatics Group_
|
|
91
|
+
([OPIG](https://opig.stats.ox.ac.uk/)), Department of Statistics, University of
|
|
92
|
+
Oxford.
|
|
93
|
+
|
|
94
|
+
**Authors**
|
|
95
|
+
|
|
96
|
+
* Matthew I. J. Raybould (University of Oxford)
|
|
97
|
+
* Claire Marks (University of Oxford)
|
|
98
|
+
* Konrad Krawczyk (University of Oxford)
|
|
99
|
+
* Bruck Taddese (AstraZeneca)
|
|
100
|
+
* Jaroslaw Nowak (University of Oxford)
|
|
101
|
+
* Alan P. Lewis (GSK)
|
|
102
|
+
* Alexander Bujotzek (Roche)
|
|
103
|
+
* Jiye Shi (UCB)
|
|
104
|
+
* Charlotte M. Deane (University of Oxford)
|
|
105
|
+
|
|
106
|
+
## Citing this work
|
|
107
|
+
|
|
108
|
+
If you use TAP, please cite
|
|
109
|
+
[the paper](https://doi.org/10.1073/pnas.1810576116):
|
|
110
|
+
|
|
111
|
+
```tex
|
|
112
|
+
@article{raybould2019,
|
|
113
|
+
title={Five computational developability guidelines for therapeutic antibody profiling},
|
|
114
|
+
author={Raybould, Matthew I. J. and Marks, Claire and Krawczyk, Konrad and Taddese, Bruck and Nowak, Jaroslaw and Lewis, Alan P. and Bujotzek, Alexander and Shi, Jiye and Deane, Charlotte M.},
|
|
115
|
+
journal={Proceedings of the National Academy of Sciences},
|
|
116
|
+
volume={116},
|
|
117
|
+
number={10},
|
|
118
|
+
pages={4025--4030},
|
|
119
|
+
year={2019},
|
|
120
|
+
doi={10.1073/pnas.1810576116}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Web tool
|
|
125
|
+
|
|
126
|
+
TAP is also available as a web application, as part of
|
|
127
|
+
[SAbPred](https://opig.stats.ox.ac.uk/webapps/sabdab-sabpred/sabpred/tap).
|
|
128
|
+
|
|
129
|
+
## Installation
|
|
130
|
+
|
|
131
|
+
TAP is distributed through [Bioconda](https://bioconda.github.io/), which is
|
|
132
|
+
the recommended way to install it:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
conda install -c conda-forge -c bioconda tap-developability
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Note:** TAP's Bioconda package is not available yet, but will follow soon.
|
|
139
|
+
Until then, install TAP from PyPI, as below.
|
|
140
|
+
|
|
141
|
+
TAP depends on [ANARCI](https://github.com/oxpig/ANARCI) and HMMER from
|
|
142
|
+
Bioconda, and on [ABodyBuilder2](https://github.com/oxpig/ImmuneBuilder),
|
|
143
|
+
[antibody-utils](https://github.com/oxpig/antibody-utils) (which numbers
|
|
144
|
+
sequences with [ANARCII](https://github.com/oxpig/ANARCII)), DSSP and FreeSASA.
|
|
145
|
+
|
|
146
|
+
TAP is also on [PyPI](https://pypi.org/project/tap-developability/), but a
|
|
147
|
+
PyPI install is incomplete: ANARCI and DSSP's `mkdssp` program aren't on PyPI.
|
|
148
|
+
Install them with Conda first, then TAP with pip:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
conda install -c conda-forge -c bioconda anarci "dssp>=4"
|
|
152
|
+
pip install tap-developability
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Do not install the `anarci` package from PyPI, which is not an official release.
|
|
156
|
+
|
|
157
|
+
ABodyBuilder2 downloads its trained weights on first use. Conda installs a
|
|
158
|
+
CUDA-enabled PyTorch where it detects a GPU, and a CPU-only one otherwise.
|
|
159
|
+
|
|
160
|
+
## Usage
|
|
161
|
+
|
|
162
|
+
For a single antibody, with its heavy and light chains separated by `/`:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
TAP --name my_antibody --output my_antibody_output --seq [heavy chain]/[light chain]
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
For multiple antibodies in a FASTA file, with each record's heavy and light
|
|
169
|
+
chains separated by `/`:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
TAP --output /path/to/output/directory --file /path/to/sequences.fasta --ncores 4
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
TAP models each antibody with ABodyBuilder2, then writes its results to the
|
|
176
|
+
output directory: a log for each antibody, a JSON summary of the metrics and
|
|
177
|
+
their flags (`TAP_Results_SingleSeqEntry_[name].json` or
|
|
178
|
+
`TAP_Results_Multientry.json`), and the models, their modelling details and
|
|
179
|
+
their sequence liabilities in `Final_Models/`. With `--web`, it also writes the
|
|
180
|
+
data for the plots shown by the web application.
|
|
181
|
+
|
|
182
|
+
To profile antibody models that you already have:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
TAP --output /path/to/output/directory --models /path/to/models
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
The models must be numbered in IMGT, with the heavy chain as chain H and the
|
|
189
|
+
light chain as chain L, as ABodyBuilder2 writes them, and without hydrogen
|
|
190
|
+
atoms. TAP writes the metrics for every model to `TAP_Results_Multientry.json`,
|
|
191
|
+
and writes annotated copies of the models, and `Final_Models/` and `tmp/`
|
|
192
|
+
directories, into the models' directory.
|
|
193
|
+
|
|
194
|
+
The thresholds were calibrated with the Kyte & Doolittle hydrophobicity scale,
|
|
195
|
+
which is the default (`--hscale 0`). For more options and information, run
|
|
196
|
+
`TAP --help`.
|
|
197
|
+
|
|
198
|
+
## Contributing
|
|
199
|
+
|
|
200
|
+
To set up a development environment, run the tests or make a release, see
|
|
201
|
+
[`CONTRIBUTING.md`](CONTRIBUTING.md). Changes are recorded in
|
|
202
|
+
[`CHANGELOG.md`](CHANGELOG.md).
|