code: def filter(args):
      
      p = OptionParser(filter.__doc__)
      p.add_option("-q", dest="qv", default=20, type="int",
                   help="Minimum quality score to keep [default: %default]")
      p.add_option("-p", dest="pct", default=95, type="int",
                   help="Minimum percent of bases that have [-q] quality "\
                   "[default: %default]")
  
      opts, args = p.parse_args(args)
  
      if len(args) not in (1, 2):
          sys.exit(not p.print_help())
  
      if len(args) == 1:
          r1 = r2 = args[0]
      else:
          r1, r2 = args
  
      qv = opts.qv
      pct = opts.pct
  
      offset = guessoffset([r1])
      qvchar = chr(offset + qv)
      logging.debug("Call base qv >= {0} as good.".format(qvchar))
      outfile = r1.rsplit(".", 1)[0] + ".q{0}.paired.fastq".format(qv)
      fw = open(outfile, "w")
  
      p1fp, p2fp = FastqPairedIterator(r1, r2)
      while True:
          a = list(islice(p1fp, 4))
          if not a:
              break
  
          b = list(islice(p2fp, 4))
          q1 = a[-1].rstrip()
          q2 = b[-1].rstrip()
  
          if isHighQv(q1, qvchar, pct=pct) and isHighQv(q2, qvchar, pct=pct):
              fw.writelines(a)
              fw.writelines(b)
docs: %prog filter paired.fastq
  
      Filter to get high qv reads. Use interleaved format (one file) or paired
      format (two files) to filter on paired reads.