예제 #1
0
def test_netmhcii_pan_multiple_alleles():
    alleles = [
        normalize_allele_name("HLA-DPA1*01:05-DPB1*100:01"),
        normalize_allele_name("HLA-DQA1*05:11-DQB1*03:02"),
        normalize_allele_name("HLA-DRB1*01:01")
    ]
    ii_pan_predictor = NetMHCIIpan(
        alleles=alleles,
        epitope_lengths=[15, 16])
    fasta_dictionary = {
        "TP53-001": "SQAMDDLMLSPDDIEQWFTED"
    }
    epitope_collection = ii_pan_predictor.predict(
        fasta_dictionary=fasta_dictionary)

    unique_lengths = {x.length for x in epitope_collection}
    eq_(unique_lengths, {15, 16})

    unique_alleles = {x.allele for x in epitope_collection}
    eq_(unique_alleles, {
        "HLA-DPA1*01:05-DPB1*100:01",
        "HLA-DQA1*05:11-DQB1*03:02",
        "HLA-DRB1*01:01"
    })

    # length of "SQAMDDLMLSPDDIEQWFTED" is 21
    # Expect 3 * ((21-15+1) + (21-16+1)) = 39 entries
    assert len(epitope_collection) == 39, \
        "Expected 39 epitopes from %s" % (epitope_collection,)
예제 #2
0
def test_macaque_alleles():
    allele_name = "Mamu-B*082:02"
    eq_(normalize_allele_name(allele_name), "Mamu-B*82:02")
    eq_(compact_allele_name(allele_name), "B8202")

    # expect 3rd zero in the family "007" to be trimmed in the normalized form
    # of this allele
    allele_name = "Mamu-B*007:02"
    eq_(normalize_allele_name(allele_name), "Mamu-B*07:02")
    eq_(compact_allele_name(allele_name), "B0702")
예제 #3
0
def test_mouse_class1_alleles_H2_Db():
    # H2-Db
    eq_(parse_allele_name("H2-Db"),
        AlleleName("H-2", "D", "", "b"))
    eq_(normalize_allele_name("H2-Db"), "H-2-Db")
    eq_(compact_allele_name("H2-Db"), "Db")

    # with hyphen in "H-2"
    eq_(parse_allele_name("H-2-Db"),
        AlleleName("H-2", "D", "", "b"))
    eq_(normalize_allele_name("H-2-Db"), "H-2-Db")
    eq_(compact_allele_name("H-2-Db"), "Db")
예제 #4
0
def test_mouse_class1_alleles_H2_Kk():
    # H2-Kk
    eq_(parse_allele_name("H2-Kk"),
        AlleleName("H-2", "K", "", "k"))
    eq_(normalize_allele_name("H2-Kk"), "H-2-Kk")
    eq_(compact_allele_name("H-2-Kk"), "Kk")

    # with a hyphen in "H-2"
    eq_(parse_allele_name("H-2-Kk"),
        AlleleName("H-2", "K", "", "k"))
    eq_(normalize_allele_name("H-2-Kk"), "H-2-Kk")
    eq_(compact_allele_name("H-2-Kk"), "Kk")
예제 #5
0
def test_mouse_class2_alleles():
    # H2-IAb
    eq_(parse_allele_name("H2-IAb"),
        AlleleName("H-2", "IA", "", "b"))
    eq_(normalize_allele_name("H2-IAb"), "H-2-IAb")
    eq_(compact_allele_name("H2-IAb"), "IAb")

    # with hyphen in "H-2"
    eq_(parse_allele_name("H-2-IAb"),
        AlleleName("H-2", "IA", "", "b"))
    eq_(normalize_allele_name("H-2-IAb"), "H-2-IAb")
    eq_(compact_allele_name("H-2-IAb"), "IAb")
예제 #6
0
def mhc_alleles_from_args(args):
    alleles = [
        normalize_allele_name(allele.strip())
        for allele in args.mhc_alleles.split(",")
        if allele.strip()
    ]
    if args.mhc_alleles_file:
        with open(args.mhc_alleles_file, 'r') as f:
            for line in f:
                line = line.strip()
                if line:
                    alleles.append(normalize_allele_name(line))
    if len(alleles) == 0:
        raise ValueError(
            "MHC alleles required (use --mhc-alleles or --mhc-alleles-file)")
    return alleles
예제 #7
0
def test_netmhc_cons_chunking():
    alleles = [normalize_allele_name(DEFAULT_ALLELE)]
    fasta_dictionary = {
        "SMAD4-001": "ASIINFKELA",
        "TP53-001": "ASILLLVFYW",
        "SMAD4-002": "ASIINFKELS",
        "TP53-002": "ASILLLVFYS",
        "TP53-003": "ASILLLVFYT",
        "TP53-004": "ASILLLVFYG",
        "TP53-005": "ASILLLVFYG"
    }
    for max_file_records in [1, 5, 20]:
        for process_limit in [1, 2, 10]:
            cons_predictor = NetMHCcons(
                alleles=alleles,
                epitope_lengths=[9],
                max_file_records=max_file_records,
                process_limit=process_limit
            )
            epitope_collection = cons_predictor.predict(
                fasta_dictionary=fasta_dictionary)
            assert len(epitope_collection) == 14, \
                "Expected 14 epitopes from %s" % (epitope_collection,)
            source_keys = []
            for epitope in epitope_collection:
                source_keys.append(epitope.source_sequence_key)
            for fasta_key in fasta_dictionary.keys():
                fasta_count = source_keys.count(fasta_key)
                assert fasta_count == 2, \
                    ("Expected each fasta key to appear twice, once for "
                     "each length, but saw %s %d time(s)" % (
                         fasta_key, fasta_count))
예제 #8
0
def test_human_class2_alpha_beta():
    expected = "HLA-DPA1*01:05-DPB1*100:01"
    expected_compact = "DPA10105-DPB110001"
    for name in ["DPA10105-DPB110001",
                 "HLA-DPA1*01:05-DPB1*100:01",
                 "hla-dpa1*0105-dpb1*10001",
                 "dpa1*0105-dpb1*10001",
                 "HLA-DPA1*01:05/DPB1*100:01"]:
        eq_(normalize_allele_name(name), expected)
        eq_(compact_allele_name(name), expected_compact)
예제 #9
0
def test_wrapper_function():
    alleles = [normalize_allele_name("HLA-A*02:01")]
    wrapped_4 = NetMHC(alleles=alleles,
                     epitope_lengths=[9],
                     program_name="netMHC")
    eq_(type(wrapped_4), NetMHC4)
    wrapped_3 = NetMHC(alleles=alleles,
                     epitope_lengths=[9],
                     program_name="netMHC-3.4")
    eq_(type(wrapped_3), NetMHC3)
예제 #10
0
def test_human_class2():
    expected = "HLA-DRB1*01:02"
    expected_compact = "DRB10102"
    for name in ["DRB1_0102",
                 "DRB101:02",
                 "HLA-DRB1_0102",
                 "DRB10102",
                 "DRB1*0102",
                 "HLA-DRB1*0102",
                 "HLA-DRB1*01:02"]:
        eq_(normalize_allele_name(name), expected)
        eq_(compact_allele_name(name), expected_compact)
예제 #11
0
def run_class_with_executable(mhc_class, mhc_executable):
    alleles = [normalize_allele_name("HLA-A*02:01")]
    predictor = mhc_class(
        alleles=alleles,
        epitope_lengths=[9],
        program_name=mhc_executable)
    fasta_dictionary = {
        "SMAD4-001": "ASIINFKELA",
        "TP53-001": "ASILLLVFYW"
    }
    epitope_collection = predictor.predict(
        fasta_dictionary=fasta_dictionary)
예제 #12
0
def test_netmhc_pan():
    alleles = [normalize_allele_name(DEFAULT_ALLELE)]
    pan_predictor = NetMHCpan(
        alleles=alleles,
        epitope_lengths=[9])
    fasta_dictionary = {
        "SMAD4-001": "ASIINFKELA",
        "TP53-001": "ASILLLVFYW"
    }
    epitope_collection = pan_predictor.predict(
        fasta_dictionary=fasta_dictionary)

    assert len(epitope_collection) == 4, \
        "Expected 4 epitopes from %s" % (epitope_collection,)
예제 #13
0
def test_netmhcii_pan_mouse():
    alleles = [normalize_allele_name("H2-IAb")]
    ii_pan_predictor = NetMHCIIpan(
        alleles=alleles,
        epitope_lengths=[15, 16])
    fasta_dictionary = {
        "SMAD4-001": "PAPAPSWPLSSSVPSQKTYQGSYGFRLGFLHSGT",
        "TP53-001": "SQAMDDLMLSPDDIEQWFTED"
    }
    epitope_collection = ii_pan_predictor.predict(
        fasta_dictionary=fasta_dictionary)

    unique_lengths = {x.length for x in epitope_collection}
    eq_(unique_lengths, {15, 16})

    unique_alleles = {x.allele for x in epitope_collection}
    eq_(unique_alleles, {"H-2-IAb"})

    # length of "PAPAPSWPLSSSVPSQKTYQGSYGFRLGFLHSGT" is 34
    # length of "SQAMDDLMLSPDDIEQWFTED" is 21
    # Expect (34-15+1) + (34-16+1) + (21-15+1) + (21-16+1) = 52 entries
    assert len(epitope_collection) == 52, \
        "Expected 52 epitopes from %s" % (epitope_collection,)
예제 #14
0
def test_hla_long_names():
    expected = "HLA-A*02:01"
    for name in hla_02_01_names:
        result = normalize_allele_name(name)
        eq_(result, expected)
예제 #15
0
def test_wrapper_failure():
    alleles = [normalize_allele_name("HLA-A*02:01")]
    NetMHC(alleles=alleles,
           epitope_lengths=[9],
           program_name="netMHC-none")