Skip to content

Commit

Permalink
fastANI version capture
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurVM committed Apr 12, 2023
1 parent 126a360 commit c7be492
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
File renamed without changes.
3 changes: 0 additions & 3 deletions src/Afanc/screen/getGenomes.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,12 @@ def getLocalGenomes(out_json, args):
taxID = str(subdict["taxon_id"])
assemblyID = subdict["name"]

print(taxID, assemblyID)

else:
taxID = str(subdict["taxon_id"])
assemblyID = subdict["name"]

species_ID = assemblyID.replace(" ", "_")

print(assembly_dict)
## copy assembly to the bt2 working directory for bt2 db construction
if taxID in assembly_dict:
assembly_path = assembly_dict[taxID][0]
Expand Down
2 changes: 1 addition & 1 deletion src/Afanc/screen/runFuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def makeFinalReport(args, variant_profile, reports):
import json
from os import listdir

from Afanc.utilities.get_versions import get_versions_screen
from Afanc.utilities.getVersions import get_versions_screen

subprocessID = "REPORT"
vprint(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,7 @@ def get_versions_screen():
bt2_stdout, bt2_stderr = command(f"bowtie2 --version", "GET-VERSIONS").run_comm_quiet(1)
version_dict["Bowtie2"] = bt2_stdout.decode().split("\n")[0].split("version ")[1]

fastANI_stdout, fastANI_stderr = command(f"fastANI -v", "GET-VERSIONS").run_comm_quiet(1)
version_dict["fastANI"] = fastANI_stderr.decode().split("\n")[0].split("version ")[1]

return version_dict
12 changes: 7 additions & 5 deletions test/afanc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def run_test(args):
sys.exit(1)

runline = f"afanc screen -o {prefix} -v {args.variants} {args.db} {fq1} {fq2} -c > {prefix}.log"
# print(runline)
print(runline)

if not os.path.exists(prefix):
subprocess.call(runline, shell=True)
Expand Down Expand Up @@ -142,22 +142,24 @@ def get_cluster_hits(hits, truth_val):
names_box = [name for (name, perc) in cluster_box]

if len(cluster_box) == 1:
tophit = cluster_box[0][0].split(" (")[0]
## return a PASS if there is only 1 hit and it is the truth value
if cluster_box[0][0] == truth_val:
if tophit == truth_val:
return "PASS", cluster_box[0][0]
## return a T3 INNACURACY if there is only 1 hit and the species matches the species of the truth value
elif " ".join(cluster_box[0][0].split(" ")[:2]) == " ".join(truth_val.split(" ")[:2]):
elif " ".join(tophit.split(" ")[:2]) == " ".join(truth_val.split(" ")[:2]):
return "TYPE-3 INNACURACY", cluster_box[0][0]
## return a FAIL if there is only 1 hit and it does not match the truth value or its broader species
else:
return "FAIL", cluster_box[0][0]

elif len(cluster_box) > 1:
tophit = cluster_box[0][0].split(" (")[0]
## return a T1 INNACURACY if there are multiple hits but the top one matches the truth value
if cluster_box[0][0] == truth_val:
if tophit == truth_val:
return "TYPE-1 INNACURACY", ",".join(names_box)
## return a T4 INNACURACY if there are multiple hits but the species of the top one matches the species of truth value
elif " ".join(cluster_box[0][0].split(" ")[:2]) == " ".join(truth_val.split(" ")[:2]):
elif " ".join(tophit.split(" ")[:2]) == " ".join(truth_val.split(" ")[:2]):
return "TYPE-4 INNACURACY", ",".join(names_box)
## return a T2 INNACURACY if there are multiple hits and one of the non-top hits matches the truth value
elif truth_val in names_box:
Expand Down

0 comments on commit c7be492

Please sign in to comment.