def iterator_contigs(gffs):

    last_contig, data = None, []
    found = set()
    for gff in gffs:
        if last_contig != gff.contig:
            if last_contig:
                yield last_contig, data
            last_contig = gff.contig
            assert last_contig not in found, "input not sorted by contig."
            found.add(last_contig)

        data.append(gff)

    if last_contig:
        yield last_contig, data
iterate over contigs.
dataset/ETHPy150Open CGATOxford/cgat/CGAT/GTF.py/iterator_contigs