From 4127d9584f69cdb1ab93a5c3b33f08e5de35a6d7 Mon Sep 17 00:00:00 2001 From: David Koslicki Date: Thu, 19 Oct 2023 13:34:36 -0400 Subject: [PATCH] remove code smells #41 --- run_YACHT.py | 4 +--- tests/test_workflow.py | 10 +++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/run_YACHT.py b/run_YACHT.py index cd5a974..28efc3a 100644 --- a/run_YACHT.py +++ b/run_YACHT.py @@ -57,9 +57,7 @@ ani_thresh = config['ani_thresh'] # Make sure the output can be written to - if os.access(os.path.abspath(os.path.dirname(out_filename)), os.W_OK): - pass - else: + if not os.access(os.path.abspath(os.path.dirname(out_filename)), os.W_OK): raise FileNotFoundError(f"Cannot write to the location: {os.path.abspath(os.path.dirname(out_filename))}.") # check if min_coverage is between 0 and 1 diff --git a/tests/test_workflow.py b/tests/test_workflow.py index f6e81e6..1074caf 100644 --- a/tests/test_workflow.py +++ b/tests/test_workflow.py @@ -74,14 +74,14 @@ def test_incorrect_workflow1(): def test_demo_workflow(): cmd = "cd demo; sourmash sketch dna -f -p k=31,scaled=1000,abund -o sample.sig.zip query_data/query_data.fq" - res = subprocess.run(cmd, shell=True, check=True) + _ = subprocess.run(cmd, shell=True, check=True) cmd = "cd demo; sourmash sketch fromfile ref_paths.csv -p dna,k=31,scaled=1000,abund -o ref.sig.zip --force-output-already-exists" - res = subprocess.run(cmd, shell=True, check=True) + _ = subprocess.run(cmd, shell=True, check=True) cmd = "cd demo; python ../make_training_data_from_sketches.py --force --ref_file ref.sig.zip --ksize 31 --num_threads 1 --ani_thresh 0.95 --prefix 'demo_ani_thresh_0.95' --outdir ./" - res = subprocess.run(cmd, shell=True, check=True) + _ = subprocess.run(cmd, shell=True, check=True) cmd = "cd demo; python ../run_YACHT.py --json demo_ani_thresh_0.95_config.json --sample_file sample.sig.zip --significance 0.99 --num_threads 1 --min_coverage_list 1 0.6 0.2 0.1 --out_filename result.xlsx" - res = subprocess.run(cmd, shell=True, check=True) + _ = subprocess.run(cmd, shell=True, check=True) cmd = "cd demo; python ../srcs/standardize_yacht_output.py --yacht_output result.xlsx --sheet_name min_coverage0.2 --genome_to_taxid toy_genome_to_taxid.tsv --mode cami --sample_name 'MySample' --outfile_prefix cami_result --outdir ./" - res = subprocess.run(cmd, shell=True, check=True) + _ = subprocess.run(cmd, shell=True, check=True)