stcrpy 1.0.3__py3-none-any.whl → 1.0.6__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.
@@ -0,0 +1,96 @@
1
+ import warnings
2
+ import tempfile
3
+ import os
4
+
5
+ from Bio.PDB import PDBParser, PDBIO
6
+ from ..TCRParser import TCRParser
7
+
8
+
9
+ def get_symmetry_mates(filename):
10
+ try:
11
+ from pymol import cmd
12
+ except ModuleNotFoundError:
13
+ warnings.warn(
14
+ "Pymol not installed - please install pymol to enabe symmetry mate TCR parsing. "
15
+ )
16
+ return []
17
+
18
+ cmd.load(filename)
19
+ obj_name = cmd.get_object_list()[0]
20
+ cmd.symexp(obj_name, obj_name, obj_name, cutoff=20.0, quiet=0)
21
+ if (
22
+ len(cmd.get_object_list()) == 1
23
+ ): # No symmetry mates found, likely becuase file did not contain symmetry information
24
+ cmd.delete(obj_name)
25
+ cmd.fetch(
26
+ filename.split("/")[-1].split(".")[0]
27
+ ) # this will try to retrieve the file from the pdb directly, will not work if the filename is not the pdb code
28
+ if len(cmd.get_object_list()) == 0:
29
+ warnings.warn(f"No symmetry mates found for {filename}.")
30
+ return
31
+ obj_name = cmd.get_object_list()[0]
32
+ cmd.symexp(obj_name, obj_name, obj_name, cutoff=10.0, quiet=0)
33
+ tcr_symmetry_mates = []
34
+
35
+ tcp = TCRParser()
36
+ pdp = PDBParser(QUIET=True)
37
+ pdbio = PDBIO()
38
+ try:
39
+ with tempfile.TemporaryDirectory() as tmpdir:
40
+ for i, obj in enumerate(cmd.get_object_list()):
41
+ fn = os.path.join(tmpdir, f"{obj_name}_symmetry_mate_{i}.pdb")
42
+ cmd.save(fn, obj)
43
+ symmetry_mate = pdp.get_structure("tmp", fn)
44
+ if i == 0:
45
+ chain_ids = generate_chain_id_list(
46
+ len(
47
+ list(symmetry_mate.get_chains())
48
+ * len(cmd.get_object_list())
49
+ )
50
+ )
51
+ for c in symmetry_mate.get_chains():
52
+ chain_ids.remove(
53
+ c.id
54
+ ) # remove all chain ids of the original structure
55
+ if i > 0: # Skip the original structure
56
+ # rename chain ids, this cannot be done directly to TCR structure without breaking the TCR and MHC chain assignments.
57
+ for chain in reversed(list(symmetry_mate.get_chains())):
58
+ symmetry_mate[0].detach_child(chain.id)
59
+ new_id = chain_ids.pop(0)
60
+ chain.id = new_id
61
+ symmetry_mate[0].add(chain)
62
+ pdbio.set_structure(symmetry_mate)
63
+ pdbio.save(fn)
64
+
65
+ symmetry_mate = tcp.get_tcr_structure(
66
+ f"{obj_name}_symmetry_{i}", fn, include_symmetry_mates=False
67
+ )
68
+ tcr_symmetry_mates.append(symmetry_mate)
69
+ except Exception as e:
70
+ warnings.warn(f"Symmetry mate generation failed with: {str(e)}")
71
+
72
+ # clean up the pymol cmd space
73
+ for obj in cmd.get_object_list():
74
+ cmd.delete(obj)
75
+ del cmd
76
+ return tcr_symmetry_mates
77
+
78
+
79
+ def generate_chain_id_list(N):
80
+ """Generates a set of chain ids starting from A, B, C, ..., Z, AA, AB, ..., AZ, BA
81
+
82
+ Args:
83
+ N (int): The number of chain IDs to generate.
84
+
85
+ Returns:
86
+ set: A set of generated chain IDs.
87
+ """
88
+ chain_ids = []
89
+ for i in range(N):
90
+ ch1 = chr(65 + (i // 26) - 1) if i >= 26 else ""
91
+ ch2 = chr(65 + (i % 26))
92
+ chain_ids.append(ch1 + ch2)
93
+ import string
94
+
95
+ chain_ids = string.ascii_uppercase + string.ascii_lowercase + string.digits
96
+ return list(chain_ids)[:N]
@@ -0,0 +1,286 @@
1
+ Metadata-Version: 2.4
2
+ Name: stcrpy
3
+ Version: 1.0.6
4
+ Summary: Set of methods to parse, annotate, and calculate features of TCR structures
5
+ Maintainer-email: Nele Quast <quast@stats.ox.ac.uk>
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENCE
9
+ License-File: stcrpy/tcr_geometry/TCRCoM_LICENCE
10
+ Requires-Dist: biopython
11
+ Requires-Dist: numpy==1.26.4
12
+ Requires-Dist: lxml
13
+ Requires-Dist: openbabel-wheel==3.1.1.21
14
+ Requires-Dist: rdkit
15
+ Requires-Dist: pyhmmer==0.11.4
16
+ Requires-Dist: anarci-mhc
17
+ Requires-Dist: pandas
18
+ Requires-Dist: matplotlib
19
+ Requires-Dist: scipy
20
+ Requires-Dist: requests
21
+ Requires-Dist: scikit-learn
22
+ Requires-Dist: DockQ
23
+ Provides-Extra: ml-datasets
24
+ Requires-Dist: einops; extra == "ml-datasets"
25
+ Requires-Dist: torch; extra == "ml-datasets"
26
+ Requires-Dist: torch_geometric; extra == "ml-datasets"
27
+ Dynamic: license-file
28
+
29
+
30
+
31
+ <img src="./stcrpy_logo.png" alt="drawing" width="300"/>
32
+
33
+
34
+ # STCRpy
35
+ [![stcrpy installation](https://github.com/npqst/STCRpy/actions/workflows/conda-workflow.yml/badge.svg)](https://github.com/npqst/STCRpy/actions/workflows/conda-workflow.yml)
36
+ [![stcrpy unittests](https://github.com/npqst/STCRpy/actions/workflows/unittest-workflow.yml/badge.svg)](https://github.com/npqst/STCRpy/actions/workflows/unittest-workflow.yml)
37
+ [![stcrpy_docs](https://readthedocs.org/projects/stcrpy/badge/?version=latest)](https://stcrpy.readthedocs.io/en/latest/)
38
+
39
+
40
+ Structural TCR python (STCRpy) is a software suite for analysing and processing T-cell receptor structures.
41
+
42
+ Please feel free to reach out with any comments or feedback.
43
+
44
+ Under review, please cite:
45
+
46
+ **Quast, N. , Deane, C., & Raybould, M. (2025). STCRpy: a software suite for TCR:pMHC structure parsing, interaction profiling, and machine learning dataset preparation. Bioinformatics. [https://doi.org/10.1093/bioinformatics/btaf566](https://doi.org/10.1093/bioinformatics/btaf566)**
47
+
48
+ <img src="./stcrpy_main_fig.png" alt="drawing" width="1500"/>
49
+
50
+
51
+
52
+ # Installation
53
+
54
+ ## TL;DR installation
55
+ ```
56
+ pip install stcrpy
57
+ pip install plip
58
+ conda install pymol-open-source -y
59
+ ANARCI --build_models # this step will take a few minutes
60
+ ```
61
+
62
+ ## Step by step installation
63
+ We recommend installing STCRpy in a [conda](https://www.anaconda.com/docs/getting-started/miniconda/install#macos-linux-installation) (or [mamba](https://mamba.readthedocs.io/en/latest/installation/mamba-installation.html)) environment using python 3.9 to 3.12. You can also use a python virtual environment if you do not need pymol visualisations.
64
+
65
+ <details> <summary>conda</summary>
66
+
67
+ ```
68
+ conda create -n stcrpy_env python==3.12 -y
69
+ conda activate stcrpy_env
70
+ ```
71
+
72
+ </details>
73
+ <details> <summary>mamba</summary>
74
+
75
+ ```
76
+ mamba create -n stcrpy_env python==3.12 -y
77
+ mamba activate stcrpy_env
78
+ ```
79
+
80
+ </details>
81
+ <details> <summary>venv</summary>
82
+
83
+ ```
84
+ python -m venv stcrpy_env
85
+ source stcrpy_env/bin/activate
86
+ ```
87
+
88
+ </details>
89
+
90
+
91
+ The core functionality of STCRpy can be installed as follows:
92
+ ```
93
+ pip install stcrpy
94
+ ```
95
+
96
+ After installing stcrpy, the anarci HMM models must be built to enable annotation.
97
+ ```
98
+ ANARCI --build_models # this step will take a few minutes
99
+ ```
100
+
101
+ To enable interaction profiling, install PLIP (Adasme et. al., 2021):
102
+ ```
103
+ pip install plip
104
+ ```
105
+
106
+ To enable pymol visualisations, install pymol open source locally within the environment. Unfortunately, pymol currently needs to be installed even if you already have a pymol version. Be sure to install pymol within a managed conda (or mamba) environment to prevent interference with any existing versions.
107
+ ```
108
+ conda install pymol-open-source -y
109
+ ```
110
+
111
+ To generate pytorch and pytorch-geometric compatible datasets (see the [pytorch docs](https://pytorch.org/get-started/locally/) for hardware specific instructions):
112
+ ```
113
+ pip install stcrpy[ml_datasets]
114
+ ```
115
+
116
+ > Note that the installs for pytorch can be platform specific.
117
+ > If errors are ecountered here it is best to manually install the depedencies following the [pytorch installation docs](https://pytorch.org/get-started/locally/).
118
+ > For example:
119
+ > ```
120
+ > pip install torch --index-url https://download.pytorch.org/whl/cpu
121
+ > pip install torch_geometric
122
+ > ```
123
+ > This installs the CPU version of pytorch (for GPU / CUDA versions follow the install [pytorch installation docs](https://pytorch.org/get-started/locally/)).
124
+ >
125
+ > The EGNN example also uses `einops`. Which can be manually installed as follows:
126
+ > ```
127
+ > pip install einops
128
+ > ```
129
+
130
+ # Documentation
131
+ STCRpy [documentation](https://stcrpy.readthedocs.io/en/latest/) is hosted on ReadtheDocs.
132
+
133
+ # Examples
134
+ STCRpy generates and operates on TCR structure objects. The majority of the API can be accessed through functions of the format: `tcr.some_stcrpy_function()`. ([See TCR object docs here](https://stcrpy.readthedocs.io/en/latest/stcrpy.tcr_processing.html#stcrpy.tcr_processing.TCR.TCR)). TCR objects are associated with their MHC and antigen if these are presented in the structure.
135
+
136
+ A notebook with examples can be found under [examples/STCRpy_examples.ipynb](./examples/STCRpy_examples.ipynb)
137
+
138
+ First import STCRpy:
139
+ ```
140
+ import stcrpy
141
+ ```
142
+
143
+ ### To fetch a TCR structure from STCRDab or the PDB:
144
+ ```
145
+ multiple_tcrs = stcrpy.fetch_TCRs("8gvb")
146
+ ```
147
+ This will return a list of all of the TCR structures found in the PDB file, represented as TCR structure objects.
148
+
149
+ ### To load a TCR structure from a PDB or MMCIF file:
150
+ ```
151
+ tcr = stcrpy.load_TCR("filename.{pdb, cif}")
152
+ ```
153
+
154
+ ### To load multiple TCR structures from a list of files at once:
155
+ ```
156
+ multiple_tcrs = stcrpy.load_TCRs([file_1, file_2, file_3])
157
+ ```
158
+
159
+ ### To save a TCR object to PDB or MMCIF files:
160
+ ```
161
+ tcr.save(filename.{pdb, cif}) # save the TCR and it's associated MHC and antigen
162
+ tcr.save(filename.{pdb, cif}, TCR_only=True) # save the TCR only
163
+ ```
164
+
165
+ ### To calculate the TCR to pMHC geometry:
166
+ ```
167
+ tcr.calculate_geometry() # change the 'mode' keyword argument to change the geometry calculation method. See paper / documentation for details.
168
+ ```
169
+
170
+ ### To score the TCR to pMHC geometry:
171
+ ```
172
+ tcr.score_docking_geometry()
173
+ ```
174
+
175
+ ### To profile interactions:
176
+ ```
177
+ tcr.profile_peptide_interactions() # interaction profiling parameters can be adjusted, see documentation for details
178
+ ```
179
+
180
+ ### To visualise interactions:
181
+ ```
182
+ tcr.visualise_interactions()
183
+ ```
184
+
185
+ ### To run full analysis on a set of TCR structures:
186
+ ```
187
+ from stcrpy.tcr_methods.tcr_batch_operations import analyse_tcrs
188
+ germlines_and_alleles_df, geometries_df, interactions_df = analyse_tcrs(list_or_dict_of_files)
189
+ ```
190
+
191
+ ### To generate graph datasets:
192
+ ```
193
+ dataset = TCRGraphDataset(
194
+ root=PATH_TO_DATASET,
195
+ data_paths=PATH_TO_TCR_FILES
196
+ )
197
+ ```
198
+
199
+ ### To calculate TCR prediction metrics such as RMSD, interface RMSD (of the TCR:pMHC interface) or DockQ scores:
200
+
201
+ ```
202
+ # RMSD
203
+ from stcrpy.tcr_metrics import RMSD
204
+
205
+ rmsd_calculator = RMSD()
206
+ rmsd = rmsd_calculator.calculate_rmsd(pred_tcr, reference_tcr, save_alignment=False) # Calculates the RMSD of each region of the TCR. To check the alignment set save_alignment to True.
207
+
208
+ # To calculate RMSD for a set of predictions against a set of reference structures from files:
209
+ files = list(zip(prediction_files, reference_files))
210
+ rmsd_df = rmsd_calculator.rmsd_from_files(files)
211
+
212
+
213
+
214
+ # Interface RMSD of TCR:pMHC interface
215
+ from stcrpy.tcr_metrics import InterfaceRMSD
216
+
217
+ interface_rmsd_calculator = InterfaceRMSD()
218
+ irmsds = interface_rmsd_calculator.get_interface_rmsd(tcr, reference_tcr)
219
+
220
+ # DockQ
221
+ from stcrpy.tcr_metrics.tcr_dockq import TCRDockQ
222
+
223
+ dockq_calculator = TCRDockQ() # by default this will merge the TCR and pMHC chains and calculate DockQ of the complete TCR:pMHC interface. To calculate DockQ scores per chain, use TCR_pMHC_interface=False
224
+ dockq_results = dockq_calculator.tcr_dockq(tcr, reference_tcr, save_merged_complex=False) # to investigate the merged TCR:pMHC structure set save_merged_complex=True
225
+
226
+ ```
227
+
228
+ ### Torsion angles and internal coordinates
229
+ STCRpy builds upon the Biopython PDB module, and you can calculate the internal coordinates, such as backbone torsion angles, using the [`internal_coordinates` function](https://biopython.org/docs/dev/api/Bio.PDB.internal_coords.html).
230
+
231
+ ```
232
+ # internal coordinate calculations should be made per chain
233
+ for c in tcr.get_chains():
234
+ c.atom_to_internal_coordinates() # calculate the internal coordinates
235
+
236
+ # internal coordinates can be accessed per residue:
237
+ res = next(tcr.get_residues())
238
+ res.internal_coord.get_angle("psi") # retrieve angles via angle keys
239
+ ```
240
+
241
+ ### Domain angles between TCR chains
242
+ STCRpy can be used to calculate the geometry and angles between the TCR variable domains of abTCRs and gdTCRs. This follows the ABangle implementation [(Dunbar et al. 2013)](https://academic.oup.com/peds/article/26/10/611/1509255).
243
+ ```
244
+ tcr.get_TCR_angles()
245
+
246
+ # returns dictionary of TCR domain angles and measurements.
247
+ # For example:
248
+ # {
249
+ # 'BA': -56.72234454750631,
250
+ # 'BC1': 122.55277240895967,
251
+ # 'AC1': 73.96532018128327,
252
+ # 'BC2': 82.63524566165464,
253
+ # 'AC2': 99.60327202896609,
254
+ # 'dc': np.float64(15.606353954437227)
255
+ # }
256
+
257
+ ```
258
+
259
+
260
+ # Symmetry mate handling
261
+ Some TCR:pMHC crystals are formed of repeating cell units in which the TCR and the antigen do not directly contact.
262
+ STCRpy generates symmetry mates in these cases to pair pMHC with TCRs in the structure.
263
+ Note that symmetry mate generation requires pymol to be installed. By default, symmetry mate generation is enabled, however, it can be toggled by setting:
264
+ `include_symmetry_mates=False` in `get_tcr_structure`.
265
+
266
+ ## Example:
267
+ ```
268
+ tcr_6ulr_paired_antigen = stcrpy.fetch_TCRs("6ulr")
269
+ tcr_6ulr_no_antigen = stcrpy.fetch_TCRs("6ulr", include_symmetry_mates=False) # does not generate symmetry mates
270
+
271
+ ```
272
+
273
+
274
+
275
+ # Limitations
276
+
277
+ ## Connected peptide chains
278
+ STCRpy is currently not configured to handle cases where the antigen peptide is connected to the TCR or MHC chain - this is primarily because the parsing pipeline operates on chain objects and it can be tricky to consistently separate the peptide segment from the remainder of the TCR chain. A known case is PDB code 6MNO.
279
+
280
+ ## Gamma-Delta TCR geometry
281
+ STCRpy supports gamma-delta TCR parsing, interaction profiling and visusalisation, but is not currently configured to calculate gd-TCR geometry.
282
+
283
+ ## MHC Class II geometry scoring
284
+ STCRpy can be used to calculate and characterise the geometries of TCRs to MHC class II antigen, however, due to the smaller number of complexes we have not fit parametric distributions to the geometry features, which means it is not possible to calculate a geometry score.
285
+
286
+
@@ -1,39 +1,49 @@
1
1
  examples/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  examples/egnn.py,sha256=ab9OMeJ--a1XkTa5nF7y8-B0XNpS5LCuK1x5lEnyz3o,13812
3
- stcrpy/__init__.py,sha256=D5Ela4G19FPIFzO5CpyzJMnrvvoTNQUwz1s-qb0waDo,252
3
+ stcrpy/__init__.py,sha256=ULJpFjOVfuUjI5F1DuWlMxNI5t6Fsrvf8IVCqVJ9OxI,253
4
4
  stcrpy/tcr_datasets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  stcrpy/tcr_datasets/tcr_graph_dataset.py,sha256=q8Di7sxgO-Rtzn7eVi_UMx4Sk9A31nvIxO7n_Nie-d0,19614
6
6
  stcrpy/tcr_datasets/tcr_selector.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  stcrpy/tcr_datasets/tcr_structure_dataset.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  stcrpy/tcr_datasets/utils.py,sha256=t_ogJu4hoI-ywr5-MnepuB-3L5-YXFoKQzyaONsDMFM,4888
9
9
  stcrpy/tcr_formats/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- stcrpy/tcr_formats/tcr_formats.py,sha256=ZLouBdpY1K8xOA7tORkfljE9iUsbn_oay4DRHvP5Wbc,3812
10
+ stcrpy/tcr_formats/tcr_formats.py,sha256=RG6P7oDZSzsTDobngv0K9qHhJM7-tmSjwQSDP3CpN3A,4342
11
11
  stcrpy/tcr_formats/tcr_haddock.py,sha256=ejGs1DsOMKE-CDK5k9M4J-9y-7bLq_BbNLAkBNhpjjQ,21913
12
+ stcrpy/tcr_geometry/TCRAngle.py,sha256=1tIoJ2RIxQPH2_ne9w-UlUKGsBlfsc2oarJVIkt9VHQ,6330
12
13
  stcrpy/tcr_geometry/TCRCoM.py,sha256=Mtq0ieQUTj2R_EN9BUFdUtSbT9AtI5OPi1TEdnMlxME,12883
13
14
  stcrpy/tcr_geometry/TCRCoM_LICENCE,sha256=93k_qqF0rgpyWEmxpcl2sbZS3CK1dkGrIuvJtKsBlCA,7844
14
15
  stcrpy/tcr_geometry/TCRDock.py,sha256=Uga1OV5owC-lVfzzKFn5dGEGnaeHJUHMpppdUxnK84k,9975
15
16
  stcrpy/tcr_geometry/TCRGeom.py,sha256=niol8kNMUufFkjxhOkFhBhonNIKpQwhl6V8qbVa7tLg,19041
16
17
  stcrpy/tcr_geometry/TCRGeomFiltering.py,sha256=JN02yyxeXy6XRH3oSKTskcUkxoqvxsvSRGpR-4H25kA,9666
17
18
  stcrpy/tcr_geometry/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
+ stcrpy/tcr_geometry/reference_data/Acoreset.txt,sha256=VDcDb_Uf5D_wNEwVtRZM9kcehodwIhl5fQ9Jfh0ncw0,125
20
+ stcrpy/tcr_geometry/reference_data/Bcoreset.txt,sha256=zZw-eZIflcAy9k8z1t869g75lU4ZRj75VtH5ztLA50k,121
18
21
  stcrpy/tcr_geometry/reference_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ stcrpy/tcr_geometry/reference_data/consensus_A.pdb,sha256=sA75dr5KcpND-pvQ5jFEkmWTUbJTwkOoSWLEMWp4nNo,2433
23
+ stcrpy/tcr_geometry/reference_data/consensus_B.pdb,sha256=gXBhVfKKLbNRP3gyq7K7ofLMgEXKWeVdYJQI0Ws_NKg,2434
24
+ stcrpy/tcr_geometry/reference_data/consensus_D.pdb,sha256=O9LHeh3bWxeEWwuTcp1HwzxzEfPfGOSAUHe4nMI-Okc,2434
25
+ stcrpy/tcr_geometry/reference_data/consensus_G.pdb,sha256=Fs8e_UDb6dI1qqhNSttWaHrzkjgzjFpMpC38_W9OXTg,2434
19
26
  stcrpy/tcr_geometry/reference_data/dock_reference_1_imgt_numbered.pdb,sha256=wjzvP6_fhMoUp4b1Q18_-JXHpl8kKbqjFvLiglW2Yek,530400
20
27
  stcrpy/tcr_geometry/reference_data/dock_reference_2_imgt_numbered.pdb,sha256=sXUJ7CKGnA9FevyocJj30VA2EqgYM0s0ejRgBP6R9Gk,526026
28
+ stcrpy/tcr_geometry/reference_data/pcA.txt,sha256=SNqBtyHeeL9dSJHzMUhjfO9zhH61Qn8fCORpsPnkH8w,99
29
+ stcrpy/tcr_geometry/reference_data/pcB.txt,sha256=IEHoYprUz56JnV3sNOMApNKmapnk18WtelCGwok5YgU,100
21
30
  stcrpy/tcr_geometry/reference_data/reference_A.pdb,sha256=sA75dr5KcpND-pvQ5jFEkmWTUbJTwkOoSWLEMWp4nNo,2433
22
31
  stcrpy/tcr_geometry/reference_data/reference_B.pdb,sha256=gXBhVfKKLbNRP3gyq7K7ofLMgEXKWeVdYJQI0Ws_NKg,2434
23
32
  stcrpy/tcr_geometry/reference_data/reference_D.pdb,sha256=O9LHeh3bWxeEWwuTcp1HwzxzEfPfGOSAUHe4nMI-Okc,2434
24
33
  stcrpy/tcr_geometry/reference_data/reference_G.pdb,sha256=Fs8e_UDb6dI1qqhNSttWaHrzkjgzjFpMpC38_W9OXTg,2434
25
34
  stcrpy/tcr_geometry/reference_data/reference_data.py,sha256=q3L-cQ1UQUfZxeIMKIiiase_6SEEuWlx7UsLndwNLAk,1658
26
35
  stcrpy/tcr_interactions/PLIPParser.py,sha256=zetY_LvH_8E-26xXc02c7_edoHWEwIWB9_XIu1szRcA,5785
27
- stcrpy/tcr_interactions/TCRInteractionProfiler.py,sha256=Q4OBQ3DooM592Sk5DnjeAJAAohVOkrbp8MAXNRTLnVg,17835
36
+ stcrpy/tcr_interactions/TCRInteractionProfiler.py,sha256=Bn2HAHG158nE3PhL1UoaZCaexm-gK9F9_exYtTCJXtQ,18038
28
37
  stcrpy/tcr_interactions/TCRpMHC_PLIP_Model_Parser.py,sha256=-fm_rtPJhU-h3WuX1U5Cv3vjO0eAlzwbm1HTreQIDCI,5464
29
38
  stcrpy/tcr_interactions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
39
  stcrpy/tcr_interactions/utils.py,sha256=KEGybd1ugZvFdj4Gqn9Xo4lnJbU1ivADmEDjkvuaNiw,5177
31
40
  stcrpy/tcr_methods/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
- stcrpy/tcr_methods/tcr_batch_operations.py,sha256=YtRgui5H8MyR0zyGDGk1pwaydhQBYbepkRB1XspzpuQ,8363
33
- stcrpy/tcr_methods/tcr_methods.py,sha256=ghWO-F4sOCv1BOxMLC-nSbGxpY4B6L88v-IF13cV2FM,5553
41
+ stcrpy/tcr_methods/tcr_batch_operations.py,sha256=-nh4EqgEYE8rx5-1iiVBJucc-r0nGizqj1S9S9LlNb0,8539
42
+ stcrpy/tcr_methods/tcr_methods.py,sha256=k1DoZYVSnNLkikpP5bFAZaSa4DS41vwiHtXVIz_9vCQ,5569
34
43
  stcrpy/tcr_methods/tcr_reformatting.py,sha256=lgWyYOrk30fCY0IoDBI6IuIqeXdH0ukKX_x9LAdLVfk,625
35
44
  stcrpy/tcr_metrics/__init__.py,sha256=vy80DujN4kMr_rlFPWtLY48mIbsXK_SfTwzzgfQIY_E,73
36
45
  stcrpy/tcr_metrics/constants.py,sha256=uocAA2RM1JSE6n0gq1RDnZIcd3JROi9wDvJ-J4yc_IY,406
46
+ stcrpy/tcr_metrics/tcr_dockq.py,sha256=G4Px1lT5OjSirdIgMQ0X7G2Nj_1DJCD0Dkjclv0QMlQ,17320
37
47
  stcrpy/tcr_metrics/tcr_interface_rmsd.py,sha256=Gsv6XDO6r4N9dCo--CyOkneni1gVf2X1Ws2y6vXuj2M,9605
38
48
  stcrpy/tcr_metrics/tcr_rmsd.py,sha256=cbK20z1ELjeEecPxZF3vQ4uDlorrAAb5C8D8YtTpwz4,6811
39
49
  stcrpy/tcr_ml/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -43,26 +53,27 @@ stcrpy/tcr_processing/Chemical_components.py,sha256=KuJiV-SnATz1cWoZnZmamNaivOhP
43
53
  stcrpy/tcr_processing/Entity.py,sha256=kY8oLVnmWOMMzj4Gj7ouE-IaxLHrlchX1Y2EAu8Sstw,11180
44
54
  stcrpy/tcr_processing/Fragment.py,sha256=QW_6sPWi2HX7mq5dLLwvA-7Q9oiBHCS0p02WgFLDisA,1908
45
55
  stcrpy/tcr_processing/Holder.py,sha256=y_q2NF0YiCf9CuXWlIm9-EWpD5CJj95o2wUCYDyEHOA,549
46
- stcrpy/tcr_processing/MHC.py,sha256=71IiBc2t3_w4_BeA99SJV8RKwWxhEMYpZG3Q5akaV0A,13639
56
+ stcrpy/tcr_processing/MHC.py,sha256=bKNs_dOiTUpqBZnTDlvGjWHH8TaVQrRo-ieYYPULXFY,26299
47
57
  stcrpy/tcr_processing/MHCchain.py,sha256=rT0FCkKD2pbZm-VTvcLwCdS5UOy-ibxnNcsgREIxgSs,4357
48
58
  stcrpy/tcr_processing/Model.py,sha256=K8wTrSCECHyqJX9811wU9MxgdGDVyCXraQ4-rOOa08U,1230
49
59
  stcrpy/tcr_processing/Select.py,sha256=VuVSgmqHBPD1DGRumM44HDzcQ-aQOwg_6zQHM3Ulm0U,3543
50
- stcrpy/tcr_processing/TCR.py,sha256=DHkNZ309TTfn_Ou2XL0dACK5KVR3j4Sj5G-42cuELi4,24651
60
+ stcrpy/tcr_processing/TCR.py,sha256=dcMdw2WEGa-BUZUqAAe0Dw4U2Qyh1xYUaS4N7E7J2AQ,33220
51
61
  stcrpy/tcr_processing/TCRIO.py,sha256=tSJLVN6MG6gyT26PreVJOz5DqD1e-VsBjBpu3mBBPKg,1501
52
- stcrpy/tcr_processing/TCRParser.py,sha256=DzRin1hQ6DfvRhPnt6pKiB6TJAzM5C7ivPwH39-m_hk,51738
62
+ stcrpy/tcr_processing/TCRParser.py,sha256=4C7wmW6ENgNLAZsxoxzl3lk6UFQmYOPcMLvIzjmms8k,56274
53
63
  stcrpy/tcr_processing/TCRStructure.py,sha256=yFiUeo02KXIBBEljy0mebv5ol5uCQRTy-Sfs94Rt6Hc,3810
54
64
  stcrpy/tcr_processing/TCRchain.py,sha256=2CdP_JX5LG7nM8Lsuhcevf7SyRaQUZlizt3ntEYVPjg,4769
55
65
  stcrpy/tcr_processing/__init__.py,sha256=BefeJ0jefteeOzWrkOMvxLCvzd0aJDhXWrdTm7zlP94,94
56
- stcrpy/tcr_processing/annotate.py,sha256=JDXsIooYewRzI8-Hh9sd84QJvPrc4GZ3MfN6A-jJPLU,17172
66
+ stcrpy/tcr_processing/annotate.py,sha256=MGk4UzLGtGL_J_ySPYoUTszOfzQjsWCpeeaXrza7Bfo,17438
57
67
  stcrpy/tcr_processing/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
68
  stcrpy/tcr_processing/utils/common.py,sha256=5e-dP6jPlaFZEErusakdQYpyj79E3WvEGF5-sG0LitI,1869
59
69
  stcrpy/tcr_processing/utils/constants.py,sha256=AHReE1QkeqTnhjvQI7nrPqLF4XdtzHV9C1w1uHTiVcM,8151
60
- stcrpy/tcr_processing/utils/region_definitions.py,sha256=pWE3xJAhnGtLHWxvJOHaU5Y5spcHuZwPzcIDCsH920I,18806
70
+ stcrpy/tcr_processing/utils/region_definitions.py,sha256=t3HT6FHFlGqS_DdV2xWLdTxhIUEjWHsf_0_f-06w94E,19198
71
+ stcrpy/tcr_processing/utils/symmetry_mates.py,sha256=dvyfEWovnjh9SZMqSTCsO_HgpyA2TqxIwHkmG_HxcK8,3557
61
72
  stcrpy/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
73
  stcrpy/utils/error_stream.py,sha256=BLHJnf-tWU41MXh6sHSZgkTFOMiWZsCgwM2qIKBnwr4,247
63
- stcrpy-1.0.3.dist-info/licenses/LICENCE,sha256=G1FnVDsfeYoveKTu9Xaqukcm-4xZ4mzakjLpFMnNfJ0,1507
64
- stcrpy-1.0.3.dist-info/licenses/stcrpy/tcr_geometry/TCRCoM_LICENCE,sha256=93k_qqF0rgpyWEmxpcl2sbZS3CK1dkGrIuvJtKsBlCA,7844
65
- stcrpy-1.0.3.dist-info/METADATA,sha256=widJsCi2RfI9soEo0mPM1TUtgJopNRvPinR-n6Z3qYo,5885
66
- stcrpy-1.0.3.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
67
- stcrpy-1.0.3.dist-info/top_level.txt,sha256=kAkgyHyGW-_YswJpcuA3pSqzuQVbUggFUmZg2OTx_B8,16
68
- stcrpy-1.0.3.dist-info/RECORD,,
74
+ stcrpy-1.0.6.dist-info/licenses/LICENCE,sha256=G1FnVDsfeYoveKTu9Xaqukcm-4xZ4mzakjLpFMnNfJ0,1507
75
+ stcrpy-1.0.6.dist-info/licenses/stcrpy/tcr_geometry/TCRCoM_LICENCE,sha256=93k_qqF0rgpyWEmxpcl2sbZS3CK1dkGrIuvJtKsBlCA,7844
76
+ stcrpy-1.0.6.dist-info/METADATA,sha256=jYS1OQgMW6ZtxxfsHlqbIuCcwIGfZ9ikRGg_9BN1TbI,10605
77
+ stcrpy-1.0.6.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
78
+ stcrpy-1.0.6.dist-info/top_level.txt,sha256=kAkgyHyGW-_YswJpcuA3pSqzuQVbUggFUmZg2OTx_B8,16
79
+ stcrpy-1.0.6.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.1.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,173 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: stcrpy
3
- Version: 1.0.3
4
- Summary: Set of methods to parse, annotate, and calculate features of TCR structures
5
- Maintainer: Nele Quast
6
- Maintainer-email: quast@stats.ox.ac.uk
7
- Description-Content-Type: text/markdown
8
- License-File: LICENCE
9
- License-File: stcrpy/tcr_geometry/TCRCoM_LICENCE
10
- Requires-Dist: biopython
11
- Requires-Dist: numpy==1.26.4
12
- Requires-Dist: lxml
13
- Requires-Dist: openbabel-wheel==3.1.1.21
14
- Requires-Dist: rdkit
15
- Requires-Dist: anarci-mhc
16
- Requires-Dist: pandas
17
- Requires-Dist: matplotlib
18
- Requires-Dist: scipy
19
- Requires-Dist: requests
20
- Requires-Dist: scikit-learn
21
- Dynamic: description
22
- Dynamic: description-content-type
23
- Dynamic: license-file
24
- Dynamic: maintainer
25
- Dynamic: maintainer-email
26
- Dynamic: requires-dist
27
- Dynamic: summary
28
-
29
-
30
-
31
- <img src="./stcrpy_logo.png" alt="drawing" width="300"/>
32
-
33
-
34
- # STCRpy
35
- [![stcrpy installation](https://github.com/npqst/STCRpy/actions/workflows/conda-workflow.yml/badge.svg)](https://github.com/npqst/STCRpy/actions/workflows/conda-workflow.yml)
36
- [![stcrpy unittests](https://github.com/npqst/STCRpy/actions/workflows/unittest-workflow.yml/badge.svg)](https://github.com/npqst/STCRpy/actions/workflows/unittest-workflow.yml)
37
- [![stcrpy_docs](https://readthedocs.org/projects/stcrpy/badge/?version=latest)](https://stcrpy.readthedocs.io/en/latest/)
38
-
39
-
40
- Structural TCR python (STCRpy) is a software suite for analysing and processing T-cell receptor structures.
41
-
42
- Please feel free to reach out with any comments or feedback.
43
-
44
- Under review, please cite:
45
-
46
- **Quast, N. , Deane, C., & Raybould, M. (2025). STCRpy: a software suite for TCR:pMHC structure parsing, interaction profiling, and machine learning dataset preparation. BioRxiv. https://doi.org/10.1101/2025.04.25.650667**
47
-
48
- <img src="./stcrpy_main_fig.png" alt="drawing" width="1500"/>
49
-
50
-
51
-
52
- # Installation
53
-
54
- ## TL;DR installation
55
- ```
56
- pip install stcrpy
57
- pip install plip
58
- conda install -c conda-forge pymol-open-source numpy -y
59
- ANARCI --build_models # this step will take a few minutes
60
- ```
61
-
62
- ## Step by step installation
63
- We recommend installing STCRpy in a [conda](https://www.anaconda.com/docs/getting-started/miniconda/install#macos-linux-installation) (or [mamba](https://mamba.readthedocs.io/en/latest/installation/mamba-installation.html)) environment using python 3.9 to 3.12:
64
- ```
65
- conda create -n stcrpy_env python==3.12 -y
66
- conda activate stcrpy_env
67
- ```
68
-
69
- The core functionality of STCRpy can be installed as follows:
70
- ```
71
- pip install stcrpy
72
- ```
73
-
74
- After installing stcrpy, the anarci HMM models must be built to enable annotation.
75
- ```
76
- ANARCI --build_models # this step will take a few minutes
77
- ```
78
-
79
- To enable interaction profiling, install PLIP (Adasme et. al., 2021):
80
- ```
81
- pip install plip
82
- ```
83
-
84
- To enable pymol visualisations, install pymol open source locally within the environment. Unfortunately, pymol currently needs to be installed even if you already have a pymol version. Be sure to install pymol within a managed conda (or mamba) environment to prevent interference with any existing versions.
85
- ```
86
- conda install -c conda-forge pymol-open-source numpy -y
87
- ```
88
-
89
- To generate pytorch and pytorch-geometric compatible datasets:
90
- ```
91
- pip install pytorch --index-url https://download.pytorch.org/whl/cpu
92
- pip install torch_geometric
93
- ```
94
- Note that this installs the CPU version of pytorch, for GPU / CUDA versions install according to the [pytorch installation docs](https://pytorch.org/get-started/locally/).
95
-
96
- The EGNN example also uses `einops`. To install:
97
- ```
98
- pip install einops
99
- ```
100
-
101
- # Documentation
102
- STCRpy [documentation](https://stcrpy.readthedocs.io/en/latest/) is hosted on ReadtheDocs.
103
-
104
- # Examples
105
- STCRpy generates and operates on TCR structure objects. The majority of the API can be accessed through functions of the format: [`tcr.some_stcrpy_function()`](https://stcrpy.readthedocs.io/en/latest/stcrpy.tcr_processing.html#stcrpy.tcr_processing.TCR.TCR). TCR objects are associated with their MHC and antigen if these are presented in the structure.
106
-
107
- A notebook with examples can be found under [examples/STCRpy_examples.ipynb](./examples/STCRpy_examples.ipynb)
108
-
109
- First import STCRpy:
110
- ```
111
- import stcrpy
112
- ```
113
-
114
- ### To fetch a TCR structure from STCRDab or the PDB:
115
- ```
116
- tcr = stcrpy.fetch_TCR("8gvb")
117
- ```
118
- This will return a TCR strcuture or object, or, if there are multiple copies of TCR crystal structures in the PDB file, will return a list containing TCR structure objects. It may be useful to unpack the list into distinct objects, or use python generators to operate on the lists.
119
-
120
- ### To load a TCR structure from a PDB or MMCIF file:
121
- ```
122
- tcr = stcrpy.load_TCR("filename.{pdb, cif}")
123
- ```
124
-
125
- ### To load multiple TCR structures from a list of files at once:
126
- ```
127
- multiple_tcrs = stcrpy.load_TCRs([file_1, file_2, file_3])
128
- ```
129
-
130
- ### To save a TCR object to PDB or MMCIF files:
131
- ```
132
- tcr.save(filename.{pdb, cif}) # save the TCR and it's associated MHC and antigen
133
- tcr.save(filename.{pdb, cif}, TCR_only=True) # save the TCR only
134
- ```
135
-
136
- ### To calculate the TCR to pMHC geometry:
137
- ```
138
- tcr.calculate_geometry() # change the 'mode' keyword argument to change the geometry calculation method. See paper / documentation for details.
139
- ```
140
-
141
- ### To score the TCR to pMHC geometry:
142
- ```
143
- tcr.score_docking_geometry()
144
- ```
145
-
146
- ### To profile interactions:
147
- ```
148
- tcr.profile_peptide_interactions() # interaction profiling parameters can be adjusted, see documentation for details
149
- ```
150
-
151
- ### To visualise interactions:
152
- ```
153
- tcr.visualise_interactions()
154
- ```
155
-
156
- ### To run full analysis on a set of TCR structures:
157
- ```
158
- from stcrpy.tcr_methods.tcr_batch_operations import analyse_tcrs
159
- germlines_and_alleles_df, geometries_df, interactions_df = analyse_tcrs(list_or_dict_of_files)
160
- ```
161
-
162
- ### To generate graph datasets:
163
- ```
164
- dataset = TCRGraphDataset(
165
- root=PATH_TO_DATASET,
166
- data_paths=PATH_TO_TCR_FILES
167
- )
168
- ```
169
-
170
-
171
-
172
-
173
-