code: def collapse_umi(in_file):
      
      keep = defaultdict(dict)
      with open_fastq(in_file) as handle:
          for line in handle:
              if line.startswith("@"):
                  m = re.search('UMI_([ATGC]*)', line.strip())
                  umis = m.group(0)
                  seq = handle.next().strip()
                  handle.next()
                  qual = handle.next().strip()
                  if (umis, seq) in keep:
                      keep[(umis, seq)][1].update(qual)
                      keep[(umis, seq)][0].update(seq)
                  else:
                      keep[(umis, seq)] = [umi(seq), quality(qual)]
      logger.info("Sequences loaded: %s" % len(keep))
      return keep
docs: collapse reads using UMI tags