Skip to main content

Set of methods to parse, annotate, and calculate features of TCR structures

Project description

drawing

STCRpy

stcrpy installation stcrpy unittests stcrpy_docs

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

drawing

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

stcrpy-1.0.3.tar.gz (746.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stcrpy-1.0.3-py3-none-any.whl (767.6 kB view details)

Uploaded Python 3

File details

Details for the file stcrpy-1.0.3.tar.gz.

File metadata

  • Download URL: stcrpy-1.0.3.tar.gz
  • Upload date:
  • Size: 746.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for stcrpy-1.0.3.tar.gz
Algorithm Hash digest
SHA256 3358aef05a208b2e2b625b16834b328769c2dfddbc998fa6527561d1899e633e
MD5 e57db82ad2905acb019b507b1580eb2b
BLAKE2b-256 d8944c582c0ec5cf817d25e6bae571577f9960b068d7eb9f6e44850db640fced

See more details on using hashes here.

Provenance

The following attestation bundles were made for stcrpy-1.0.3.tar.gz:

Publisher: release.yml on npqst/STCRpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stcrpy-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: stcrpy-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 767.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for stcrpy-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c69547f6390004ed6b84477bf63e0c526cc4081b9b6910e0a748df5faad8832b
MD5 15734e625fde2085c048be6012169ad4
BLAKE2b-256 7b909102e4bb8d0c8c425117ab595dc61a99c50220710524f1ff28b7010cc6f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for stcrpy-1.0.3-py3-none-any.whl:

Publisher: release.yml on npqst/STCRpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page