def iterator( infile ):
    ntracks = 0
    while 1:
        line = infile.readline()
        if not line: return
        if line[0] == "#": continue
        if len(line.strip()) == 0: continue
        if line.startswith("track"):
            ntracks += 1
            if ntracks > 1: raise ValueError( "more than one track in %s" % infile)
            continue
        gff = Entry()
        gff.read( line )
        yield gff
a simple iterator over all entries in a file.
dataset/ETHPy150Open CGATOxford/cgat/obsolete/GFF.py/iterator