def cigar_read_len(cigar):
    '''
    >>> cigar_read_len(cigar_fromstr('8M'))
    8
    >>> cigar_read_len(cigar_fromstr('8M100N8M'))
    16
    >>> cigar_read_len(cigar_fromstr('8M10I8M'))
    26
    >>> cigar_read_len(cigar_fromstr('8M10D8M'))
    16
    '''

    read_pos = 0

    for op, length in cigar:
        if op == 0:  # M
            read_pos += length
        elif op == 1:  # I
            read_pos += length
        elif op == 2:  # D
            pass
        elif op == 3:  # N
            pass
        elif op == 4:  # S
            read_pos += length
        elif op == 5:  # H
            pass
        elif op == 7:  # =
            read_pos += length
        elif op == 8:  # X
            read_pos += length
        else:
            raise ValueError("Unsupported CIGAR operation: %s" % op)

    return read_pos
dataset/ETHPy150Open ngsutils/ngsutils/ngsutils/bam/__init__.py/cigar_read_len/original