stcrpy 1.0.0__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.
Files changed (68) hide show
  1. examples/__init__.py +0 -0
  2. examples/egnn.py +425 -0
  3. stcrpy/__init__.py +5 -0
  4. stcrpy/tcr_datasets/__init__.py +0 -0
  5. stcrpy/tcr_datasets/tcr_graph_dataset.py +499 -0
  6. stcrpy/tcr_datasets/tcr_selector.py +0 -0
  7. stcrpy/tcr_datasets/tcr_structure_dataset.py +0 -0
  8. stcrpy/tcr_datasets/utils.py +350 -0
  9. stcrpy/tcr_formats/__init__.py +0 -0
  10. stcrpy/tcr_formats/tcr_formats.py +114 -0
  11. stcrpy/tcr_formats/tcr_haddock.py +556 -0
  12. stcrpy/tcr_geometry/TCRCoM.py +350 -0
  13. stcrpy/tcr_geometry/TCRCoM_LICENCE +168 -0
  14. stcrpy/tcr_geometry/TCRDock.py +261 -0
  15. stcrpy/tcr_geometry/TCRGeom.py +450 -0
  16. stcrpy/tcr_geometry/TCRGeomFiltering.py +273 -0
  17. stcrpy/tcr_geometry/__init__.py +0 -0
  18. stcrpy/tcr_geometry/reference_data/__init__.py +0 -0
  19. stcrpy/tcr_geometry/reference_data/dock_reference_1_imgt_numbered.pdb +6549 -0
  20. stcrpy/tcr_geometry/reference_data/dock_reference_2_imgt_numbered.pdb +6495 -0
  21. stcrpy/tcr_geometry/reference_data/reference_A.pdb +31 -0
  22. stcrpy/tcr_geometry/reference_data/reference_B.pdb +31 -0
  23. stcrpy/tcr_geometry/reference_data/reference_D.pdb +31 -0
  24. stcrpy/tcr_geometry/reference_data/reference_G.pdb +31 -0
  25. stcrpy/tcr_geometry/reference_data/reference_data.py +104 -0
  26. stcrpy/tcr_interactions/PLIPParser.py +147 -0
  27. stcrpy/tcr_interactions/TCRInteractionProfiler.py +433 -0
  28. stcrpy/tcr_interactions/TCRpMHC_PLIP_Model_Parser.py +133 -0
  29. stcrpy/tcr_interactions/__init__.py +0 -0
  30. stcrpy/tcr_interactions/utils.py +170 -0
  31. stcrpy/tcr_methods/__init__.py +0 -0
  32. stcrpy/tcr_methods/tcr_batch_operations.py +223 -0
  33. stcrpy/tcr_methods/tcr_methods.py +150 -0
  34. stcrpy/tcr_methods/tcr_reformatting.py +18 -0
  35. stcrpy/tcr_metrics/__init__.py +2 -0
  36. stcrpy/tcr_metrics/constants.py +39 -0
  37. stcrpy/tcr_metrics/tcr_interface_rmsd.py +237 -0
  38. stcrpy/tcr_metrics/tcr_rmsd.py +179 -0
  39. stcrpy/tcr_ml/__init__.py +0 -0
  40. stcrpy/tcr_ml/geometry_predictor.py +3 -0
  41. stcrpy/tcr_processing/AGchain.py +89 -0
  42. stcrpy/tcr_processing/Chemical_components.py +48915 -0
  43. stcrpy/tcr_processing/Entity.py +301 -0
  44. stcrpy/tcr_processing/Fragment.py +58 -0
  45. stcrpy/tcr_processing/Holder.py +24 -0
  46. stcrpy/tcr_processing/MHC.py +449 -0
  47. stcrpy/tcr_processing/MHCchain.py +149 -0
  48. stcrpy/tcr_processing/Model.py +37 -0
  49. stcrpy/tcr_processing/Select.py +145 -0
  50. stcrpy/tcr_processing/TCR.py +532 -0
  51. stcrpy/tcr_processing/TCRIO.py +47 -0
  52. stcrpy/tcr_processing/TCRParser.py +1230 -0
  53. stcrpy/tcr_processing/TCRStructure.py +148 -0
  54. stcrpy/tcr_processing/TCRchain.py +160 -0
  55. stcrpy/tcr_processing/__init__.py +3 -0
  56. stcrpy/tcr_processing/annotate.py +480 -0
  57. stcrpy/tcr_processing/utils/__init__.py +0 -0
  58. stcrpy/tcr_processing/utils/common.py +67 -0
  59. stcrpy/tcr_processing/utils/constants.py +367 -0
  60. stcrpy/tcr_processing/utils/region_definitions.py +782 -0
  61. stcrpy/utils/__init__.py +0 -0
  62. stcrpy/utils/error_stream.py +12 -0
  63. stcrpy-1.0.0.dist-info/METADATA +173 -0
  64. stcrpy-1.0.0.dist-info/RECORD +68 -0
  65. stcrpy-1.0.0.dist-info/WHEEL +5 -0
  66. stcrpy-1.0.0.dist-info/licenses/LICENCE +28 -0
  67. stcrpy-1.0.0.dist-info/licenses/stcrpy/tcr_geometry/TCRCoM_LICENCE +168 -0
  68. stcrpy-1.0.0.dist-info/top_level.txt +2 -0
@@ -0,0 +1,367 @@
1
+ """
2
+ constants.py
3
+ @author: leem
4
+ @date: 9 May 2017
5
+
6
+ Constant values that are useful. Based off of rotlib.constants.
7
+ """
8
+
9
+ import re
10
+
11
+
12
+ def tuplefy(x):
13
+ """
14
+ Interpretation for converting numbering (in string) into a tuple.
15
+
16
+ @param x: A string for the identifier of a numbered position. e.g "H100A".
17
+ @return : A tuple of the chain tupe followed by a tuple of residue id and insertion code. eg. ( H, (100, "A") )
18
+
19
+ """
20
+ chain, resi, ins = re.split(r"(\d+)", x)
21
+ assert chain in ["B", "A", "G", "D"], "Not a recognised chain type."
22
+ ins = ins if ins else " "
23
+ return (chain, (int(resi), ins))
24
+
25
+
26
+ #######
27
+ # String constants
28
+ #######
29
+
30
+ # Basic string names for residues
31
+ RESIDUES = {}
32
+ RESIDUES["ALA"] = "A"
33
+ RESIDUES["CYS"] = "C"
34
+ RESIDUES["ASP"] = "D"
35
+ RESIDUES["GLU"] = "E"
36
+ RESIDUES["PHE"] = "F"
37
+ RESIDUES["GLY"] = "G"
38
+ RESIDUES["HIS"] = "H"
39
+ RESIDUES["ILE"] = "I"
40
+ RESIDUES["LYS"] = "K"
41
+ RESIDUES["LEU"] = "L"
42
+ RESIDUES["MET"] = "M"
43
+ RESIDUES["ASN"] = "N"
44
+ RESIDUES["PRO"] = "P"
45
+ RESIDUES["GLN"] = "Q"
46
+ RESIDUES["ARG"] = "R"
47
+ RESIDUES["SER"] = "S"
48
+ RESIDUES["THR"] = "T"
49
+ RESIDUES["VAL"] = "V"
50
+ RESIDUES["TRP"] = "W"
51
+ RESIDUES["TYR"] = "Y"
52
+ RESIDUES_SINGLE = dict([(v, k) for k, v in list(RESIDUES.items())])
53
+ RESIDUES_SINGLE_STRING = "ACDEFGHIKLMNPQRSTVWY"
54
+
55
+ # Atoms in the backbone/CB for doing checks on residues.
56
+ BACKBONE_ATOMS = ["N", "CA", "C", "O"]
57
+ BACKBONE_CB = ["N", "CA", "C", "O", "CB"]
58
+
59
+ # TCR chain types
60
+ TCR_CHAINS = ["B", "A", "G", "D"]
61
+ TCR_REGIONS = [
62
+ "fwb1",
63
+ "fwb2",
64
+ "fwb3",
65
+ "fwb4",
66
+ "fwa1",
67
+ "fwa2",
68
+ "fwa3",
69
+ "fwa4",
70
+ "fwg1",
71
+ "fwg2",
72
+ "fwg3",
73
+ "fwg4",
74
+ "fwd1",
75
+ "fwd2",
76
+ "fwd3",
77
+ "fwd4",
78
+ "cdrb1",
79
+ "cdrb2",
80
+ "cdrb3",
81
+ "cdrb4",
82
+ "cdra1",
83
+ "cdra2",
84
+ "cdra3",
85
+ "cdra4",
86
+ "cdrg1",
87
+ "cdrg2",
88
+ "cdrg3",
89
+ "cdrg4",
90
+ "cdrd1",
91
+ "cdrd2",
92
+ "cdrd3",
93
+ "cdrd4",
94
+ ]
95
+
96
+ # MHC chain types and regions
97
+ MHC_CHAINS = ["GA1", "GA2", "GA", "GB"] # G-alpha1,2, G-alpha,beta
98
+ MHC_REGIONS = ["Astrand", "Bstrand", "Cstrand", "Dstrand", "Helix", "Turn"]
99
+
100
+ # Common names for species
101
+ COMMON_NAMES = {
102
+ "bos taurus": "cattle",
103
+ "camelus dromedarius": "arabian camel",
104
+ "canis lupus familiaris": "domestic dog",
105
+ "cerocebus atys": "sooty mangabey",
106
+ "danio rerio": "zebrafish",
107
+ "homo sapiens": "human",
108
+ "macaca fascicularis": "crab-eating macaque",
109
+ "macaca mulatta": "rhesus macaque",
110
+ "macaca nemestrina": "Southern pig-tailed macaque",
111
+ "mus musculus": "house mouse",
112
+ "mus cookii": "cook's mouse",
113
+ "mus minutoides": "African pygmy mouse",
114
+ "mus pahari": "Gairdner's shrewmouse",
115
+ "mus saxicola": "brown spiny mouse",
116
+ "mus spretus": "Algerian mouse",
117
+ "oncorhynchus mykiss": "rainbow trout",
118
+ "ornithorhynchus anatinus": "platypus",
119
+ "oryctolagus cuniculus": "rabbit",
120
+ "ovis aries": "sheep",
121
+ "papio anubis": "olive baboon",
122
+ "staphylococcus aureus": "S. aureus",
123
+ "rattus norvegicus": "norway rat",
124
+ "rattus rattus": "black rat",
125
+ "sus scrofa": "pig",
126
+ "vicugna pacos": "alpaca",
127
+ }
128
+
129
+ # Atoms in the backbone/CB for doing checks on residues.
130
+ BACKBONE_ATOMS = ["N", "CA", "C", "O"]
131
+ BACKBONE_CB = ["N", "CA", "C", "O", "CB"]
132
+
133
+ SIDECHAIN_ATOMS = dict(
134
+ ALA=["CB"],
135
+ ARG=["CB", "CG", "CD", "CZ", "NE", "NH1", "NH2"],
136
+ ASN=["CB", "CG", "ND2", "OD1"],
137
+ ASP=["CB", "CG", "OD1", "OD2"],
138
+ CYS=["CB", "SG"],
139
+ GLN=["CB", "CG", "CD", "NE2", "OE1"],
140
+ GLU=["CB", "CG", "CD", "OE1", "OE2"],
141
+ HIS=["CB", "CG", "CD2", "CE1", "ND1", "NE2"],
142
+ ILE=["CB", "CG1", "CD1", "CG2"],
143
+ LEU=["CB", "CG", "CD1", "CD2"],
144
+ LYS=["CB", "CG", "CD", "CE", "NZ"],
145
+ MET=["CB", "CG", "SD", "CE"],
146
+ PHE=["CB", "CG", "CD1", "CD2", "CE1", "CE2", "CZ"],
147
+ PRO=["CB", "CG", "CD"],
148
+ SER=["CB", "OG"],
149
+ THR=["CB", "CG2", "OG1"],
150
+ TRP=["CB", "CG", "CD1", "CD2", "CE2", "CE3", "CH2", "CZ2", "CZ3", "NE1"],
151
+ TYR=["CB", "CG", "CD1", "CD2", "CE1", "CE2", "CZ", "OH"],
152
+ VAL=["CB", "CG1", "CG2"],
153
+ )
154
+
155
+ # BLOSUM62 matrix
156
+ BLOSUM62 = {
157
+ ("A", "A"): 4,
158
+ ("C", "A"): 0,
159
+ ("C", "C"): 9,
160
+ ("C", "D"): -3,
161
+ ("C", "N"): -3,
162
+ ("C", "R"): -3,
163
+ ("D", "A"): -2,
164
+ ("D", "D"): 6,
165
+ ("D", "N"): 1,
166
+ ("D", "R"): -2,
167
+ ("E", "A"): -1,
168
+ ("E", "C"): -4,
169
+ ("E", "D"): 2,
170
+ ("E", "E"): 5,
171
+ ("E", "N"): 0,
172
+ ("E", "Q"): 2,
173
+ ("E", "R"): 0,
174
+ ("F", "A"): -2,
175
+ ("F", "C"): -2,
176
+ ("F", "D"): -3,
177
+ ("F", "E"): -3,
178
+ ("F", "F"): 6,
179
+ ("F", "G"): -3,
180
+ ("F", "H"): -1,
181
+ ("F", "I"): 0,
182
+ ("F", "K"): -3,
183
+ ("F", "L"): 0,
184
+ ("F", "M"): 0,
185
+ ("F", "N"): -3,
186
+ ("F", "Q"): -3,
187
+ ("F", "R"): -3,
188
+ ("G", "A"): 0,
189
+ ("G", "C"): -3,
190
+ ("G", "D"): -1,
191
+ ("G", "E"): -2,
192
+ ("G", "G"): 6,
193
+ ("G", "N"): 0,
194
+ ("G", "Q"): -2,
195
+ ("G", "R"): -2,
196
+ ("H", "A"): -2,
197
+ ("H", "C"): -3,
198
+ ("H", "D"): -1,
199
+ ("H", "E"): 0,
200
+ ("H", "G"): -2,
201
+ ("H", "H"): 8,
202
+ ("H", "N"): 1,
203
+ ("H", "Q"): 0,
204
+ ("H", "R"): 0,
205
+ ("I", "A"): -1,
206
+ ("I", "C"): -1,
207
+ ("I", "D"): -3,
208
+ ("I", "E"): -3,
209
+ ("I", "G"): -4,
210
+ ("I", "H"): -3,
211
+ ("I", "I"): 4,
212
+ ("I", "N"): -3,
213
+ ("I", "Q"): -3,
214
+ ("I", "R"): -3,
215
+ ("K", "A"): -1,
216
+ ("K", "C"): -3,
217
+ ("K", "D"): -1,
218
+ ("K", "E"): 1,
219
+ ("K", "G"): -2,
220
+ ("K", "H"): -1,
221
+ ("K", "I"): -3,
222
+ ("K", "K"): 5,
223
+ ("K", "L"): -2,
224
+ ("K", "N"): 0,
225
+ ("K", "Q"): 1,
226
+ ("K", "R"): 2,
227
+ ("L", "A"): -1,
228
+ ("L", "C"): -1,
229
+ ("L", "D"): -4,
230
+ ("L", "E"): -3,
231
+ ("L", "G"): -4,
232
+ ("L", "H"): -3,
233
+ ("L", "I"): 2,
234
+ ("L", "L"): 4,
235
+ ("L", "N"): -3,
236
+ ("L", "Q"): -2,
237
+ ("L", "R"): -2,
238
+ ("M", "A"): -1,
239
+ ("M", "C"): -1,
240
+ ("M", "D"): -3,
241
+ ("M", "E"): -2,
242
+ ("M", "G"): -3,
243
+ ("M", "H"): -2,
244
+ ("M", "I"): 1,
245
+ ("M", "K"): -1,
246
+ ("M", "L"): 2,
247
+ ("M", "M"): 5,
248
+ ("M", "N"): -2,
249
+ ("M", "Q"): 0,
250
+ ("M", "R"): -1,
251
+ ("N", "A"): -2,
252
+ ("N", "N"): 6,
253
+ ("N", "R"): 0,
254
+ ("P", "A"): -1,
255
+ ("P", "C"): -3,
256
+ ("P", "D"): -1,
257
+ ("P", "E"): -1,
258
+ ("P", "F"): -4,
259
+ ("P", "G"): -2,
260
+ ("P", "H"): -2,
261
+ ("P", "I"): -3,
262
+ ("P", "K"): -1,
263
+ ("P", "L"): -3,
264
+ ("P", "M"): -2,
265
+ ("P", "N"): -2,
266
+ ("P", "P"): 7,
267
+ ("P", "Q"): -1,
268
+ ("P", "R"): -2,
269
+ ("Q", "A"): -1,
270
+ ("Q", "C"): -3,
271
+ ("Q", "D"): 0,
272
+ ("Q", "N"): 0,
273
+ ("Q", "Q"): 5,
274
+ ("Q", "R"): 1,
275
+ ("R", "A"): -1,
276
+ ("R", "R"): 5,
277
+ ("S", "A"): 1,
278
+ ("S", "C"): -1,
279
+ ("S", "D"): 0,
280
+ ("S", "E"): 0,
281
+ ("S", "F"): -2,
282
+ ("S", "G"): 0,
283
+ ("S", "H"): -1,
284
+ ("S", "I"): -2,
285
+ ("S", "K"): 0,
286
+ ("S", "L"): -2,
287
+ ("S", "M"): -1,
288
+ ("S", "N"): 1,
289
+ ("S", "P"): -1,
290
+ ("S", "Q"): 0,
291
+ ("S", "R"): -1,
292
+ ("S", "S"): 4,
293
+ ("T", "A"): 0,
294
+ ("T", "C"): -1,
295
+ ("T", "D"): -1,
296
+ ("T", "E"): -1,
297
+ ("T", "F"): -2,
298
+ ("T", "G"): -2,
299
+ ("T", "H"): -2,
300
+ ("T", "I"): -1,
301
+ ("T", "K"): -1,
302
+ ("T", "L"): -1,
303
+ ("T", "M"): -1,
304
+ ("T", "N"): 0,
305
+ ("T", "P"): -1,
306
+ ("T", "Q"): -1,
307
+ ("T", "R"): -1,
308
+ ("T", "S"): 1,
309
+ ("T", "T"): 5,
310
+ ("V", "A"): 0,
311
+ ("V", "C"): -1,
312
+ ("V", "D"): -3,
313
+ ("V", "E"): -2,
314
+ ("V", "F"): -1,
315
+ ("V", "G"): -3,
316
+ ("V", "H"): -3,
317
+ ("V", "I"): 3,
318
+ ("V", "K"): -2,
319
+ ("V", "L"): 1,
320
+ ("V", "M"): 1,
321
+ ("V", "N"): -3,
322
+ ("V", "P"): -2,
323
+ ("V", "Q"): -2,
324
+ ("V", "R"): -3,
325
+ ("V", "S"): -2,
326
+ ("V", "T"): 0,
327
+ ("V", "V"): 4,
328
+ ("V", "W"): -3,
329
+ ("V", "Y"): -1,
330
+ ("W", "A"): -3,
331
+ ("W", "C"): -2,
332
+ ("W", "D"): -4,
333
+ ("W", "E"): -3,
334
+ ("W", "F"): 1,
335
+ ("W", "G"): -2,
336
+ ("W", "H"): -2,
337
+ ("W", "I"): -3,
338
+ ("W", "K"): -3,
339
+ ("W", "L"): -2,
340
+ ("W", "M"): -1,
341
+ ("W", "N"): -4,
342
+ ("W", "P"): -4,
343
+ ("W", "Q"): -2,
344
+ ("W", "R"): -3,
345
+ ("W", "S"): -3,
346
+ ("W", "T"): -2,
347
+ ("W", "W"): 11,
348
+ ("Y", "A"): -2,
349
+ ("Y", "C"): -2,
350
+ ("Y", "D"): -3,
351
+ ("Y", "E"): -2,
352
+ ("Y", "F"): 3,
353
+ ("Y", "G"): -3,
354
+ ("Y", "H"): 2,
355
+ ("Y", "I"): -1,
356
+ ("Y", "K"): -2,
357
+ ("Y", "L"): -1,
358
+ ("Y", "M"): -1,
359
+ ("Y", "N"): -2,
360
+ ("Y", "P"): -3,
361
+ ("Y", "Q"): -1,
362
+ ("Y", "R"): -2,
363
+ ("Y", "S"): -2,
364
+ ("Y", "T"): -2,
365
+ ("Y", "W"): 2,
366
+ ("Y", "Y"): 7,
367
+ }