code: def asm(args):
      
      p = OptionParser(asm.__doc__)
      opts, args = p.parse_args(args)
  
      if len(args) != 1:
          sys.exit(p.print_help())
  
      asmfile, = args
      prefix = asmfile.rsplit(".", 1)[0]
      ctgfastafile = prefix + ".ctg.fasta"
      scffastafile = prefix + ".scf.fasta"
      fp = open(asmfile)
      ctgfw = open(ctgfastafile, "w")
      scffw = open(scffastafile, "w")
  
      for rec in iter_records(fp):
          type = rec.type
          if type == "CCO":
              fw = ctgfw
              pp = "ctg"
          elif type == "SCF":
              fw = scffw
              pp = "scf"
          else:
              continue
  
          id = rec.get_field("acc")
          id = id.translate(None, "()").split(",")[0]
          seq = rec.get_field("cns").translate(None, "-")
          s = SeqRecord(Seq(seq), id=pp + id, description="")
          SeqIO.write([s], fw, "fasta")
          fw.flush()
  
      fw.close()
docs: %prog asm asmfile
  
      Extract FASTA sequences from asm reads.