import re


def splitCIGAR(SAM_CIGAR):
    """
    Split CIGAR string into list of tuples with format (len,operator)
    """
    CIGARlist = list()
    for x in re.findall('[0-9]*[A-Z|=]',SAM_CIGAR):
        CIGARlist.append((int(re.findall('[0-9]*', x)[0]),re.findall('[A-Z]|=', x)[0]))
    #174M76S --> [(174,M),(76,S)]
    #96S154M --> [(96,S),(154,M)]
    return CIGARlist