code: def merge(args):
      
      p = OptionParser(merge.__doc__)
      p.set_outdir(outdir="outdir")
      opts, args = p.parse_args(args)
  
      if len(args) < 1:
          sys.exit(not p.print_help())
  
      folders = args
      outdir = opts.outdir
      mkdir(outdir)
  
      files = flatten(glob("{0}/*.*.fastq".format(x)) for x in folders)
      files = list(files)
      key = lambda x: op.basename(x).split(".")[0]
      files.sort(key=key)
      for id, fns in groupby(files, key=key):
          fns = list(fns)
          outfile = op.join(outdir, "{0}.fastq".format(id))
          FileMerger(fns, outfile=outfile).merge(checkexists=True)
docs: %prog merge folder1 ...
  
      Consolidate split contents in the folders. The folders can be generated by
      the split() process and several samples may be in separate fastq files. This
      program merges them.