mhctools
Python interface to MHC binding, presentation, immunogenicity, and antigen processing predictors
What it is and what it does
mhctools wraps multiple published MHC prediction algorithms into a single Python interface, handling peptide-MHC binding affinity, surface presentation likelihood, stability, immunogenicity, antigen processing, and TCR recognition. It abstracts away the differences between underlying predictors (NetMHCpan, MHCflurry, NetCleave, Pepsickle, and others) and returns results as structured PeptideResult objects with consistent accessors for each prediction kind, or as pandas DataFrames for bulk analysis.
The package is designed for immunology and vaccine research workflows: scanning proteins for candidate epitopes, ranking peptides by MHC binding strength and percentile rank, predicting presentation likelihood across multiple HLA alleles, and handling multi-sample cohort predictions where each patient has a different HLA genotype. It supports both single-allele and haplotype-level predictions, with metadata describing whether each prediction kind is MHC-dependent and which MHC class (I or II) it applies to.
Use it for:
- Scan a protein sequence for immunogenic peptides that bind strongly to a patient's HLA alleles.
- Rank candidate neoantigen peptides by predicted MHC-I affinity and presentation likelihood for personalized cancer vaccine design.
- Predict TCR recognition of a peptide-MHC complex using paired CDR3 sequences and allele information.
- Generate flat DataFrames of peptide predictions across multiple samples with different HLA genotypes for cohort analysis.
- Combine multiple prediction kinds (affinity, stability, immunogenicity) to filter and prioritize epitope candidates.
- Integrate MHC predictions into a larger immunoinformatics pipeline alongside variant calling and protein annotation.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Unified Python interface to multiple MHC binding, presentation, immunogenicity, and antigen processing prediction tools, returning structured peptide results with affinity, percentile rank, and other prediction kinds.
Yes. mhctools is actively maintained, has low install friction, carries no known vulnerabilities, and uses a permissive license. It is the standard unified interface for MHC prediction in Python research workflows. Install it if you need to predict peptide-MHC binding, presentation, or immunogenicity; the main gotcha is that some wrapped predictors may require additional model downloads or environment setup beyond the base package.
Install
mhctools on PyPI
pip
pip install mhctoolsuv
uv add mhctoolspoetry
poetry add mhctoolsInstalling mhctools
Before you install
Low install friction; pure Python wheel with no compiled dependencies. Active maintenance: last release 34 days ago, repository at 103 stars, continuous commits. Requires Python >=3.9 and 7 runtime dependencies (numpy, pandas, varcode, pyensembl, sercol, mhcflurry, mhcgnomes), all standard scientific packages.
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions; suitable for research, clinical, and proprietary applications.
Quickstart
from mhctools import NetMHCpan41
predictor = NetMHCpan41(alleles=["HLA-A*02:01", "HLA-B*07:02"])
results = predictor.predict(["SIINFEKL", "GILGFVFTL"])
for r in results:
if r.affinity:
print(f"{r.peptide} IC50={r.affinity.value:.1f}nM")
MHCflurry support requires running `mhcflurry-downloads fetch` after install to download model data.
Verify before relying
- Whether all wrapped predictors (NetMHCpan, MHCflurry, NetMHCstabpan, etc.) are automatically available or require separate installation.
- Performance characteristics and typical runtime for protein scanning across different peptide lengths and allele counts.
- Whether TCR predictor support (NetTCR, Tulip) requires additional environment setup beyond the base install.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 7 — numpy, pandas, varcode, pyensembl, sercol, mhcflurry, mhcgnomes |
| Maintenance | actively maintained — 34 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 105,773/month — #12,680 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mhctools-3.31.5-py3-none-any.whl
Tags
More Bio-Informatics packages
NetworkX provides data structures and…
permissive · top 1,000 on PyPI
biopythonBiopython provides Python tools for…
unclear · top 5,000 on PyPI
firecrawl-pyClient library for the Firecrawl API that…
permissive · top 5,000 on PyPI
intervaltreeA self-balancing interval tree data structure…
permissive · top 5,000 on PyPI
albumentationsAlbumentations applies image transformations to…
permissive · top 5,000 on PyPI
PubChemPyPubChemPy is a Python wrapper around the…
permissive · top 5,000 on PyPI
pyteomicsPyteomics provides Python tools for proteomics…
permissive · top 15,000 on PyPI
datarobot-predictProvides a unified Python interface for making…
permissive · top 15,000 on PyPI
pipebioA Python SDK for the PipeBio cloud platform…
permissive · top 15,000 on PyPI
varcodeVarcode loads and analyzes genomic variant…
permissive · top 15,000 on PyPI
abnumberAbNumber provides Python APIs to number and…
permissive · top 15,000 on PyPI
propkaPROPKA predicts pKa values of ionizable groups…
copyleft · top 15,000 on PyPI
sklearn2pmmlConverts fitted Scikit-Learn pipelines to PMML…
agpl · top 15,000 on PyPI
fair-esmProvides pre-trained transformer protein…
permissive · top 15,000 on PyPI
tmtoolsProvides Python bindings to the TM-align…
copyleft · top 15,000 on PyPI