code: def clean(args):
      
      p = OptionParser(clean.__doc__)
      p.add_option("--fancy", default=False, action="store_true",
                   help="Pretty print the sequence [default: %default]")
      p.add_option("--canonical", default=False, action="store_true",
                   help="Use only acgtnACGTN [default: %default]")
      p.set_outfile()
  
      opts, args = p.parse_args(args)
  
      if len(args) != 1:
          sys.exit(not p.print_help())
  
      fastafile, = args
      fw = must_open(opts.outfile, "w")
      if opts.fancy:
          for header, seq in iter_clean_fasta(fastafile):
              print(">" + header, file=fw)
              fancyprint(fw, seq)
  
          return 0
  
      iterator = iter_canonical_fasta if opts.canonical else iter_clean_fasta
  
      for header, seq in iterator(fastafile):
          seq = Seq(seq)
          s = SeqRecord(seq, id=header, description="")
          SeqIO.write([s], fw, "fasta")
docs: %prog clean fastafile
  
      Remove irregular chars in FASTA seqs.