code: def filter(args):
      
      p = OptionParser(filter.__doc__)
      p.add_option("--less", default=False, action="store_true",
                   help="filter the sizes < certain cutoff [default: >=]")
      p.set_outfile()
  
      opts, args = p.parse_args(args)
  
      if len(args) != 2:
          sys.exit(not p.print_help())
  
      fastafile, cutoff = args
      try:
          cutoff = int(cutoff)
      except ValueError:
          sys.exit(not p.print_help())
  
      f = Fasta(fastafile, lazy=True)
  
      fw = must_open(opts.outfile, "w")
      for name, rec in f.iteritems_ordered():
  
          if opts.less and len(rec) >= cutoff:
              continue
  
          if (not opts.less) and len(rec) < cutoff:
              continue
  
          SeqIO.write([rec], fw, "fasta")
          fw.flush()
  
      return fw.name
docs: %prog filter fastafile 100
  
      Filter the FASTA file to contain records with size >= or <= certain cutoff.