def read_chain_file(chain_file):
    """Read chain file.

    Create dict chain_id: (start, end)."""
    ret = {}
    f = open(chain_file, "r")
    for line in f:
        if not line.startswith("chain"):
            continue
        line_data = line.rstrip().split()
        start = int(line_data[5])
        end = int(line_data[6])
        chain_id = int(line_data[12])
        ret[chain_id] = (start, end)
    f.close()
    return ret