def ani(fastas, mash_file, sim_threshold, threads):
ANI = Graph()<EOL>for fasta in fastas:<EOL><INDENT>indiv_mash = fasta + '<STR_LIT>'<EOL>if os.path.isfile(indiv_mash):<EOL><INDENT>cmp_file = indiv_mash<EOL><DEDENT>else:<EOL><INDENT>cmp_file = fasta<EOL><DEDENT>mash_cmd = ['<STR_LIT>', '<STR_LIT>', cmp_file, mash_file]<EOL>process = subprocess.Popen(mash_cmd, stdout = subprocess.PIPE)<EOL>for pair in process.communicate()[<NUM_LIT:0>].splitlines():<EOL><INDENT>a, b, dist, p, shared = pair.decode().strip().split()<EOL>a = a.rsplit('<STR_LIT:.>', <NUM_LIT:1>)[<NUM_LIT:0>].rsplit('<STR_LIT:/>', <NUM_LIT:1>)[-<NUM_LIT:1>].rsplit('<STR_LIT>')[<NUM_LIT:0>]<EOL>b = b.rsplit('<STR_LIT:.>', <NUM_LIT:1>)[<NUM_LIT:0>].rsplit('<STR_LIT:/>', <NUM_LIT:1>)[-<NUM_LIT:1>].rsplit('<STR_LIT>')[<NUM_LIT:0>]<EOL>p = float(p)<EOL>similarity = (<NUM_LIT:1> - float(dist)) * <NUM_LIT:100><EOL>if similarity >= sim_threshold:<EOL><INDENT>ANI.add_edge(a, b, si = similarity, pval = p, sharedK = shared)<EOL><DEDENT><DEDENT>process.wait()<EOL><DEDENT>return ANI<EOL>
Use mash to estimate ANI of genomes
Input:
    fastas <list[str]>      -- paths to fasta files
    sim_threshold <float>   -- fractional cutoff % identity for cluster joining
    mash_file <str>         -- pasted sketch file of all fastas being compared
    threads <int>           -- number threads for distance estimation