def test_netmhc3_stdout():

    netmhc_output = """
NetMHC version 3.4. 9mer predictions using Artificial Neural Networks - Direct. Allele HLA-A02:01.
Strong binder threshold  50 nM. Weak binder threshold score 500 nM



----------------------------------------------------------------------------------------------------
 pos    peptide      logscore affinity(nM) Bind Level    Protein Name     Allele
----------------------------------------------------------------------------------------------------
   0  CFTWNQMNL         0.085        19899                       seq4 HLA-A02:01
--------------------------------------------------------------------------------------------------
   0  SLYNTVATL         0.579           94         WB            seq5 HLA-A02:01
--------------------------------------------------------------------------------------------------
   0  SLYNTVATF         0.289         2186                       seq6 HLA-A02:01
--------------------------------------------------------------------------------------------------



NetMHC version 3.4. 9mer predictions using Artificial Neural Networks - Direct. Allele HLA-A02:03.
Strong binder threshold  50 nM. Weak binder threshold score 500 nM



----------------------------------------------------------------------------------------------------
 pos    peptide      logscore affinity(nM) Bind Level    Protein Name     Allele
----------------------------------------------------------------------------------------------------
   0  SB                0.113        14800                       seq4 HLA-A02:03
--------------------------------------------------------------------------------------------------
   0  SLYNTVATL         0.730           18         SB            seq5 HLA-A02:03
--------------------------------------------------------------------------------------------------
   0  SLYNTVATF         0.493          239         WB            seq6 HLA-A02:03
--------------------------------------------------------------------------------------------------
    """
    fasta_dictionary = {
      "seq4": "CFTWNQMNL",
      "seq5": "SLYNTVATL",
      "seq6": "SLYNTVATF",
    }
    epitope_collection = parse_netmhc3_stdout(
      netmhc_output,
      fasta_dictionary=fasta_dictionary,
      prediction_method_name="netmhc3")
    assert len(epitope_collection) == 2 * len(fasta_dictionary), \
      "Wrong number of binding predictions: %d (expected %d)" % (
        len(epitope_collection), 2 * len(fasta_dictionary))
    for i, entry in enumerate(epitope_collection):
        # make sure both allele's tables get parsed
        assert entry.allele in ('HLA-A*02:01', 'HLA-A*02:03')
        # expect the HIV epitope SLYNTVATL to be a predicted binder for both
        # alleles
        if entry.peptide == "SLYNTVATL":
            assert entry.value < 100
Test parsing of NetMHC output of predictions of HLA-A*02:01
dataset/ETHPy150Open hammerlab/mhctools/test/test_mhc_formats.py/test_netmhc3_stdout