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,96 @@
|
|
|
1
|
+
"""
|
|
2
|
+
The CDR Assigner code within the Therapeutic Antibody Profiler (TAP).
|
|
3
|
+
1. Numbers the input sequence using ANARCII (IMGT)
|
|
4
|
+
2. Picks out the IMGT and North CDR Strings and records amino acid by Position.
|
|
5
|
+
3. Returns two dictionaries, one containing the CDR strings, with lengths (tuple), and the other with numbered amino acid data.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import pickle as pickle
|
|
9
|
+
from antibody_utils.regions import get_region #Required to assign CDR or Not in a given definition
|
|
10
|
+
from antibody_utils.numbering import number_sequence #Required to number the chains, with ANARCII
|
|
11
|
+
|
|
12
|
+
#############################################################
|
|
13
|
+
#Called on each single sequence after ANARCI has numbered it#
|
|
14
|
+
|
|
15
|
+
def find_all_regions(output_name,numbered,Chain):
|
|
16
|
+
|
|
17
|
+
definitions = ['imgt','north','chothia','kabat'] #list your desired definitions here
|
|
18
|
+
|
|
19
|
+
regions = {}
|
|
20
|
+
amino_acid_dict = {}
|
|
21
|
+
cdr_length_dict = {}
|
|
22
|
+
|
|
23
|
+
for definition in definitions:
|
|
24
|
+
|
|
25
|
+
regions[definition] = {}
|
|
26
|
+
amino_acid_dict[definition] = {}
|
|
27
|
+
cdr_length_dict[definition] = {}
|
|
28
|
+
|
|
29
|
+
if Chain == "H":
|
|
30
|
+
list_of_regions = ["cdrh3","fwh1", "cdrh1", "fwh2", "cdrh2", "fwh3","fwh4"]
|
|
31
|
+
list_of_cdrs = ["cdrh1","cdrh2","cdrh3"]
|
|
32
|
+
elif Chain == "L":
|
|
33
|
+
list_of_regions = ["cdrl3","fwl1", "cdrl1", "fwl2", "cdrl2", "fwl3","fwl4"]
|
|
34
|
+
list_of_cdrs = ["cdrl1","cdrl2","cdrl3"]
|
|
35
|
+
|
|
36
|
+
for r in list_of_regions:
|
|
37
|
+
regions[definition][r] = ''
|
|
38
|
+
amino_acid_dict[definition][r] = {}
|
|
39
|
+
|
|
40
|
+
# Assign each position on its own, as ABDB's Accept did, so that
|
|
41
|
+
# the CDRs match TAP's previous output.
|
|
42
|
+
for position, residue in numbered:
|
|
43
|
+
r = get_region(position, Chain, scheme="imgt", definition=definition)
|
|
44
|
+
if r is None:
|
|
45
|
+
continue
|
|
46
|
+
regions[definition][r] += residue # We collect the entire primary sequence for each antibody region
|
|
47
|
+
amino_acid_dict[definition][r][str(position)] = residue
|
|
48
|
+
|
|
49
|
+
for r in list_of_regions:
|
|
50
|
+
if r in list_of_cdrs:
|
|
51
|
+
cdr_length_dict[definition][r] = len(regions[definition][r])
|
|
52
|
+
|
|
53
|
+
# Returns a dictionary of regions as strings.
|
|
54
|
+
return regions,amino_acid_dict,cdr_length_dict
|
|
55
|
+
|
|
56
|
+
###################################################################
|
|
57
|
+
#Called by TAP on each chain#
|
|
58
|
+
|
|
59
|
+
def main(output_name, sequence, chain, output_dest, verbose=True):
|
|
60
|
+
aa_dict = {} #Used to store amino acid by position data
|
|
61
|
+
region_dict = {} #Used to store strings and lengths of IMGT/North CDRs
|
|
62
|
+
region_dict['imgt'] = {}
|
|
63
|
+
region_dict['north'] = {}
|
|
64
|
+
|
|
65
|
+
if chain == "H":
|
|
66
|
+
chain_id = "Heavy"
|
|
67
|
+
list_of_regions = ["cdrh1","cdrh2","cdrh3","fwh1","fwh2","fwh3","fwh4"]
|
|
68
|
+
elif chain == "L":
|
|
69
|
+
chain_id = "Light"
|
|
70
|
+
list_of_regions = ["cdrl1","cdrl2","cdrl3","fwl1","fwl2","fwl3","fwl4"]
|
|
71
|
+
|
|
72
|
+
#################################
|
|
73
|
+
numbered = number_sequence(sequence) #Submit to ANARCII; raises NumberingError if it fails
|
|
74
|
+
|
|
75
|
+
# use get_region() to determine CDR or Framework strings
|
|
76
|
+
primary_seqs, amino_dict, length_dict = find_all_regions(output_name,numbered,chain)
|
|
77
|
+
|
|
78
|
+
if verbose:
|
|
79
|
+
print("REGION DICTIONARY\n")
|
|
80
|
+
print(primary_seqs)
|
|
81
|
+
|
|
82
|
+
print("\nAA BY POSIION DICTIONARY\n")
|
|
83
|
+
print(amino_dict)
|
|
84
|
+
|
|
85
|
+
print(numbered.numbering)
|
|
86
|
+
|
|
87
|
+
#print length_dict
|
|
88
|
+
|
|
89
|
+
with open(str(output_dest)+"/Outputs/"+str(output_name)+"_CDR_String_Data.pkl","wb") as fo:
|
|
90
|
+
pickle.dump(primary_seqs,fo,protocol=pickle.HIGHEST_PROTOCOL)
|
|
91
|
+
with open(str(output_dest)+"/Outputs/"+str(output_name)+"_CDR_Length_Data.pkl","wb") as fo:
|
|
92
|
+
pickle.dump(length_dict,fo,protocol=pickle.HIGHEST_PROTOCOL)
|
|
93
|
+
with open(str(output_dest)+"/Outputs/"+str(output_name)+"_Amino_Acid_By_Pos_Data.pkl","wb") as fo:
|
|
94
|
+
pickle.dump(amino_dict,fo,protocol=pickle.HIGHEST_PROTOCOL)
|
|
95
|
+
|
|
96
|
+
return primary_seqs, amino_dict, length_dict
|
|
File without changes
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import math
|
|
2
|
+
from scipy.spatial.distance import cdist
|
|
3
|
+
|
|
4
|
+
def is_number(s):
|
|
5
|
+
try:
|
|
6
|
+
float(s)
|
|
7
|
+
return True
|
|
8
|
+
except ValueError:
|
|
9
|
+
return False
|
|
10
|
+
|
|
11
|
+
class Atom:
|
|
12
|
+
def __init__(self,typ,coords,line):
|
|
13
|
+
self.typ = typ
|
|
14
|
+
self.coords = coords
|
|
15
|
+
self.pdb_line = line
|
|
16
|
+
"""
|
|
17
|
+
To avoid "PDBUtils.Atom instance" message...
|
|
18
|
+
def __repr__(self):
|
|
19
|
+
return "%s" % (self.typ)
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
#Class to hold a single chain from the PDB
|
|
23
|
+
class Residue:
|
|
24
|
+
def __init__(self,atoms,res_type):
|
|
25
|
+
self.atoms = atoms
|
|
26
|
+
self.res_type = res_type
|
|
27
|
+
|
|
28
|
+
def distance(self,res1,res2):
|
|
29
|
+
mindist = 99999999
|
|
30
|
+
for a1 in res1.atoms:
|
|
31
|
+
for a2 in res2.atoms:
|
|
32
|
+
dist = self.euclid(a1.coords[0]-a2.coords[0],a1.coords[1]-a2.coords[1],a1.coords[2]-a2.coords[2])
|
|
33
|
+
if dist<mindist:
|
|
34
|
+
mindist = dist
|
|
35
|
+
|
|
36
|
+
return mindist
|
|
37
|
+
|
|
38
|
+
def sb_distance(self,res1,res2):
|
|
39
|
+
mindist = 99999999
|
|
40
|
+
donors = []
|
|
41
|
+
acceptors = []
|
|
42
|
+
if res1.res_type == "LYS":
|
|
43
|
+
for atom in res1.atoms:
|
|
44
|
+
if atom.typ == "NZ":
|
|
45
|
+
donors.append(atom)
|
|
46
|
+
if res2.res_type == "ASP":
|
|
47
|
+
for atom in res2.atoms:
|
|
48
|
+
if atom.typ == "OD1" or atom.typ == "OD2":
|
|
49
|
+
acceptors.append(atom)
|
|
50
|
+
elif res2.res_type == "GLU":
|
|
51
|
+
for atom in res2.atoms:
|
|
52
|
+
if atom.typ == "OE1" or atom.typ == "OE2":
|
|
53
|
+
acceptors.append(atom)
|
|
54
|
+
elif res1.res_type == "ARG":
|
|
55
|
+
for atom in res1.atoms:
|
|
56
|
+
if atom.typ == "NH1" or atom.typ == "NH2":
|
|
57
|
+
donors.append(atom)
|
|
58
|
+
if res2.res_type == "ASP":
|
|
59
|
+
for atom in res2.atoms:
|
|
60
|
+
if atom.typ == "OD1" or atom.typ == "OD2":
|
|
61
|
+
acceptors.append(atom)
|
|
62
|
+
elif res2.res_type == "GLU":
|
|
63
|
+
for atom in res2.atoms:
|
|
64
|
+
if atom.typ == "OE1" or atom.typ == "OE2":
|
|
65
|
+
acceptors.append(atom)
|
|
66
|
+
"""
|
|
67
|
+
print "*******************************************"
|
|
68
|
+
|
|
69
|
+
for a in donors:
|
|
70
|
+
print a.typ
|
|
71
|
+
print a.coords
|
|
72
|
+
print a.pdb_line
|
|
73
|
+
|
|
74
|
+
for b in acceptors:
|
|
75
|
+
print b.typ
|
|
76
|
+
print b.coords
|
|
77
|
+
print b.pdb_line
|
|
78
|
+
|
|
79
|
+
print "*******************************************"
|
|
80
|
+
"""
|
|
81
|
+
interacters = False
|
|
82
|
+
|
|
83
|
+
for a1 in donors:
|
|
84
|
+
for a2 in acceptors:
|
|
85
|
+
dist = self.euclid((a1.coords[0]-a2.coords[0]),(a1.coords[1]-a2.coords[1]),(a1.coords[2]-a2.coords[2]))
|
|
86
|
+
if dist<mindist:
|
|
87
|
+
mindist = dist
|
|
88
|
+
interacters = (a1,a2)
|
|
89
|
+
|
|
90
|
+
#if interacters != False:
|
|
91
|
+
# print "Minimum Distance between " + str(interacters[0].typ) + " on " + str(res1.res_type) + " coord: " + str(interacters[0].coords) + " and " + str(interacters[1].typ) + " on " + str(res2.res_type) + " coords: " + str(interacters[1].coords) + " is: " + str(mindist)
|
|
92
|
+
|
|
93
|
+
return mindist
|
|
94
|
+
|
|
95
|
+
def euclid(self,x,y,z):
|
|
96
|
+
result = math.sqrt(x*x+y*y+z*z)
|
|
97
|
+
|
|
98
|
+
return result
|
|
99
|
+
|
|
100
|
+
class PDBchain:
|
|
101
|
+
|
|
102
|
+
#Get the contact mappings between the two structures
|
|
103
|
+
def contact_map(self,str1,str2):
|
|
104
|
+
mapping = dict()
|
|
105
|
+
types = dict()
|
|
106
|
+
for chain_1 in str1:
|
|
107
|
+
for chain_2 in str2:
|
|
108
|
+
for res_id_1 in str1[chain_1].residues:
|
|
109
|
+
r_1 = str1[chain_1].residues[res_id_1]
|
|
110
|
+
index_id_1 = chain_1+str(res_id_1[0])+res_id_1[1]
|
|
111
|
+
if index_id_1 not in mapping:
|
|
112
|
+
mapping[index_id_1] = dict()
|
|
113
|
+
types[index_id_1] = r_1.res_type
|
|
114
|
+
for res_id_2 in str2[chain_2].residues:
|
|
115
|
+
index_id_2 = chain_2+str(res_id_2[0])+res_id_2[1]
|
|
116
|
+
r_2 = str2[chain_2].residues[res_id_2]
|
|
117
|
+
types[index_id_2] = r_2.res_type
|
|
118
|
+
d = r_1.distance(r_1,r_2)
|
|
119
|
+
mapping[index_id_1][index_id_2] = d
|
|
120
|
+
|
|
121
|
+
return mapping,types
|
|
122
|
+
#Change the b-factor on the pdb line
|
|
123
|
+
def color_line(self,line,bf):
|
|
124
|
+
while(len(bf))<6:
|
|
125
|
+
bf=" "+bf
|
|
126
|
+
line = line[0:60]+bf+line[66:len(line)]
|
|
127
|
+
|
|
128
|
+
return line
|
|
129
|
+
|
|
130
|
+
def __init__(self,path_to_pdb,which_chain):
|
|
131
|
+
|
|
132
|
+
try:
|
|
133
|
+
residues = dict()
|
|
134
|
+
atoms = []
|
|
135
|
+
curr_id = ""
|
|
136
|
+
res_type = ""
|
|
137
|
+
for line in open(path_to_pdb):
|
|
138
|
+
|
|
139
|
+
if line[0:4]!='ATOM':
|
|
140
|
+
continue
|
|
141
|
+
line = line.strip()
|
|
142
|
+
#print "Chain:",line[21]
|
|
143
|
+
chain = line[21]
|
|
144
|
+
if chain!=which_chain:
|
|
145
|
+
continue
|
|
146
|
+
#print line
|
|
147
|
+
#print "Sid:",line[22:28].replace(" ","")
|
|
148
|
+
sid = line[22:28].replace(" ","")
|
|
149
|
+
|
|
150
|
+
if is_number(sid):
|
|
151
|
+
sid = (int(sid),'')
|
|
152
|
+
else:
|
|
153
|
+
sid = (int(sid[0:len(sid)-1]),sid[len(sid)-1])
|
|
154
|
+
if len(curr_id) ==0:
|
|
155
|
+
curr_id = sid
|
|
156
|
+
#print "atom: ",line[12:17].replace(" ","")
|
|
157
|
+
atom_type = line[12:17].replace(" ","")
|
|
158
|
+
|
|
159
|
+
#print "x:",float(line[30:38].replace(" ",""))
|
|
160
|
+
x = float(line[30:38].replace(" ",""))
|
|
161
|
+
#print "y:",float(line[38:46].replace(" ",""))
|
|
162
|
+
y = float(line[38:46].replace(" ",""))
|
|
163
|
+
#print "z:",float(line[46:54].replace(" ",""))
|
|
164
|
+
z = float(line[46:54].replace(" ",""))
|
|
165
|
+
atom = Atom(atom_type,(x,y,z),line)
|
|
166
|
+
#Push the previous residue
|
|
167
|
+
if sid!=curr_id:
|
|
168
|
+
#push the residue
|
|
169
|
+
res = Residue(atoms,res_type)
|
|
170
|
+
residues[curr_id] = res
|
|
171
|
+
curr_id = sid
|
|
172
|
+
atoms = [atom]
|
|
173
|
+
else:
|
|
174
|
+
atoms.append(atom)
|
|
175
|
+
#print "Res: ",line[17:21].replace(" ","")
|
|
176
|
+
res_type = line[17:21].replace(" ","")
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
#Last residue
|
|
180
|
+
res = Residue(atoms,res_type)
|
|
181
|
+
residues[curr_id] = res
|
|
182
|
+
#print "Initialized with ",len(residues)," residues"
|
|
183
|
+
self.residues = residues
|
|
184
|
+
except IOError:
|
|
185
|
+
print("IOError: ",path_to_pdb,"does not exist")
|
|
186
|
+
quit()
|
|
187
|
+
|
|
File without changes
|