Skip to main content

Build Status Open In Colab

MHCflurry

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.

Quick start

Install MHCflurry 2.3 and download the pretrained presentation models:

pip install --upgrade "mhcflurry>=2.3,<2.4"
mhcflurry downloads fetch models_class1_presentation

The 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.csv

The 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.csv

To try MHCflurry without installing anything, open the Colab notebook.

Documentation

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.

Citing MHCflurry

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

Development

Contributions are welcome. Start with CONTRIBUTING.md; the testing guide describes the fast local checks and full suite.

Docker

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 --version

Run predictions against files in the current directory:

docker run --rm -v "$PWD:/work" openvax/mhcflurry:latest \
    mhcflurry predict input.csv --out predictions.csv

Mounted 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:latest

Open 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 .

License

MHCflurry is released under the Apache License 2.0.

Metadata

Release files for mhcflurry 2.3.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mhcflurry 2.3.16
File Size Uploaded Provenance
mhcflurry-2.3.16.tar.gz 792.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mhcflurry 2.3.16
File Interpreter ABI Platform
mhcflurry-2.3.16-py3-none-any.whl Python 3 none any Details

Total release size: 1.4 MB

Release files / mhcflurry-2.3.16.tar.gz

Download URL mhcflurry-2.3.16.tar.gz
Size 792.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6782bd3aa8e3ab2cc6922fe131e572894c33936e088d972efb9e19a9d9bf53fe
BLAKE2b-256 checksum
How to use checksums
66a53c1c67b259131d40b7ee68823665dbf6e35cd5a8cc31fbf0f122dcf31179
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Release files / mhcflurry-2.3.16-py3-none-any.whl

Download URL mhcflurry-2.3.16-py3-none-any.whl
Size 578.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cdb7b52395f048531cdace58d16a67e8d82a74878b3d05328b70148091fe2c80
BLAKE2b-256 checksum
How to use checksums
8f649d4217939473219d472b7a45b0bff56bb7bb57c86dfeaed33833d16898f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Security for mhcflurry 2.3.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mhcflurry-2.3.16.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

2.3.16 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page