def parse_cigar(cigar):
    """
    parse cigar string into list of operations
      e.g.: 28M1I29M2I6M1I46M ->
        [['28', 'M'], ['1', 'I'], ['29', 'M'], ['2', 'I'], ['6', 'M'], ['1', 'I'], ['46', 'M']]
    """
    cigar = cigar.replace('M', 'M ').replace('I', 'I ').replace('D', 'D ').split()
    cigar = [c.replace('M', ' M').replace('I', ' I').replace('D', ' D').split() for c in cigar]
    return [(int(c[0]), c[1]) for c in cigar]
parse cigar string into list of operations
      e.g.: 28M1I29M2I6M1I46M ->
        [['28', 'M'], ['1', 'I'], ['29', 'M'], ['2', 'I'], ['6', 'M'], ['1', 'I'], ['46', 'M']]