nodes: 0, module; 1, function_definition; 2, function_name:usearch_sort_by_abundance; 3, parameters; 4, block; 5, identifier:fasta_filepath; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 15, default_parameter; 16, expression_statement; 17, if_statement; 18, expression_statement; 19, expression_statement; 20, expression_statement; 21, if_statement; 22, if_statement; 23, if_statement; 24, if_statement; 25, expression_statement; 26, if_statement; 27, comment:# Can have no data following this filter step, which will raise an; 28, comment:# application error, try to catch it here to raise meaningful message.; 29, try_statement; 30, return_statement; 31, identifier:output_filepath; 32, None; 33, identifier:sizein; 34, True; 35, identifier:sizeout; 36, True; 37, identifier:minsize; 38, integer:0; 39, identifier:log_name; 40, string:"abundance_sort.log"; 41, identifier:usersort; 42, False; 43, identifier:HALT_EXEC; 44, False; 45, identifier:save_intermediate_files; 46, False; 47, identifier:remove_usearch_logs; 48, False; 49, identifier:working_dir; 50, None; 51, comment:""" Sorts fasta file by abundance
  
      fasta_filepath = input fasta file, generally a dereplicated fasta
      output_filepath = output abundance sorted fasta filepath
      sizein = not defined in usearch helpstring
      sizeout = not defined in usearch helpstring
      minsize = minimum size of cluster to retain.
      log_name = string to specify log filename
      usersort = Use if not sorting by abundance or usearch will raise an error
      HALT_EXEC: Used for debugging app controller
      save_intermediate_files: Preserve all intermediate files created.
      """; 52, not_operator; 53, block; 54, assignment; 55, assignment; 56, assignment; 57, identifier:usersort; 58, block; 59, identifier:minsize; 60, block; 61, identifier:sizein; 62, block; 63, identifier:sizeout; 64, block; 65, assignment; 66, not_operator; 67, block; 68, block; 69, except_clause; 70, expression_list; 71, identifier:output_filepath; 72, expression_statement; 73, identifier:log_filepath; 74, call; 75, identifier:params; 76, dictionary; 77, identifier:app; 78, call; 79, expression_statement; 80, expression_statement; 81, expression_statement; 82, expression_statement; 83, identifier:data; 84, dictionary; 85, identifier:remove_usearch_logs; 86, expression_statement; 87, expression_statement; 88, identifier:ApplicationError; 89, block; 90, identifier:app_result; 91, identifier:output_filepath; 92, assignment; 93, identifier:join; 94, argument_list; 95, identifier:Usearch; 96, argument_list; 97, call; 98, call; 99, call; 100, call; 101, pair; 102, pair; 103, assignment; 104, assignment; 105, raise_statement; 106, pattern_list; 107, call; 108, identifier:working_dir; 109, binary_operator:"minsize_" + str(minsize) + "_" + log_name; 110, identifier:params; 111, keyword_argument; 112, keyword_argument; 113, attribute; 114, argument_list; 115, attribute; 116, argument_list; 117, attribute; 118, argument_list; 119, attribute; 120, argument_list; 121, string; 122, identifier:fasta_filepath; 123, string; 124, identifier:output_filepath; 125, subscript; 126, identifier:log_filepath; 127, identifier:app_result; 128, call; 129, call; 130, identifier:_; 131, identifier:output_filepath; 132, identifier:mkstemp; 133, argument_list; 134, binary_operator:"minsize_" + str(minsize) + "_"; 135, identifier:log_name; 136, identifier:WorkingDir; 137, identifier:working_dir; 138, identifier:HALT_EXEC; 139, identifier:HALT_EXEC; 140, subscript; 141, identifier:on; 142, subscript; 143, identifier:on; 144, identifier:minsize; 145, subscript; 146, identifier:on; 147, subscript; 148, identifier:on; 149, string_content:--sortsize; 150, string_content:--output; 151, identifier:data; 152, string; 153, identifier:app; 154, argument_list; 155, identifier:ValueError; 156, argument_list; 157, keyword_argument; 158, keyword_argument; 159, binary_operator:"minsize_" + str(minsize); 160, string:"_"; 161, attribute; 162, string; 163, attribute; 164, string; 165, attribute; 166, string; 167, attribute; 168, string; 169, string_content:--log; 170, identifier:data; 171, binary_operator:'No data following filter steps, please check ' +
                           'parameter settings for usearch_qf.'; 172, identifier:prefix; 173, string; 174, identifier:suffix; 175, string; 176, string:"minsize_"; 177, call; 178, identifier:app; 179, identifier:Parameters; 180, string_content:--usersort; 181, identifier:app; 182, identifier:Parameters; 183, string_content:--minsize; 184, identifier:app; 185, identifier:Parameters; 186, string_content:--sizein; 187, identifier:app; 188, identifier:Parameters; 189, string_content:--sizeout; 190, string; 191, string; 192, string_content:usearch_abundance_sorted; 193, string_content:.fasta; 194, identifier:str; 195, argument_list; 196, string_content:No data following filter steps, please check; 197, string_content:parameter settings for usearch_qf.; 198, identifier:minsize
code: def usearch_sort_by_abundance(
          fasta_filepath,
          output_filepath=None,
          sizein=True,
          sizeout=True,
          minsize=0,
          log_name="abundance_sort.log",
          usersort=False,
          HALT_EXEC=False,
          save_intermediate_files=False,
          remove_usearch_logs=False,
          working_dir=None):
      """ Sorts fasta file by abundance
  
      fasta_filepath = input fasta file, generally a dereplicated fasta
      output_filepath = output abundance sorted fasta filepath
      sizein = not defined in usearch helpstring
      sizeout = not defined in usearch helpstring
      minsize = minimum size of cluster to retain.
      log_name = string to specify log filename
      usersort = Use if not sorting by abundance or usearch will raise an error
      HALT_EXEC: Used for debugging app controller
      save_intermediate_files: Preserve all intermediate files created.
      """
      if not output_filepath:
          _, output_filepath = mkstemp(prefix='usearch_abundance_sorted',
                                       suffix='.fasta')
  
      log_filepath = join(
          working_dir,
          "minsize_" + str(minsize) + "_" + log_name)
  
      params = {}
  
      app = Usearch(params, WorkingDir=working_dir, HALT_EXEC=HALT_EXEC)
  
      if usersort:
          app.Parameters['--usersort'].on()
  
      if minsize:
          app.Parameters['--minsize'].on(minsize)
  
      if sizein:
          app.Parameters['--sizein'].on()
  
      if sizeout:
          app.Parameters['--sizeout'].on()
  
      data = {'--sortsize': fasta_filepath,
              '--output': output_filepath
              }
  
      if not remove_usearch_logs:
          data['--log'] = log_filepath
  
      # Can have no data following this filter step, which will raise an
      # application error, try to catch it here to raise meaningful message.
  
      try:
          app_result = app(data)
      except ApplicationError:
          raise ValueError('No data following filter steps, please check ' +
                           'parameter settings for usearch_qf.')
  
      return app_result, output_filepath