def read_calc_mismatches_gen(ref, read, chrom):
    start = read.pos
    ref_pos = 0
    read_pos = 0

    for op, length in read.cigar:
        if op == 1:
            yield ref_pos, op, None
            read_pos += length
        elif op == 2:
            yield ref_pos, op, None
            ref_pos += length
        elif op == 3:
            ref_pos += length
        elif op == 0:
            refseq = ref.fetch(chrom, start + ref_pos, start + ref_pos + length)
            if not refseq:
                raise ValueError("Reference '%s' not found in FASTA file: %s" % (chrom, ref.filename))
            cur_pos = start + ref_pos
            for refbase, readbase in zip(refseq.upper(), read.seq[read_pos:read_pos + length].upper()):
                if refbase != readbase:
                    yield op, cur_pos, readbase
                cur_pos += 1
            ref_pos += length
            read_pos += length
        else:
            raise ValueError(op % "Unsupported CIGAR operation: %s")
dataset/ETHPy150Open ngsutils/ngsutils/ngsutils/bam/__init__.py/read_calc_mismatches_gen/swapped operands of `%`