From a59fe5054461f739fd778a486fa46b1a94066c86 Mon Sep 17 00:00:00 2001 From: Alex Rubinsteyn <alex.rubinsteyn@gmail.com> Date: Tue, 19 Apr 2016 13:35:04 -0400 Subject: [PATCH] added known epitope tests --- mhcflurry/predictor_base.py | 5 +++++ test/test_known_class1_epitopes.py | 30 ++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/mhcflurry/predictor_base.py b/mhcflurry/predictor_base.py index 4b104049..1c6ed73a 100644 --- a/mhcflurry/predictor_base.py +++ b/mhcflurry/predictor_base.py @@ -15,6 +15,7 @@ from collections import defaultdict import numpy as np +from six import string_types from .peptide_encoding import fixed_length_index_encoding from .amino_acid import ( @@ -114,6 +115,10 @@ class PredictorBase(object): amino acid characters. The prediction for a single peptide will be the average of expanded 9mers. """ + if isinstance(peptides, string_types): + raise TypeError("Input must be a list of peptides, not %s : %s" % ( + peptides, type(peptides))) + input_matrix, original_peptide_indices = self.encode_peptides(peptides) # non-9mer peptides get multiple predictions, which are then combined # with the combine_fn argument diff --git a/test/test_known_class1_epitopes.py b/test/test_known_class1_epitopes.py index 8b7ac11e..face8d3a 100644 --- a/test/test_known_class1_epitopes.py +++ b/test/test_known_class1_epitopes.py @@ -1,3 +1,29 @@ -def test_known_class1_epitopes(): - pass +from mhcflurry import Class1BindingPredictor + +def test_MAGE_epitope(): + # Test the A1 MAGE epitope ESDPIVAQY from + # Identification of a Titin-Derived HLA-A1-Presented Peptide + # as a Cross-Reactive Target for Engineered MAGE A3-Directed + # T Cells + model = Class1BindingPredictor.from_allele_name("HLA-A*01:01") + ic50s = model.predict_peptides_ic50(["ESDPIVAQY"]) + print(ic50s) + assert len(ic50s) == 1 + ic50 = ic50s[0] + assert ic50 <= 500 + +def test_HIV_epitope(): + # Test the A2 HIV epitope SLYNTVATL from + # The HIV-1 HLA-A2-SLYNTVATL Is a Help-Independent CTL Epitope + model = Class1BindingPredictor.from_allele_name("HLA-A*02:01") + ic50s = model.predict_peptides_ic50(["SLYNTVATL"]) + print(ic50s) + assert len(ic50s) == 1 + ic50 = ic50s[0] + assert ic50 <= 500 + + +if __name__ == "__main__": + test_MAGE_epitope() + test_HIV_epitope() -- GitLab