MHCflurry predicts which peptides are likely to be displayed by MHC class I molecules. Given peptides or protein sequences and MHC class I alleles, its pretrained models predict:
- Binding affinity: how strongly a peptide binds an MHC allele, in nM.
- Antigen processing: whether cellular processing favors the peptide.
- Presentation: a combined score using binding and processing predictions.
You can use the released models from the command line or Python, scan proteins for candidate epitopes, or train models on your own data.
Install MHCflurry 2.3 and download the pretrained presentation models:
pip install --upgrade "mhcflurry>=2.3,<2.4"
mhcflurry downloads fetch models_class1_presentationThe presentation bundle includes the affinity and processing components.
Predict a few peptides:
mhcflurry predict \
--alleles HLA-A0201 HLA-A0301 \
--peptides SIINFEKL SIINFEKD SIINFEKQ \
--out predictions.csvThe output CSV includes predicted binding affinity (nM), affinity percentile, processing score and presentation score columns; the introduction explains how to read them.
Or scan a protein sequence for candidate ligands:
mhcflurry predict-scan \
--sequences MFVFLVLLPLVSSQCVNLTTRTQLPPAYTNSFTRGVYYPDKVFRSSVLHS \
--alleles 'HLA-A*02:01' \
--out scan.csvTo try MHCflurry without installing anything, open the Colab notebook.
- Introduction and installation
- Command-line tutorial
- Python tutorial
- Model weights and older releases:
browse weights with
mhcflurry downloads infoand select one with--model-release. - Evaluation of the 2.3.0 weights
- Training models
- Command reference
- API reference
- Predicted binding motifs
Scripts that use the older mhcflurry-* command names, such as
mhcflurry-predict, keep working; see the
2.3.0 release notes.
Please file an issue if you have questions or encounter problems.
If you use MHCflurry in your research, please cite:
T. O'Donnell, A. Rubinsteyn, U. Laserson. "MHCflurry 2.0: Improved pan-allele prediction of MHC I-presented peptides by incorporating antigen processing," Cell Systems, 2020. https://doi.org/10.1016/j.cels.2020.06.010
T. O'Donnell, A. Rubinsteyn, M. Bonsack, A. B. Riemer, U. Laserson, and J. Hammerbacher, "MHCflurry: Open-Source Class I MHC Binding Affinity Prediction," Cell Systems, 2018. https://doi.org/10.1016/j.cels.2018.05.014
Contributions are welcome. Start with CONTRIBUTING.md; the testing guide describes the fast local checks and full suite.
Docker images built from version 2.3.6 onward include the full presentation weights, the command-line tools and Jupyter notebooks. They run predictions on the CPU and support Intel/AMD and ARM Linux. Check the published image's version with:
docker pull openvax/mhcflurry:latest
docker run --rm openvax/mhcflurry:latest mhcflurry --versionRun predictions against files in the current directory:
docker run --rm -v "$PWD:/work" openvax/mhcflurry:latest \
mhcflurry predict input.csv --out predictions.csvMounted directories must be writable by the container's user (UID 1000).
To start Jupyter, run the image without a command:
docker run --rm -p 127.0.0.1:9999:9999 -v "$PWD:/work" openvax/mhcflurry:latestOpen the localhost URL printed in the logs, including its access token. Without the volume mount, the image starts in a directory containing the example notebooks.
Each stable release publishes a matching version tag. The latest tag is
updated only after both architecture builds pass an offline prediction check,
so an incomplete publication can leave latest on the previous version; see
the Docker workflow
for publication status.
To build images from a checkout:
docker build -t mhcflurry:local .
# Separate image for CUDA training
docker build -f docker/Dockerfile.train -t mhcflurry:train .MHCflurry is released under the Apache License 2.0.