/bio-immunoinformatics-mhc-binding-prediction
Predict peptide-MHC class I and II binding affinity using MHCflurry and NetMHCpan neural network models. Identify potential T-cell epitopes from protein sequences. Use when predicting MHC binding for vaccine design or neoantigen identification.
$ npx -y skills add FreedomIntelligence/OpenClaw-Medical-Skills --skill bio-immunoinformatics-mhc-binding-prediction --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/bio-immunoinformatics-mhc-binding-prediction
Context preview
The summary Claude sees to decide when to auto-load this skill.
Predict peptide-MHC class I and II binding affinity using MHCflurry and NetMHCpan neural network models. Identify potential T-cell epitopes from protein sequences. Use when predicting MHC binding for vaccine design or neoantigen identification.
SKILL.md
bio-immunoinformatics-mhc-binding-prediction.SKILL.mdname: bio-immunoinformatics-mhc-binding-prediction
description: Predict peptide-MHC class I and II binding affinity using MHCflurry and NetMHCpan neural network models. Identify potential T-cell epitopes from protein sequences. Use when predicting MHC binding for vaccine design or neoantigen identification.
tool_type: python
primary_tool: mhcflurry
Version Compatibility
Reference examples tested with: MHCflurry 2.1+, pandas 2.2+
Before using code patterns, verify installed versions match. If versions differ:
- Python: `pip show <package>` then `help(module.function)` to check signatures
- CLI: `<tool> --version` then `<tool> --help` to confirm flags
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
MHC Binding Prediction
**"Predict which peptides bind to MHC"** → Predict peptide-MHC class I and II binding affinity using neural network models to identify potential T-cell epitopes from protein sequences.
- Python: `mhcflurry.Class1PresentationPredictor().predict()` for MHC-I
- CLI: `netMHCpan` for alternative MHC-I/II predictions
MHCflurry Setup
**Goal:** Install MHCflurry and download pre-trained prediction models.
**Approach:** Install via pip and fetch model weights for class I pan-allele or specific allele predictions.
# Install MHCflurry
pip install mhcflurry
# Download prediction models
mhcflurry-downloads fetch
# Download models for specific alleles
mhcflurry-downloads fetch models_class1_pan
MHCflurry Python API
**Goal:** Predict peptide-MHC binding affinity and presentation scores for a set of peptides.
**Approach:** Load the Class1PresentationPredictor and call predict() with peptide-allele pairs to obtain IC50, percentile rank, and presentation scores.
from mhcflurry import Class1PresentationPredictor
# Load predictor (includes binding and processing scores)
predictor = Class1PresentationPredictor.load()
# Predict for single allele
result = predictor.predict(
peptides=['SIINFEKL', 'GILGFVFTL', 'NLVPMVATV'],
alleles=['HLA-A*02:01', 'HLA-A*02:01', 'HLA-A*02:01']
)
# Result columns:
# - mhcflurry_affinity: Predicted IC50 (nM)
# - mhcflurry_affinity_percentile: Percentile rank
# - mhcflurry_presentation_score: Combined binding + processing
print(result)Interpret Binding Predictions
**Goal:** Classify peptide-MHC binding strength from predicted IC50 values.
**Approach:** Apply standard affinity thresholds (strong <50nM, moderate <500nM, weak <5000nM) to categorize binding.
def interpret_binding(ic50_nm):
'''Interpret MHC binding affinity
IC50 thresholds (commonly used):
- <50 nM: Strong binder (high confidence epitope)
- 50-500 nM: Moderate binder (potential epitope)
- 500-5000 nM: Weak binder (unlikely epitope)
- >5000 nM: Non-binder
Percentile rank (recommended):
- <0.5%: Strong binder
- 0.5-2%: Moderate binder
- >2%: Weak/non-binder
'''
if ic50_nm < 50:
return 'strong'
elif ic50_nm < 500:
return 'moderate'
elif ic50_nm < 5000:
return 'weak'
else:
return 'non-binder'Batch Prediction
**Goal:** Predict binding for all peptide-allele combinations in a batch.
**Approach:** Iterate over peptide-allele pairs, call MHCflurry for each combination, and concatenate results into a single DataFrame.
from mhcflurry import Class1PresentationPredictor
import pandas as pd
def predict_binding_batch(peptides, alleles):
'''Predict binding for multiple peptides and alleles
Args:
peptides: List of peptide sequences
alleles: List of HLA alleles (4-digit format)
Returns:
DataFrame with predictions for all combinations
'''
predictor = Class1PresentationPredictor.load()
# Create all combinations
results = []
for peptide in peptides:
for allele in alleles:
pred = predictor.predict(
peptides=[peptide],
alleles=[allele]
)
pred['peptide'] = peptide
pred['allele'] = allele
results.append(pred)
return pd.concat(results, ignore_index=True)
# Example usage
peptides = ['SIINFEKL', 'GILGFVFTL', 'NLVPMVATV', 'YMLDLQPETT']
alleles = ['HLA-A*02:01', 'HLA-A*03:01', 'HLA-B*07:02']
predictions = predict_binding_batch(peptides, alleles)
print(predictions[['peptide', 'allele', 'mhcflurry_affinity', 'mhcflurry_affinity_percentile']])Scan Protein Sequence
**Goal:** Identify all potential MHC-I epitopes within a protein by scanning overlapping peptide windows.
**Approach:** Generate all k-mers (8-11aa) from the protein, predict binding for each against target alleles, and retain those below the 2% percentile rank cutoff.
def scan_protein_for_epitopes(protein_seq, alleles, peptide_lengths=[8, 9, 10, 11]):
'''Scan protein for potential MHC epitopes
MHC-I typically binds 8-11mer peptides
Most common: 9-mers
Returns all peptides with predicted binding
'''
from mhcflurry import Class1PresentationPredictor
predictor = Class1PresentationPredictor.load()
epitopes = []
for length in peptide_lengths:
for i in range(len(protein_seq) - length + 1):
peptide = protein_seq[i:i + length]
for allele in alleles:
pred = predictor.predict(peptides=[peptide], alleles=[allele])
if pred['mhcflurry_affinity_percentile'].values[0] < 2.0:
epitopes.append({
'peptide': peptide,
'position': i + 1,
'length': length,
'allele': allele,
'affinity_nM': pred['mhcflurry_affinity'].values[0],
'percentile': pred['mhcflurry_affinity_percentile'].values[0]
})
return pd.DataFrame(eRead more
name: bio-immunoinformatics-mhc-binding-prediction description: Predict peptide-MHC class I and II binding affinity using MHCflurry and NetMHCpan neural network models. Identify potential T-cell epitopes from protein sequences. Use when predicting MHC binding for vaccine design or neoantigen identification. tool_type: python primary_tool: mhcflurry
Version Compatibility
Reference examples tested with: MHCflurry 2.1+, pandas 2.2+
Before using code patterns, verify installed versions match. If versions differ:
- Python: `pip show <package>` then `help(module.function)` to check signatures
- CLI: `<tool> --version` then `<tool> --help` to confirm flags
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
MHC Binding Prediction
**"Predict which peptides bind to MHC"** → Predict peptide-MHC class I and II binding affinity using neural network models to identify potential T-cell epitopes from protein sequences.
- Python: `mhcflurry.Class1PresentationPredictor().predict()` for MHC-I
- CLI: `netMHCpan` for alternative MHC-I/II predictions
MHCflurry Setup
**Goal:** Install MHCflurry and download pre-trained prediction models.
**Approach:** Install via pip and fetch model weights for class I pan-allele or specific allele predictions.
# Install MHCflurry pip install mhcflurry # Download prediction models mhcflurry-downloads fetch # Download models for specific alleles mhcflurry-downloads fetch models_class1_pan
MHCflurry Python API
**Goal:** Predict peptide-MHC binding affinity and presentation scores for a set of peptides.
**Approach:** Load the Class1PresentationPredictor and call predict() with peptide-allele pairs to obtain IC50, percentile rank, and presentation scores.
from mhcflurry import Class1PresentationPredictor
# Load predictor (includes binding and processing scores)
predictor = Class1PresentationPredictor.load()
# Predict for single allele
result = predictor.predict(
peptides=['SIINFEKL', 'GILGFVFTL', 'NLVPMVATV'],
alleles=['HLA-A*02:01', 'HLA-A*02:01', 'HLA-A*02:01']
)
# Result columns:
# - mhcflurry_affinity: Predicted IC50 (nM)
# - mhcflurry_affinity_percentile: Percentile rank
# - mhcflurry_presentation_score: Combined binding + processing
print(result)Interpret Binding Predictions
**Goal:** Classify peptide-MHC binding strength from predicted IC50 values.
**Approach:** Apply standard affinity thresholds (strong <50nM, moderate <500nM, weak <5000nM) to categorize binding.
def interpret_binding(ic50_nm):
'''Interpret MHC binding affinity
IC50 thresholds (commonly used):
- <50 nM: Strong binder (high confidence epitope)
- 50-500 nM: Moderate binder (potential epitope)
- 500-5000 nM: Weak binder (unlikely epitope)
- >5000 nM: Non-binder
Percentile rank (recommended):
- <0.5%: Strong binder
- 0.5-2%: Moderate binder
- >2%: Weak/non-binder
'''
if ic50_nm < 50:
return 'strong'
elif ic50_nm < 500:
return 'moderate'
elif ic50_nm < 5000:
return 'weak'
else:
return 'non-binder'Batch Prediction
**Goal:** Predict binding for all peptide-allele combinations in a batch.
**Approach:** Iterate over peptide-allele pairs, call MHCflurry for each combination, and concatenate results into a single DataFrame.
from mhcflurry import Class1PresentationPredictor
import pandas as pd
def predict_binding_batch(peptides, alleles):
'''Predict binding for multiple peptides and alleles
Args:
peptides: List of peptide sequences
alleles: List of HLA alleles (4-digit format)
Returns:
DataFrame with predictions for all combinations
'''
predictor = Class1PresentationPredictor.load()
# Create all combinations
results = []
for peptide in peptides:
for allele in alleles:
pred = predictor.predict(
peptides=[peptide],
alleles=[allele]
)
pred['peptide'] = peptide
pred['allele'] = allele
results.append(pred)
return pd.concat(results, ignore_index=True)
# Example usage
peptides = ['SIINFEKL', 'GILGFVFTL', 'NLVPMVATV', 'YMLDLQPETT']
alleles = ['HLA-A*02:01', 'HLA-A*03:01', 'HLA-B*07:02']
predictions = predict_binding_batch(peptides, alleles)
print(predictions[['peptide', 'allele', 'mhcflurry_affinity', 'mhcflurry_affinity_percentile']])Scan Protein Sequence
**Goal:** Identify all potential MHC-I epitopes within a protein by scanning overlapping peptide windows.
**Approach:** Generate all k-mers (8-11aa) from the protein, predict binding for each against target alleles, and retain those below the 2% percentile rank cutoff.
def scan_protein_for_epitopes(protein_seq, alleles, peptide_lengths=[8, 9, 10, 11]):
'''Scan protein for potential MHC epitopes
MHC-I typically binds 8-11mer peptides
Most common: 9-mers
Returns all peptides with predicted binding
'''
from mhcflurry import Class1PresentationPredictor
predictor = Class1PresentationPredictor.load()
epitopes = []
for length in peptide_lengths:
for i in range(len(protein_seq) - length + 1):
peptide = protein_seq[i:i + length]
for allele in alleles:
pred = predictor.predict(peptides=[peptide], alleles=[allele])
if pred['mhcflurry_affinity_percentile'].values[0] < 2.0:
epitopes.append({
'peptide': peptide,
'position': i + 1,
'length': length,
'allele': allele,
'affinity_nM': pred['mhcflurry_affinity'].values[0],
'percentile': pred['mhcflurry_affinity_percentile'].values[0]
})
return pd.DataFrame(eThe largest open-source medical AI skill library for OpenClaw.
Other skills on openclaw-medical-skills.
- /aav-vector-design-agent
<!--
Open skill - /adaptyv
Cloud laboratory platform for automated protein testing and validation. Use when designing proteins and needing experimental validation including binding assays, expression testing, thermostability measurements, enzyme activity assays, or protein sequence optimization. Also use
Open skill - /adhd-daily-planner
Time-blind friendly planning, executive function support, and daily structure for ADHD brains. Specializes in realistic time estimation, dopamine-aware task design, and building systems that
Open skill - /aeon
This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations
Open skill - /agent-browser
Browse the web for any task — research topics, read articles, interact with web apps, fill forms, take screenshots, extract data, and test web pages. Use whenever a browser would be useful, not just when the user explicitly asks.
Open skill - /agentd-drug-discovery
<!--
Open skill

