def find_genus(files, database, threads=<NUM_LIT:12>):
genus_dict = dict()<EOL>tmpdir = str(time.time()).split('<STR_LIT:.>')[-<NUM_LIT:1>]<EOL>if not os.path.isdir(tmpdir):<EOL><INDENT>os.makedirs(tmpdir)<EOL><DEDENT>for file_name, fasta in files.items():<EOL><INDENT>mash.screen(database, fasta,<EOL>threads=threads,<EOL>w='<STR_LIT>',<EOL>i=<NUM_LIT>,<EOL>output_file=os.path.join(tmpdir, '<STR_LIT>'))<EOL>screen_output = mash.read_mash_screen(os.path.join(tmpdir, '<STR_LIT>'))<EOL>try:<EOL><INDENT>os.remove(os.path.join(tmpdir, '<STR_LIT>'))<EOL><DEDENT>except IOError:<EOL><INDENT>pass<EOL><DEDENT>try:<EOL><INDENT>genus = screen_output[<NUM_LIT:0>].query_id.split('<STR_LIT:/>')[-<NUM_LIT:3>]<EOL>if genus == '<STR_LIT>':<EOL><INDENT>genus = '<STR_LIT>'<EOL><DEDENT>genus_dict[file_name] = genus<EOL><DEDENT>except IndexError:<EOL><INDENT>genus_dict[file_name] = '<STR_LIT>'<EOL><DEDENT><DEDENT>shutil.rmtree(tmpdir)<EOL>return genus_dict<EOL>
Uses MASH to find the genus of fasta files.
:param files: File dictionary returned by filer method.
:param database: Path to reduced refseq database sketch.
:param threads: Number of threads to run mash with.
:return: genus_dict: Dictionary of genus for each sample. Will return NA if genus could not be found.