def _process_consensus_mhcii(mhc_file, normal=False):
    """
    Process the results from running IEDB MHCII binding predictions using the consensus method into
    a pandas dataframe.

    :param str mhc_file: Output file containing consensus mhcii:peptide binding predictions
    :param bool normal: Is this processing the results of a normal?
    :return: Results in a tabular format
    :rtype: pandas.DataFrame
    """
    core_col = None  # Variable to hold the column number with the core
    results = pandas.DataFrame(columns=['allele', 'pept', 'tumor_pred', 'core'])
    with open(mhc_file, 'r') as mf:
        peptides = set()
        for line in mf:
            # Skip header lines
            if not line.startswith('HLA'):
                continue
            line = line.strip().split('\t')
            allele = line[0]
            pept = line[4]
            pred = line[6]
            if core_col:
                core = line[core_col]
            else:
                methods = line[5].lstrip('Consensus(').rstrip(')')
                methods = methods.split(',')
                if 'NN' in methods:
                    core_col = 13
                elif 'netMHCIIpan' in methods:
                    core_col = 17
                elif 'Sturniolo' in methods:
                    core_col = 19
                elif 'SMM' in methods:
                    core_col = 10
                core = line[core_col] if core_col else 'NOCORE'
            if float(pred) > 5.00 and not normal:
                continue
            results.loc[len(results)] = [allele, pept, pred, core]
    results.drop_duplicates(inplace=True)
    return results
def _process_consensus_mhcii ( mhc_file , normal = False ) : core_col = None results = pandas . DataFrame ( columns = [ 'allele' , 'pept' , 'tumor_pred' , 'core' ] ) with open ( mhc_file , 'r' ) as mf : peptides = set ( ) for line in mf : if not line . startswith ( 'HLA' ) : continue line = line . strip ( ) . split ( '\t' ) allele = line [ 0 ] pept = line [ 4 ] pred = line [ 6 ] if core_col : core = line [ core_col ] else : methods = line [ 5 ] . lstrip ( 'Consensus(' ) . rstrip ( ')' ) methods = methods . split ( ',' ) if 'NN' in methods : core_col = 13 elif 'netMHCIIpan' in methods : core_col = 17 elif 'Sturniolo' in methods : core_col = 19 elif 'SMM' in methods : core_col = 10 core = line [ core_col ] if core_col else 'NOCORE' if float ( pred ) > 5.00 and not normal : continue results . loc [ len ( results ) ] = [ allele , pept , pred , core ] results . drop_duplicates ( inplace = True ) return results
Process the results from running IEDB MHCII binding predictions using the consensus method into
    a pandas dataframe.

    :param str mhc_file: Output file containing consensus mhcii:peptide binding predictions
    :param bool normal: Is this processing the results of a normal?
    :return: Results in a tabular format
    :rtype: pandas.DataFrame