def generate_tss_flanks(tss, flank_distance: int=1000, flank_size: int=100):
    """Generate coordinates of TSS flanks

    Parameters
    ----------
    tss
        an iterable containing coordinates of TSS's
    flank_distance : int
        distance from tss of outer ends of flanks
    flank_size : int
        size of flanks (for determining average depth)

    Yields
    ------
    tuple
        The coordinates of a TSS flank and the corresponding TSS, in the form:
        chrom, flank_start, flank_end, tss_pos
    """
    for chrom, pos in tss:
        if pos >= flank_distance:
            yield chrom, pos - flank_distance, pos - flank_distance + flank_size, pos
            yield chrom, pos - 1, pos, pos
            yield chrom, pos + flank_distance - flank_size, pos + flank_distance, pos
