def read_calc_mismatches(read):
    inserts = 0
    deletions = 0
    indels = 0
    edits = int(read.opt('NM'))
    #
    # NM counts the length of indels
    # We really just care about *if* there is an indel, not the size
    #

    for op, length in read.cigar:
        if op == 1:
            inserts += length
            indels += 1
        elif op == 2:
            deletions += length
            indels += 1

    return inserts - deletions + indels - edits
dataset/ETHPy150Open ngsutils/ngsutils/ngsutils/bam/__init__.py/read_calc_mismatches/swapped operands of `-`