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

This version

2.2.0

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.2.0.tar.gz (51.6 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.2.0-py3-none-any.whl (60.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mhctools-2.2.0.tar.gz
Algorithm Hash digest
SHA256 11dcb6b4de557fe5e82c25547a6ab47c0e27d07f79daac178e7bef0fc374fdc9
MD5 87cf453c417f8e3b07bcb067cb0d2a57
BLAKE2b-256 7ddf963fdc6ffe6924b234b46a767876a03ffb006fc7388fb527c6d2175d91b6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mhctools-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 60.5 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9f35e61d3578653888dc4926c9b281ac343d8c029b4f09841e5223da58f01e2
MD5 a70f8c61dac0ea05320ddb11a19cc86f
BLAKE2b-256 42b0c6338a7c7c36fd2bd6d630c095ff47fdf38282211f3806520f3662c86160

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