Skip to main content

Python interface to running command-line and web-based MHC binding predictors

Project description

Tests PyPI

mhctools

Python interface to running command-line and web-based MHC binding predictors.

Commandline examples

Prediction for user-supplied peptide sequences

mhctools --sequence SIINFEKL SIINFEKLQ --mhc-predictor netmhc --mhc-alleles A0201

Automatically extract peptides as subsequences of specified length

mhctools --sequence AAAQQQSIINFEKL --extract-subsequences --mhc-peptide-lengths 8-10 --mhc-predictor mhcflurry --mhc-alleles A0201

Python usage

from mhctools import NetMHCpan
# Run NetMHCpan for alleles HLA-A*01:01 and HLA-A*02:01
predictor = NetMHCpan(alleles=["A*02:01", "hla-a0101"])

# scan the short proteins 1L2Y and 1L3Y for epitopes
protein_sequences = {
  "1L2Y": "NLYIQWLKDGGPSSGRPPPS",
  "1L3Y": "ECDTINCERYNGQVCGGPGRGLCFCGKCRCHPGFEGSACQA"
}

binding_predictions = predictor.predict_subsequences(protein_sequences, peptide_lengths=[9])

# flatten binding predictions into a Pandas DataFrame
df = binding_predictions.to_dataframe()

# epitope collection is sorted by percentile rank
# of binding predictions
for binding_prediction in binding_predictions:
    if binding_prediction.affinity < 100:
        print("Strong binder: %s" % (binding_prediction,))

API

The following MHC binding predictors are available in mhctools:

  • MHCflurry: open source predictor installed by default with mhctools, requires the user run mhcflurry-downloads fetch first to download MHCflurry models
  • NetMHC3: requires locally installed version of NetMHC 3.x
  • NetMHC4: requires locally installed version of NetMHC 4.x
  • NetMHC: a wrapper function to automatically use NetMHC3 or NetMHC4 depending on what's installed.
  • NetMHCpan: requires locally installed version of NetMHCpan
  • NetMHCIIpan: requires locally installed version of NetMHCIIpan
  • NetMHCcons: requires locally installed version of NetMHCcons
  • IedbMhcClass1: Uses IEDB's REST API for class I binding predictions.
  • IedbMhcClass2: Uses IEDB's REST API for class II binding predictions.
  • RandomBindingPredictor: Creates binding predictions with random IC50 and percentile rank values.

Every binding predictor is constructed with an alleles argument specifying the HLA type for which to make predictions. Predictions are generated by calling the predict method with a dictionary mapping sequence IDs or names to amino acid sequences.

Additionally there is a module for running the NetChop proteosomal cleavage predictor:

  • NetChop: requires locally installed version of NetChop-3.1

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mhctools-2.0.0.tar.gz (49.5 kB view details)

Uploaded Source

Built Distribution

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

mhctools-2.0.0-py3-none-any.whl (59.3 kB view details)

Uploaded Python 3

File details

Details for the file mhctools-2.0.0.tar.gz.

File metadata

  • Download URL: mhctools-2.0.0.tar.gz
  • Upload date:
  • Size: 49.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for mhctools-2.0.0.tar.gz
Algorithm Hash digest
SHA256 29421d7d71f9d497cb3621b4fb9164e13525201402bfa4334a3053ed45191b18
MD5 8694d05b526eac7ebccfab89c9deb7d3
BLAKE2b-256 546b69c7f9d517ac75c0f69a4720a5b8f4f0144f525186fc958a9238f8b8e850

See more details on using hashes here.

File details

Details for the file mhctools-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: mhctools-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 59.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for mhctools-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a10124cfcd66a90ccdebf81695b73a50a7698420c3956465c6c7d58c8019baf8
MD5 7656de25450104df834018181f4c545e
BLAKE2b-256 deca5fb3e6508d1331df33937548b23995efa59ff3c5f76d4b441e809ed85a91

See more details on using hashes here.

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