def transcript_iterator(gff_iterator, strict=True):
    """iterate over the contents of a gtf file.

    return a list of entries with the same transcript id.

    Any features without a transcript_id will be ignored.

    The entries for the same transcript have to be consecutive
    in the file. If *strict* is set an AssertionError will be
    raised if that is not true.
    """
    last = None
    matches = []
    found = set()

    for gff in gff_iterator:

        # ignore entries without transcript or gene id
        try:
            this = gff.transcript_id + gff.gene_id
        except __HOLE__:
            continue

        if last != this:
            if last:
                yield matches
            matches = []
            assert not strict or this not in found, \
                "duplicate entry: %s" % this
            found.add(this)
            last = this
        matches.append(gff)
    if last:
        yield matches
dataset/ETHPy150Open CGATOxford/cgat/CGAT/GTF.py/transcript_iterator