Set of methods to parse, annotate, and calculate features of TCR structures
Project description
STCRpy
Structural TCR python (STCRpy) is a software suite for analysing and processing T-cell receptor structures.
Please feel free to reach out with any comments or feedback.
Under review, please cite:
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
Installation
TL;DR installation
pip install stcrpy
pip install plip
conda install -c conda-forge pymol-open-source numpy -y
ANARCI --build_models # this step will take a few minutes
Step by step installation
We recommend installing STCRpy in a conda (or mamba) environment using python 3.9 to 3.12:
conda create -n stcrpy_env python==3.12 -y
conda activate stcrpy_env
The core functionality of STCRpy can be installed as follows:
pip install stcrpy
After installing stcrpy, the anarci HMM models must be built to enable annotation.
ANARCI --build_models # this step will take a few minutes
To enable interaction profiling, install PLIP (Adasme et. al., 2021):
pip install plip
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.
conda install -c conda-forge pymol-open-source numpy -y
To generate pytorch and pytorch-geometric compatible datasets:
pip install pytorch --index-url https://download.pytorch.org/whl/cpu
pip install torch_geometric
Note that this installs the CPU version of pytorch, for GPU / CUDA versions install according to the pytorch installation docs.
The EGNN example also uses einops. To install:
pip install einops
Documentation
STCRpy documentation is hosted on ReadtheDocs.
Examples
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(). TCR objects are associated with their MHC and antigen if these are presented in the structure.
A notebook with examples can be found under examples/STCRpy_examples.ipynb
First import STCRpy:
import stcrpy
To fetch a TCR structure from STCRDab or the PDB:
tcr = stcrpy.fetch_TCR("8gvb")
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.
To load a TCR structure from a PDB or MMCIF file:
tcr = stcrpy.load_TCR("filename.{pdb, cif}")
To load multiple TCR structures from a list of files at once:
multiple_tcrs = stcrpy.load_TCRs([file_1, file_2, file_3])
To save a TCR object to PDB or MMCIF files:
tcr.save(filename.{pdb, cif}) # save the TCR and it's associated MHC and antigen
tcr.save(filename.{pdb, cif}, TCR_only=True) # save the TCR only
To calculate the TCR to pMHC geometry:
tcr.calculate_geometry() # change the 'mode' keyword argument to change the geometry calculation method. See paper / documentation for details.
To score the TCR to pMHC geometry:
tcr.score_docking_geometry()
To profile interactions:
tcr.profile_peptide_interactions() # interaction profiling parameters can be adjusted, see documentation for details
To visualise interactions:
tcr.visualise_interactions()
To run full analysis on a set of TCR structures:
from stcrpy.tcr_methods.tcr_batch_operations import analyse_tcrs
germlines_and_alleles_df, geometries_df, interactions_df = analyse_tcrs(list_or_dict_of_files)
To generate graph datasets:
dataset = TCRGraphDataset(
root=PATH_TO_DATASET,
data_paths=PATH_TO_TCR_FILES
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stcrpy-1.0.0.tar.gz.
File metadata
- Download URL: stcrpy-1.0.0.tar.gz
- Upload date:
- Size: 744.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
104f603b5efadddc3a69baffc005cd3b00d7409fd823d0d56b17a41c8a5d2aae
|
|
| MD5 |
10b87c94951a9ff44b05f352f6edcae0
|
|
| BLAKE2b-256 |
c963b03b16d8ced5053e57c7862cec0ed130a4c6fb3899324b9ca3ba3d5658a0
|
Provenance
The following attestation bundles were made for stcrpy-1.0.0.tar.gz:
Publisher:
release.yml on npqst/STCRpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stcrpy-1.0.0.tar.gz -
Subject digest:
104f603b5efadddc3a69baffc005cd3b00d7409fd823d0d56b17a41c8a5d2aae - Sigstore transparency entry: 204397645
- Sigstore integration time:
-
Permalink:
npqst/STCRpy@3e66a740bc7a4d57b49de79d7e8bde4958184b2a -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/npqst
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3e66a740bc7a4d57b49de79d7e8bde4958184b2a -
Trigger Event:
push
-
Statement type:
File details
Details for the file stcrpy-1.0.0-py3-none-any.whl.
File metadata
- Download URL: stcrpy-1.0.0-py3-none-any.whl
- Upload date:
- Size: 765.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97a0fdc95fd2fc153d28ba8f0e6c1323085b833a122b709d64f39c5465ae1e26
|
|
| MD5 |
4d1d2708bba93c49e2689cba79fdb01b
|
|
| BLAKE2b-256 |
2c4edffee3b3345b4e60f7397cad1c5fb852bbe53b2f1cc6eadbc3834550839d
|
Provenance
The following attestation bundles were made for stcrpy-1.0.0-py3-none-any.whl:
Publisher:
release.yml on npqst/STCRpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stcrpy-1.0.0-py3-none-any.whl -
Subject digest:
97a0fdc95fd2fc153d28ba8f0e6c1323085b833a122b709d64f39c5465ae1e26 - Sigstore transparency entry: 204397647
- Sigstore integration time:
-
Permalink:
npqst/STCRpy@3e66a740bc7a4d57b49de79d7e8bde4958184b2a -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/npqst
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3e66a740bc7a4d57b49de79d7e8bde4958184b2a -
Trigger Event:
push
-
Statement type: