Accept data about one neoepitope from merge_mhc_peptide_calls and print it to outfile.  This is
    a generic module to reduce code redundancy.

    :param pandas.core.frame neoepitope_info: object containing with allele, pept, pred, core,
           normal_pept, normal_pred
    :param dict peptides: Dict of pepname: pep sequence for all IARS considered
    :param dict pepmap: Dict containing teh contents from the peptide map file.
    :param file outfile: An open file descriptor to the output file
    :param bool netmhc: Does this record correspond to a netmhcIIpan record? These are processed
           differently.

def print_mhc_peptide(neoepitope_info, peptides, pepmap, outfile, netmhc=False):
    """
    Accept data about one neoepitope from merge_mhc_peptide_calls and print it to outfile.  This is
    a generic module to reduce code redundancy.

    :param pandas.core.frame neoepitope_info: object containing with allele, pept, pred, core,
           normal_pept, normal_pred
    :param dict peptides: Dict of pepname: pep sequence for all IARS considered
    :param dict pepmap: Dict containing teh contents from the peptide map file.
    :param file outfile: An open file descriptor to the output file
    :param bool netmhc: Does this record correspond to a netmhcIIpan record? These are processed
           differently.
    """
    if netmhc:
        peptide_names = [neoepitope_info.peptide_name]
    else:
        peptide_names = [x for x, y in peptides.items() if neoepitope_info.pept in y]
    # Convert named tuple to dict so it can be modified
    neoepitope_info = neoepitope_info._asdict()
    # Handle fusion peptides (They are characterized by having all N's as the normal partner)
    if neoepitope_info['normal_pept'] == 'N' * len(neoepitope_info['pept']):
        neoepitope_info['normal_pept'] = neoepitope_info['normal_pred'] = 'NA'
    # For each peptide, append the ensembl gene
    for peptide_name in peptide_names:
        print('{ni[allele]}\t'
              '{ni[pept]}\t'
              '{ni[normal_pept]}\t'
              '{pname}\t'
              '{ni[core]}\t'
              '0\t'
              '{ni[tumor_pred]}\t'
              '{ni[normal_pred]}\t'
              '{pmap}'.format(ni=neoepitope_info, pname=peptide_name,
                                                  pmap=pepmap[peptide_name]), file=outfile)
    return None