code: def merge(args):
      
      p = OptionParser(merge.__doc__)
      p.add_option("--seq", default=False, action="store_true",
                   help="Print FASTA sequences at the end")
      p.set_outfile()
  
      opts, args = p.parse_args(args)
  
      nargs = len(args)
      if nargs < 1:
          sys.exit(not p.print_help())
  
      if nargs == 1:
          listfile, = args
          fp = open(listfile)
          gffiles = [x.strip() for x in fp]
      else:
          gffiles = args
  
      outfile = opts.outfile
  
      deflines = set()
      fw = must_open(outfile, "w")
      fastarecs = {}
      for gffile in natsorted(gffiles, key=lambda x: op.basename(x)):
          logging.debug(gffile)
          fp = open(gffile)
          for row in fp:
              row = row.rstrip()
              if not row or row[0] == '#':
                  if row == FastaTag:
                      break
                  if row in deflines:
                      continue
                  else:
                      deflines.add(row)
  
              print(row, file=fw)
  
          if not opts.seq:
              continue
  
          f = Fasta(gffile, lazy=True)
          for key, rec in f.iteritems_ordered():
              if key in fastarecs:
                  continue
              fastarecs[key] = rec
  
      if opts.seq:
          print(FastaTag, file=fw)
          SeqIO.write(fastarecs.values(), fw, "fasta")
  
      fw.close()
docs: %prog merge gffiles
  
      Merge several gff files into one. When only one file is given, it is assumed
      to be a file with a list of gff files.