nodes: 0, module; 1, function_definition; 2, function_name:build; 3, parameters; 4, block; 5, identifier:args; 6, expression_statement; 7, import_from_statement; 8, import_from_statement; 9, import_from_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, if_statement; 14, expression_statement; 15, expression_statement; 16, expression_statement; 17, expression_statement; 18, expression_statement; 19, expression_statement; 20, expression_statement; 21, expression_statement; 22, expression_statement; 23, expression_statement; 24, expression_statement; 25, expression_statement; 26, comment:"""
      %prog build current.fasta Bacteria_Virus.fasta prefix
  
      Build assembly files after a set of clean-ups:
      1. Use cdhit (100%) to remove duplicate scaffolds
      2. Screen against the bacteria and virus database (remove scaffolds 95% id, 50% cov)
      3. Mask matches to UniVec_Core
      4. Sort by decreasing scaffold sizes
      5. Rename the scaffolds sequentially
      6. Build the contigs by splitting scaffolds at gaps
      7. Rename the contigs sequentially
      """; 27, dotted_name; 28, dotted_name; 29, dotted_name; 30, dotted_name; 31, dotted_name; 32, dotted_name; 33, assignment; 34, call; 35, assignment; 36, comparison_operator:len(args) != 3; 37, block; 38, assignment; 39, assignment; 40, assignment; 41, assignment; 42, assignment; 43, assignment; 44, call; 45, assignment; 46, assignment; 47, call; 48, assignment; 49, call; 50, identifier:jcvi; 51, identifier:apps; 52, identifier:cdhit; 53, identifier:deduplicate; 54, identifier:jcvi; 55, identifier:apps; 56, identifier:vecscreen; 57, identifier:mask; 58, identifier:jcvi; 59, identifier:formats; 60, identifier:fasta; 61, identifier:sort; 62, identifier:p; 63, call; 64, attribute; 65, argument_list; 66, pattern_list; 67, call; 68, call; 69, integer:3; 70, expression_statement; 71, pattern_list; 72, identifier:args; 73, identifier:dd; 74, conditional_expression:deduplicate([fastafile, "--pctid=100"]) \
                  if not opts.nodedup else fastafile; 75, identifier:screenfasta; 76, call; 77, identifier:tidyfasta; 78, call; 79, identifier:sortedfasta; 80, call; 81, identifier:scaffoldfasta; 82, binary_operator:pf + ".assembly.fasta"; 83, identifier:format; 84, argument_list; 85, identifier:gapsplitfasta; 86, binary_operator:pf + ".gapSplit.fasta"; 87, identifier:cmd; 88, call; 89, identifier:sh; 90, argument_list; 91, identifier:contigsfasta; 92, binary_operator:pf + ".contigs.fasta"; 93, identifier:format; 94, argument_list; 95, identifier:OptionParser; 96, argument_list; 97, identifier:p; 98, identifier:add_option; 99, string:"--nodedup"; 100, keyword_argument; 101, keyword_argument; 102, keyword_argument; 103, identifier:opts; 104, identifier:args; 105, attribute; 106, argument_list; 107, identifier:len; 108, argument_list; 109, call; 110, identifier:fastafile; 111, identifier:bacteria; 112, identifier:pf; 113, call; 114, line_continuation:\; 115, not_operator; 116, identifier:fastafile; 117, identifier:screen; 118, argument_list; 119, identifier:mask; 120, argument_list; 121, identifier:sort; 122, argument_list; 123, identifier:pf; 124, string:".assembly.fasta"; 125, list; 126, identifier:pf; 127, string:".gapSplit.fasta"; 128, attribute; 129, argument_list; 130, identifier:cmd; 131, identifier:pf; 132, string:".contigs.fasta"; 133, list; 134, attribute; 135, identifier:default; 136, False; 137, identifier:action; 138, string:"store_true"; 139, identifier:help; 140, string:"Do not deduplicate [default: deduplicate]"; 141, identifier:p; 142, identifier:parse_args; 143, identifier:args; 144, identifier:args; 145, attribute; 146, argument_list; 147, identifier:deduplicate; 148, argument_list; 149, attribute; 150, list; 151, list; 152, list; 153, identifier:sortedfasta; 154, identifier:scaffoldfasta; 155, string:"--prefix=scaffold_"; 156, string:"--sequential"; 157, string:"gapSplit -minGap=10 {0} {1}"; 158, identifier:format; 159, identifier:scaffoldfasta; 160, identifier:gapsplitfasta; 161, identifier:gapsplitfasta; 162, identifier:contigsfasta; 163, string:"--prefix=contig_"; 164, string:"--sequential"; 165, identifier:build; 166, identifier:__doc__; 167, identifier:sys; 168, identifier:exit; 169, not_operator; 170, list; 171, identifier:opts; 172, identifier:nodedup; 173, identifier:dd; 174, identifier:bacteria; 175, identifier:screenfasta; 176, identifier:tidyfasta; 177, string:"--sizes"; 178, call; 179, identifier:fastafile; 180, string:"--pctid=100"; 181, attribute; 182, argument_list; 183, identifier:p; 184, identifier:print_help
code: def build(args):
      """
      %prog build current.fasta Bacteria_Virus.fasta prefix
  
      Build assembly files after a set of clean-ups:
      1. Use cdhit (100%) to remove duplicate scaffolds
      2. Screen against the bacteria and virus database (remove scaffolds 95% id, 50% cov)
      3. Mask matches to UniVec_Core
      4. Sort by decreasing scaffold sizes
      5. Rename the scaffolds sequentially
      6. Build the contigs by splitting scaffolds at gaps
      7. Rename the contigs sequentially
      """
      from jcvi.apps.cdhit import deduplicate
      from jcvi.apps.vecscreen import mask
      from jcvi.formats.fasta import sort
  
      p = OptionParser(build.__doc__)
      p.add_option("--nodedup", default=False, action="store_true",
                   help="Do not deduplicate [default: deduplicate]")
      opts, args = p.parse_args(args)
  
      if len(args) != 3:
          sys.exit(not p.print_help())
  
      fastafile, bacteria, pf = args
      dd = deduplicate([fastafile, "--pctid=100"]) \
                  if not opts.nodedup else fastafile
      screenfasta = screen([dd, bacteria])
      tidyfasta = mask([screenfasta])
      sortedfasta = sort([tidyfasta, "--sizes"])
      scaffoldfasta = pf + ".assembly.fasta"
      format([sortedfasta, scaffoldfasta, "--prefix=scaffold_", "--sequential"])
      gapsplitfasta = pf + ".gapSplit.fasta"
      cmd = "gapSplit -minGap=10 {0} {1}".format(scaffoldfasta, gapsplitfasta)
      sh(cmd)
      contigsfasta = pf + ".contigs.fasta"
      format([gapsplitfasta, contigsfasta, "--prefix=contig_", "--sequential"])