# Path: graftm/sequence_search_results.py
# class SequenceSearchResult:
#     QUERY_FROM_FIELD = 'query_from'
#     QUERY_TO_FIELD = 'query_to'
#     QUERY_LENGTH_FIELD = 'query_length'
#     HIT_FROM_FIELD = 'hit_from'
#     HIT_TO_FIELD = 'hit_to'
#     ALIGNMENT_LENGTH_FIELD = 'alignment_length'
#     ALIGNMENT_BIT_SCORE = 'alignment_bit_score'
#     ALIGNMENT_DIRECTION = 'alignment_direction'
#     HIT_ID_FIELD = 'hit_id'
#     QUERY_ID_FIELD = 'query_id'
#     HMM_NAME_FIELD = 'hmm_name'
#     ACCESSION_ID_FIELD = 'accession_id'
#     PERCENT_ID_FIELD = 'percent_id'
#     MISMATCH_FIELD = "mismatch"
#     EVALUE_FIELD = "evalue"
# 
# 
# 
#     def __init__(self):
#         self.fields = []
#         self.results = []
# 
#     def each(self, field_names):
#         """Iterate over the results, yielding a list for each result, where
#         each element corresponds to the field given in the field_name parameters
# 
#         Parameters
#         ----------
#         field_names: list of str
#             The names of the fields to be returned during iteration
# 
#         Returns
#         -------
#         None
# 
#         Exceptions
#         ----------
#         raises something when a field name is not in self.fields
#         """
#         field_ids = []
#         for f in field_names:
#             # below raises error if the field name is not found, so
#             # don't need to account for that.
#             field_ids.append(self.fields.index(f))
# 
#         for r in self.results:
#             yield([r[i] for i in field_ids])


import logging
from graftm.sequence_search_results import SequenceSearchResult
                [SequenceSearchResult_1, SequenceSearchResult_2, ...]

        base_list: list
            Iterable of the basenames for each sequence file provided to graftM
            e.g.
                [sample_1, sample_2, ...]

        Returns
        -------
        dictionary:
            Contains samples as entries. The value for each sample is another
            dictionary with HMM as the key, and number of hits as values:
                {"sample_1":{HMM_1: 12
                             HMM_2: 35
                             HMM_3: 1258
                             ...}
                 ...
                }

        '''
        logging.debug("Sorting reads into HMMs by bit score")

        run_results = {}

        ########################################################################
        ################## - Sort reads to best hit db - #######################
        for base, results in zip(base_list, results_list): # For each sample
            search_results = {}
            for search in results():
                search_list = list(

# Path: graftm/sequence_search_results.py
# class SequenceSearchResult:
#     QUERY_FROM_FIELD = 'query_from'
#     QUERY_TO_FIELD = 'query_to'
#     QUERY_LENGTH_FIELD = 'query_length'
#     HIT_FROM_FIELD = 'hit_from'
#     HIT_TO_FIELD = 'hit_to'
#     ALIGNMENT_LENGTH_FIELD = 'alignment_length'
#     ALIGNMENT_BIT_SCORE = 'alignment_bit_score'
#     ALIGNMENT_DIRECTION = 'alignment_direction'
#     HIT_ID_FIELD = 'hit_id'
#     QUERY_ID_FIELD = 'query_id'
#     HMM_NAME_FIELD = 'hmm_name'
#     ACCESSION_ID_FIELD = 'accession_id'
#     PERCENT_ID_FIELD = 'percent_id'
#     MISMATCH_FIELD = "mismatch"
#     EVALUE_FIELD = "evalue"
# 
# 
# 
#     def __init__(self):
#         self.fields = []
#         self.results = []
# 
#     def each(self, field_names):
#         """Iterate over the results, yielding a list for each result, where
#         each element corresponds to the field given in the field_name parameters
# 
#         Parameters
#         ----------
#         field_names: list of str
#             The names of the fields to be returned during iteration
# 
#         Returns
#         -------
#         None
# 
#         Exceptions
#         ----------
#         raises something when a field name is not in self.fields
#         """
#         field_ids = []
#         for f in field_names:
#             # below raises error if the field name is not found, so
#             # don't need to account for that.
#             field_ids.append(self.fields.index(f))
# 
#         for r in self.results:
#             yield([r[i] for i in field_ids])


# Path: graftm/search_table.py
import logging
from graftm.sequence_search_results import SequenceSearchResult

                [SequenceSearchResult_1, SequenceSearchResult_2, ...]

        base_list: list
            Iterable of the basenames for each sequence file provided to graftM
            e.g.
                [sample_1, sample_2, ...]

        Returns
        -------
        dictionary:
            Contains samples as entries. The value for each sample is another
            dictionary with HMM as the key, and number of hits as values:
                {"sample_1":{HMM_1: 12
                             HMM_2: 35
                             HMM_3: 1258
                             ...}
                 ...
                }

        '''
        logging.debug("Sorting reads into HMMs by bit score")

        run_results = {}

        ########################################################################
        ################## - Sort reads to best hit db - #######################
        for base, results in zip(base_list, results_list): # For each sample
            search_results = {}
            for search in results():
                search_list = list(

                                   search.each([SequenceSearchResult.QUERY_ID_FIELD,