code: def merger(args):
      
      p = OptionParser(merger.__doc__)
      opts, args = p.parse_args(args)
  
      if len(args) != 3:
          sys.exit(not p.print_help())
  
      layout, gkpstore, contigs = args
      fp = open(layout)
      pf = "0"
      iidfile = pf + ".iids"
      for i, row in enumerate(fp):
          logging.debug("Read unitig {0}".format(i))
          fw = open(iidfile, "w")
          layout = row.split("|")
          print("\n".join(layout), file=fw)
          fw.close()
          cmd = "gatekeeper -iid {0}.iids -dumpfasta {0} {1}".format(pf, gkpstore)
          sh(cmd)
  
          fastafile = "{0}.fasta".format(pf)
          newfastafile = "{0}.new.fasta".format(pf)
          format([fastafile, newfastafile, "--sequential=replace", \
                  "--sequentialoffset=1", "--nodesc"])
          fasta([newfastafile])
  
          sh("rm -rf {0}".format(pf))
          cmd = "runCA {0}.frg -p {0} -d {0} consensus=pbutgcns".format(pf)
          cmd += " unitigger=bogart doFragmentCorrection=0 doUnitigSplitting=0"
          sh(cmd)
          outdir = "{0}/9-terminator".format(pf)
  
          cmd = "cat {0}/{1}.ctg.fasta {0}/{1}.deg.fasta {0}/{1}.singleton.fasta"\
                  .format(outdir, pf)
          sh(cmd, outfile=contigs, append=True)
docs: %prog merger layout gkpStore contigs.fasta
  
      Merge reads into one contig.