def parse_bim_line(line):
    """
    Parse a bim line.
    Format should be: chromosome SNP_name 0 location allele_1 allele_2. allele_1 != allele_2.

    Parameters
    ----------
    line: str
        bim line to parse.

    Returns: tuple
        Dictionary entry with SNP name as key.
    """
    elems = line.translate(None, "\n").split("\t")
    if len(elems) == 1:
        elems = line.translate(None, "\n").split(" ")
    try:
        assert len(elems) == 6
        chromosome = int(elems[0])
        SNP_name = elems[1]
        assert int(elems[2]) == 0, "Third index is not 0"
        location = int(elems[3])
        allele_1 = elems[4]
        assert allele_1 in "TCAG", "Allele not in TCAG"
        allele_2 = elems[5]
        assert allele_2 in "TCAG", "Allele not in TCAG"
        assert allele_1 != allele_2, "Allele 1 and 2 are equal."
    except AssertionError as e:
        raise ValueError("Could not parse bim line \"%s\"(%s)" % (line, e))
    return (SNP_name, {"location": location, "chromosome": chromosome,
                       "allele_1": allele_1, "allele_2": allele_2})