code: def splitread(args):
      
      p = OptionParser(splitread.__doc__)
      p.add_option("-n", dest="n", default=76, type="int",
              help="Split at N-th base position [default: %default]")
      p.add_option("--rc", default=False, action="store_true",
              help="Reverse complement second read [default: %default]")
      opts, args = p.parse_args(args)
  
      if len(args) != 1:
          sys.exit(not p.print_help())
  
      pairsfastq, = args
  
      base = op.basename(pairsfastq).split(".")[0]
      fq1 = base + ".1.fastq"
      fq2 = base + ".2.fastq"
      fw1 = must_open(fq1, "w")
      fw2 = must_open(fq2, "w")
  
      fp = must_open(pairsfastq)
      n = opts.n
      minsize = n * 8 / 5
  
      for name, seq, qual in FastqGeneralIterator(fp):
          if len(seq) < minsize:
              logging.error("Skipping read {0}, length={1}".format(name, len(seq)))
              continue
  
          name = "@" + name
          rec1 = FastqLite(name, seq[:n], qual[:n])
          rec2 = FastqLite(name, seq[n:], qual[n:])
          if opts.rc:
              rec2.rc()
  
          print(rec1, file=fw1)
          print(rec2, file=fw2)
  
      logging.debug("Reads split into `{0},{1}`".format(fq1, fq2))
      fw1.close()
      fw2.close()
docs: %prog splitread fastqfile
  
      Split fastqfile into two read fastqfiles, cut in the middle.