code: def cigar_to_intervalpairs(cigar):
      
  
      cigar_elem_re = re.compile(r"(?P<len>\d+)(?P<op>[=DIMNX])")
      ces = [
          CIGARElement(op=md["op"], len=int(md["len"]))
          for md in [m.groupdict() for m in cigar_elem_re.finditer(cigar)]
      ]
      ips = [None] * len(ces)
      ref_pos = tgt_pos = 0
      for i, ce in enumerate(ces):
          ips[i] = IntervalPair(
              Interval(ref_pos, ref_pos + ce.ref_len), Interval(tgt_pos, tgt_pos + ce.tgt_len))
          ref_pos += ce.ref_len
          tgt_pos += ce.tgt_len
      return ips
docs: 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