def transReadsIter(bamfile, trans, compatible=True, mis=0, sense=True,
    maxNH=None, minMapQ=None, secondary=False, paired=False, flank=0):
    """fetch reads from transcript exons
  """
    chr = bamfile.get_chrname(trans.chr)
    if chr is None:
        return
    if compatible:
        from . import interval
        transitv = interval.trans2interval(trans)
    if flank < 0:
        flank = 0
    used = {}
    for e in trans.exons:
        start, stop = e.start, e.stop
        if flank > 0:
            if start == trans.start:
                start -= flank
                if start < 1:
                    start = 1
            if stop == trans.stop:
                stop += flank
        rds = bamfile.fetch_reads(chr=chr, start=start, stop=stop, maxNH=
            maxNH, minMapQ=minMapQ, secondary=secondary, paired=paired)
        for read in rds:
            if (read.id, read.fragment_start) in used:
                continue
            if sense and read.strand != trans.strand:
                continue
            if read.fragment_start <= e.start or read.fragment_stop >= e.stop:
                used[read.id, read.fragment_start] = 1
            if compatible and not read.isCompatible(transitv=transitv, mis=mis
                ):
                continue
            yield read
