@T.timeit<EOL><INDENT>def _assign_taxonomy_with_diamond(self, base_list, db_search_results,<EOL>graftm_package, graftm_files):<DEDENT>
runner = Diamond(graftm_package.diamond_database_path(),<EOL>self.args.threads,<EOL>self.args.evalue)<EOL>taxonomy_definition = Getaxnseq().read_taxtastic_taxonomy_and_seqinfo(open(graftm_package.taxtastic_taxonomy_path()),<EOL>open(graftm_package.taxtastic_seqinfo_path()))<EOL>results = {}<EOL>for i, search_result in enumerate(db_search_results):<EOL><INDENT>sequence_id_to_hit = {}<EOL>logging.debug("<STR_LIT>" % search_result.hit_fasta())<EOL>diamond_result = runner.run(search_result.hit_fasta(),<EOL>UnpackRawReads.PROTEIN_SEQUENCE_TYPE,<EOL>daa_file_basename=graftm_files.diamond_assignment_output_basename(base_list[i]))<EOL>for res in diamond_result.each([SequenceSearchResult.QUERY_ID_FIELD,<EOL>SequenceSearchResult.HIT_ID_FIELD]):<EOL><INDENT>if res[<NUM_LIT:0>] in sequence_id_to_hit:<EOL><INDENT>if sequence_id_to_hit[res[<NUM_LIT:0>]] != res[<NUM_LIT:1>]:<EOL><INDENT>raise Exception("<STR_LIT>" % res[<NUM_LIT:0>])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>sequence_id_to_hit[res[<NUM_LIT:0>]] = res[<NUM_LIT:1>]<EOL><DEDENT><DEDENT>sequence_id_to_taxonomy = {}<EOL>for seqio in SequenceIO().read_fasta_file(search_result.hit_fasta()):<EOL><INDENT>name = seqio.name<EOL>if name in sequence_id_to_hit:<EOL><INDENT>sequence_id_to_taxonomy[name] = ['<STR_LIT>']+taxonomy_definition[sequence_id_to_hit[name]]<EOL><DEDENT>else:<EOL><INDENT>sequence_id_to_taxonomy[name] = ['<STR_LIT>']<EOL><DEDENT><DEDENT>results[base_list[i]] = sequence_id_to_taxonomy<EOL><DEDENT>return results<EOL>
Run diamond to assign taxonomy

        Parameters
        ----------
        base_list: list of str
            list of sequence block names
        db_search_results: list of DBSearchResult
            the result of running hmmsearches
        graftm_package: GraftMPackage object
            Diamond is run against this database
        graftm_files: GraftMFiles object
            Result files are written here

        Returns
        -------
        list of
        1. time taken for assignment
        2. assignments i.e. dict of base_list entry to dict of read names to
            to taxonomies, or None if there was no hit detected.