def read_gene_table(f):
    """Read coordinates of genes on genomes.

    Parameters
    ----------
    f : file handle
        Gene table file.

    Returns
    -------
    dict of list of tuple of (int, bool, bool, str)
        Flattened list of gene coordinates per nucleotide.
            Coordinate (nt).
            Whether start (True) or end (False).
            Whether gene (True) or read (False).
            Identifier of gene.

    See Also
    --------
    map_read_gene

    Notes
    -----
    This data structure is central to this algorithm. Starting and ending
    coordinates of each gene are separated and flattened into a sorted list.
    which enables only one round of list traversal for the entire set of genes
    plus reads.
    """
    res = {}
    nucl = None
    for line in f:
        line = line.rstrip('\r\n')

        # ">" or "#" indicates nucleotide name
        if line.startswith(('>', '#')):
            nucl = line[1:].strip()

            # double ">" or "#" indicates genome name
            if not nucl.startswith(('>', '#')):
                res[nucl] = []
        else:
            x = line.split('\t')
            idx = x[0]

            # start and end are based on genome, not gene itself
            start, end = sorted([int(x[1]), int(x[2])])
            res[nucl].extend((
                (start, True, True, idx),
                (end,  False, True, idx)))
    return res