import csv


def parse_proteq_file(filename, simplify_protein_names=True):
    """Parse the given protein expression file"""
    # Example:
    # /mnt/e/TCGA-BRCA/b09881e2-d622-4e5c-834a-18b893848de9/mdanderson.org_BRCA.MDA_RPPA_Core.protein_expression.Level_3.F3DF6E4D-CA53-4DEA-B48D-652306B60C77.txt
    with open(filename, 'r') as handle:
        entries = [e for e in csv.DictReader(handle, delimiter='\t')]
    table = {}
    for entry in entries:
        if simplify_protein_names:
            name = entry['Sample REF'].split("-")[0]
            assert len(name) > 0
        else:
            name = entry['Sample REF']
        table[name] = entry
    return table