Introduction and installation
MHCflurry predicts which peptides are likely to be displayed by MHC class I molecules. Its pretrained models answer three related questions:
Binding affinity: can this peptide bind a particular MHC allele?
Antigen processing: is cellular processing likely to produce this peptide?
Presentation: is the peptide likely to reach the cell surface, considering both binding and processing?
For most epitope-prioritization work, start with the presentation predictor. Use binding affinity when you specifically need peptide–MHC binding estimates, or processing alone when you do not have an allele or genotype.
The default pan-allele models support most sequenced human MHC I alleles and several other species. GPUs and Apple Silicon (MPS) are optional and are detected automatically.
Install MHCflurry
Install MHCflurry, including prereleases, with:
pip install --upgrade --pre mhcflurry
Omit --pre to install the latest stable release. Older releases may use the
historical mhcflurry-* command names shown in the command reference.
Download the pretrained presentation models:
mhcflurry downloads fetch models_class1_presentation
This bundle includes the binding-affinity and antigen-processing components needed for presentation prediction.
Make a first prediction
mhcflurry predict \
--alleles HLA-A0201 HLA-A0301 \
--peptides SIINFEKL SIINFEKD SIINFEKQ \
--out predictions.csv
Understand the results
The output contains one row per peptide and allele or genotype query. These are the main prediction columns:
Column |
Interpretation |
|---|---|
|
Combined binding and processing score from 0–1; higher is stronger. |
|
Predicted binding affinity in nM; lower is stronger. |
|
Allele-specific rank from 0–100; lower is stronger. |
|
Processing score from 0–1; higher is stronger. |
Separate allele arguments request separate predictions. A delimited allele
list represents one genotype and reports its strongest-binding allele. See
Alleles, genotypes, and samples for examples. Historical mhcflurry-* command
names remain supported for existing scripts.
Where to go next
Command-line tutorial: predict peptides and scan proteins.
Python library tutorial: use predictors from Python.
Training models: fit and select custom models.
Evaluating trained models: compare trained models and generate evaluation figures.
Command-line reference: complete generated command reference.
Configuration and performance: runtime defaults, hardware autosizing, and reproducibility.
Using conda
You can install into a conda environment and then use pip normally:
conda create -q -n mhcflurry-env python=3.10
conda activate mhcflurry-env
pip install --pre mhcflurry
mhcflurry downloads fetch models_class1_presentation
MHCflurry supports Python 3.10+ on Linux and macOS. Windows may work but is not currently part of the supported test matrix.
Getting help and citing MHCflurry
For questions and bug reports, use the GitHub issue tracker.
If you use MHCflurry in research, cite the MHCflurry 2.0 presentation-model paper and the original binding-affinity paper listed in the project README.