nodes: 0, module; 1, function_definition; 2, function_name:assign_reads_to_otus; 3, parameters; 4, block; 5, identifier:original_fasta; 6, identifier:filtered_fasta; 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, expression_statement; 16, comment:# Not sure if I feel confortable using blast as a way to recapitulate; 17, comment:# original read ids....; 18, if_statement; 19, expression_statement; 20, expression_statement; 21, expression_statement; 22, expression_statement; 23, if_statement; 24, expression_statement; 25, return_statement; 26, identifier:output_filepath; 27, None; 28, identifier:log_name; 29, string:"assign_reads_to_otus.log"; 30, identifier:perc_id_blast; 31, float:0.97; 32, identifier:global_alignment; 33, True; 34, identifier:HALT_EXEC; 35, False; 36, identifier:save_intermediate_files; 37, False; 38, identifier:remove_usearch_logs; 39, False; 40, identifier:working_dir; 41, None; 42, comment:""" Uses original fasta file, blasts to assign reads to filtered fasta
  
      original_fasta = filepath to original query fasta
      filtered_fasta = filepath to enumerated, filtered fasta
      output_filepath = output path to clusters (uc) file
      log_name = string specifying output log name
      perc_id_blast = percent ID for blasting original seqs against filtered set
      usersort = Enable if input fasta not sorted by length purposefully, lest
       usearch will raise an error.  In post chimera checked sequences, the seqs
       are sorted by abundance, so this should be set to True.
      HALT_EXEC: Used for debugging app controller
      save_intermediate_files: Preserve all intermediate files created.
      """; 43, not_operator; 44, block; 45, assignment; 46, assignment; 47, assignment; 48, assignment; 49, not_operator; 50, block; 51, assignment; 52, expression_list; 53, identifier:output_filepath; 54, expression_statement; 55, identifier:log_filepath; 56, call; 57, identifier:params; 58, dictionary; 59, identifier:app; 60, call; 61, identifier:data; 62, dictionary; 63, identifier:remove_usearch_logs; 64, expression_statement; 65, identifier:app_result; 66, call; 67, identifier:app_result; 68, identifier:output_filepath; 69, assignment; 70, identifier:join; 71, argument_list; 72, pair; 73, pair; 74, identifier:Usearch; 75, argument_list; 76, pair; 77, pair; 78, pair; 79, assignment; 80, identifier:app; 81, argument_list; 82, pattern_list; 83, call; 84, identifier:working_dir; 85, identifier:log_name; 86, string; 87, identifier:perc_id_blast; 88, string; 89, identifier:global_alignment; 90, identifier:params; 91, keyword_argument; 92, keyword_argument; 93, string; 94, identifier:original_fasta; 95, string; 96, identifier:filtered_fasta; 97, string; 98, identifier:output_filepath; 99, subscript; 100, identifier:log_filepath; 101, identifier:data; 102, identifier:_; 103, identifier:output_filepath; 104, identifier:mkstemp; 105, argument_list; 106, string_content:--id; 107, string_content:--global; 108, identifier:WorkingDir; 109, identifier:working_dir; 110, identifier:HALT_EXEC; 111, identifier:HALT_EXEC; 112, string_content:--query; 113, string_content:--db; 114, string_content:--uc; 115, identifier:data; 116, string; 117, keyword_argument; 118, keyword_argument; 119, string_content:--log; 120, identifier:prefix; 121, string; 122, identifier:suffix; 123, string; 124, string_content:assign_reads_to_otus; 125, string_content:.uc
code: def assign_reads_to_otus(original_fasta,
                           filtered_fasta,
                           output_filepath=None,
                           log_name="assign_reads_to_otus.log",
                           perc_id_blast=0.97,
                           global_alignment=True,
                           HALT_EXEC=False,
                           save_intermediate_files=False,
                           remove_usearch_logs=False,
                           working_dir=None):
      """ Uses original fasta file, blasts to assign reads to filtered fasta
  
      original_fasta = filepath to original query fasta
      filtered_fasta = filepath to enumerated, filtered fasta
      output_filepath = output path to clusters (uc) file
      log_name = string specifying output log name
      perc_id_blast = percent ID for blasting original seqs against filtered set
      usersort = Enable if input fasta not sorted by length purposefully, lest
       usearch will raise an error.  In post chimera checked sequences, the seqs
       are sorted by abundance, so this should be set to True.
      HALT_EXEC: Used for debugging app controller
      save_intermediate_files: Preserve all intermediate files created.
      """
  
      # Not sure if I feel confortable using blast as a way to recapitulate
      # original read ids....
      if not output_filepath:
          _, output_filepath = mkstemp(prefix='assign_reads_to_otus',
                                       suffix='.uc')
  
      log_filepath = join(working_dir, log_name)
  
      params = {'--id': perc_id_blast,
                '--global': global_alignment}
  
      app = Usearch(params, WorkingDir=working_dir, HALT_EXEC=HALT_EXEC)
  
      data = {'--query': original_fasta,
              '--db': filtered_fasta,
              '--uc': output_filepath
              }
  
      if not remove_usearch_logs:
          data['--log'] = log_filepath
  
      app_result = app(data)
  
      return app_result, output_filepath