nodes: 0, module; 1, function_definition; 2, function_name:build_index_sortmerna; 3, parameters; 4, block; 5, identifier:ref_fp; 6, identifier:working_dir; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, return_statement; 13, comment:"""Build a SortMeRNA index for all reference databases.
  
      Parameters
      ----------
      ref_fp: tuple
          filepaths to FASTA reference databases
      working_dir: string
          working directory path where to store the indexed database
  
      Returns
      -------
      all_db: tuple
          filepaths to SortMeRNA indexed reference databases
      """; 14, assignment; 15, call; 16, assignment; 17, identifier:db; 18, identifier:ref_fp; 19, block; 20, identifier:all_db; 21, identifier:logger; 22, call; 23, attribute; 24, argument_list; 25, identifier:all_db; 26, list; 27, expression_statement; 28, expression_statement; 29, expression_statement; 30, expression_statement; 31, expression_statement; 32, expression_statement; 33, if_statement; 34, expression_statement; 35, expression_statement; 36, attribute; 37, argument_list; 38, identifier:logger; 39, identifier:info; 40, binary_operator:'build_index_sortmerna files %s to'
                  ' dir %s' % (ref_fp, working_dir); 41, assignment; 42, assignment; 43, assignment; 44, call; 45, assignment; 46, assignment; 47, not_operator; 48, block; 49, call; 50, call; 51, identifier:logging; 52, identifier:getLogger; 53, identifier:__name__; 54, concatenated_string; 55, tuple; 56, pattern_list; 57, call; 58, identifier:index_basename; 59, subscript; 60, identifier:db_output; 61, call; 62, attribute; 63, argument_list; 64, identifier:params; 65, list; 66, pattern_list; 67, call; 68, comparison_operator:res == 0; 69, expression_statement; 70, expression_statement; 71, expression_statement; 72, expression_statement; 73, raise_statement; 74, attribute; 75, argument_list; 76, attribute; 77, argument_list; 78, string; 79, string; 80, identifier:ref_fp; 81, identifier:working_dir; 82, identifier:fasta_dir; 83, identifier:fasta_filename; 84, identifier:split; 85, argument_list; 86, call; 87, integer:0; 88, identifier:join; 89, argument_list; 90, identifier:logger; 91, identifier:debug; 92, binary_operator:'processing file %s into location %s' % (db, db_output); 93, string; 94, string; 95, binary_operator:'%s,%s' %
                    (db, db_output); 96, string; 97, identifier:working_dir; 98, identifier:sout; 99, identifier:serr; 100, identifier:res; 101, identifier:_system_call; 102, argument_list; 103, identifier:res; 104, integer:0; 105, call; 106, call; 107, call; 108, call; 109, call; 110, identifier:logger; 111, identifier:debug; 112, binary_operator:'file %s indexed' % db; 113, identifier:all_db; 114, identifier:append; 115, identifier:db_output; 116, string_content:build_index_sortmerna files %s to; 117, string_content:dir %s; 118, identifier:db; 119, identifier:splitext; 120, argument_list; 121, identifier:working_dir; 122, identifier:index_basename; 123, string; 124, tuple; 125, string_content:indexdb_rna; 126, string_content:--ref; 127, string; 128, tuple; 129, string_content:--tmpdir; 130, identifier:params; 131, attribute; 132, argument_list; 133, attribute; 134, argument_list; 135, attribute; 136, argument_list; 137, attribute; 138, argument_list; 139, identifier:RuntimeError; 140, argument_list; 141, string; 142, identifier:db; 143, identifier:fasta_filename; 144, string_content:processing file %s into location %s; 145, identifier:db; 146, identifier:db_output; 147, string_content:%s,%s; 148, identifier:db; 149, identifier:db_output; 150, identifier:logger; 151, identifier:error; 152, binary_operator:'Problem running indexdb_rna on file %s to dir %s. '
                           'database not indexed' % (db, db_output); 153, identifier:logger; 154, identifier:debug; 155, binary_operator:'stdout: %s' % sout; 156, identifier:logger; 157, identifier:debug; 158, binary_operator:'stderr: %s' % serr; 159, identifier:logger; 160, identifier:critical; 161, string; 162, binary_operator:'Cannot index database file %s' % db; 163, string_content:file %s indexed; 164, concatenated_string; 165, tuple; 166, string; 167, identifier:sout; 168, string; 169, identifier:serr; 170, string_content:execution halted; 171, string; 172, identifier:db; 173, string; 174, string; 175, identifier:db; 176, identifier:db_output; 177, string_content:stdout: %s; 178, string_content:stderr: %s; 179, string_content:Cannot index database file %s; 180, string_content:Problem running indexdb_rna on file %s to dir %s.; 181, string_content:database not indexed
code: def build_index_sortmerna(ref_fp, working_dir):
      """Build a SortMeRNA index for all reference databases.
  
      Parameters
      ----------
      ref_fp: tuple
          filepaths to FASTA reference databases
      working_dir: string
          working directory path where to store the indexed database
  
      Returns
      -------
      all_db: tuple
          filepaths to SortMeRNA indexed reference databases
      """
      logger = logging.getLogger(__name__)
      logger.info('build_index_sortmerna files %s to'
                  ' dir %s' % (ref_fp, working_dir))
      all_db = []
      for db in ref_fp:
          fasta_dir, fasta_filename = split(db)
          index_basename = splitext(fasta_filename)[0]
          db_output = join(working_dir, index_basename)
          logger.debug('processing file %s into location %s' % (db, db_output))
          params = ['indexdb_rna', '--ref', '%s,%s' %
                    (db, db_output), '--tmpdir', working_dir]
          sout, serr, res = _system_call(params)
          if not res == 0:
              logger.error('Problem running indexdb_rna on file %s to dir %s. '
                           'database not indexed' % (db, db_output))
              logger.debug('stdout: %s' % sout)
              logger.debug('stderr: %s' % serr)
              logger.critical('execution halted')
              raise RuntimeError('Cannot index database file %s' % db)
          logger.debug('file %s indexed' % db)
          all_db.append(db_output)
      return all_db