def cigar_to_intervalpairs(cigar):
cigar_elem_re = re.compile(r"<STR_LIT>")<EOL>ces = [<EOL>CIGARElement(op=md["<STR_LIT>"], len=int(md["<STR_LIT>"]))<EOL>for md in [m.groupdict() for m in cigar_elem_re.finditer(cigar)]<EOL>]<EOL>ips = [None] * len(ces)<EOL>ref_pos = tgt_pos = <NUM_LIT:0><EOL>for i, ce in enumerate(ces):<EOL><INDENT>ips[i] = IntervalPair(<EOL>Interval(ref_pos, ref_pos + ce.ref_len), Interval(tgt_pos, tgt_pos + ce.tgt_len))<EOL>ref_pos += ce.ref_len<EOL>tgt_pos += ce.tgt_len<EOL><DEDENT>return ips<EOL>
For a given CIGAR string, return a list of (Interval,Interval)
    pairs.  The length of the returned list will be equal to the
    number of CIGAR operations