From fef570d1b19510185c1f16bceaca64a93749b194 Mon Sep 17 00:00:00 2001 From: Amandine PERRIN <amandine.perrin@pasteur.fr> Date: Fri, 16 Oct 2020 19:18:19 +0200 Subject: [PATCH] add first test for prepare/only_mash --- .../exp_files/exp_lstinfo_run_only-mash.lst | 2 + .../test_files/test_lstinfo_onlymash.lst | 6 +++ test/test_functional/test_prepare.py | 45 +++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 test/data/prepare/exp_files/exp_lstinfo_run_only-mash.lst create mode 100644 test/data/prepare/test_files/test_lstinfo_onlymash.lst diff --git a/test/data/prepare/exp_files/exp_lstinfo_run_only-mash.lst b/test/data/prepare/exp_files/exp_lstinfo_run_only-mash.lst new file mode 100644 index 00000000..9015579e --- /dev/null +++ b/test/data/prepare/exp_files/exp_lstinfo_run_only-mash.lst @@ -0,0 +1,2 @@ +to_annotate gsize nb_conts L90 +test/data/prepare/genomes/genomes_comparison/ACOC.1019.fna 3050 1 1 diff --git a/test/data/prepare/test_files/test_lstinfo_onlymash.lst b/test/data/prepare/test_files/test_lstinfo_onlymash.lst new file mode 100644 index 00000000..3265e383 --- /dev/null +++ b/test/data/prepare/test_files/test_lstinfo_onlymash.lst @@ -0,0 +1,6 @@ +to_annotate gsize nb_conts L90 +test/data/prepare/genomes/genomes_comparison/ACOC.1019.fna 3050 1 1 +test/data/prepare/genomes/genomes_comparison/ACOR002.0519.fna 3012665 78 17 +test/data/prepare/genomes/genomes_comparison/ACOR001.0519-almost-same.fna 3012665 261 17 +test/data/prepare/genomes/genomes_comparison/ACOR001.0519.fna 3012665 269 17 +test/data/prepare/genomes/genomes_comparison/ACOR001.0519-bis.fna 3012665 269 17 diff --git a/test/test_functional/test_prepare.py b/test/test_functional/test_prepare.py index 44930301..f60f3d72 100644 --- a/test/test_functional/test_prepare.py +++ b/test/test_functional/test_prepare.py @@ -440,3 +440,48 @@ def test_main_norefseq_givendbdir(capsys): tmp_files = glob.glob(os.path.join(GENEPATH, "tmp_files", "*.fna_prepare-split2N.fna")) assert len(tmp_files) == 5 + +def test_only_mash(capsys): + """ + Running only mash step (giving genomes and corresponding LSTINFO file) + """ + NCBI_species = "" + NCBI_taxid = "" + levels = "" + outdir = GENEPATH + tmp_dir = "" + threads = 1 + no_refseq = False + db_dir = "" + only_mash = True + info_file = os.path.join(TEST_DIR, "test_lstinfo_onlymash.lst") + l90 = 100 + nbcont = 999 + cutn = 5 + min_dist = 1e-4 + max_dist = 0.06 + verbose = 1 + quiet = False + prepare.main("cmd", NCBI_species, NCBI_taxid, levels, outdir, tmp_dir, threads, no_refseq, + db_dir, only_mash, info_file, l90, nbcont, cutn, min_dist, max_dist, + verbose, quiet) + out, err = capsys.readouterr() + assert ("You asked to run only mash steps") in err + assert ("You want to run only mash steps. Getting information from " + "test/data/prepare/test_files/test_lstinfo_onlymash.lst") in out + assert ("Found 5 genomes in total") in out + assert ("Computing pairwise distances between all genomes") in out + assert ("Sorting all 5 genomes by quality") in out + assert ("Final number of genomes in dataset: 1") in out + + # Check output files + assert len(os.listdir(os.path.join(outdir, "tmp_files"))) == 0 + # Check logfiles are here + log_files = glob.glob(os.path.join(outdir, "*log*")) + assert len(log_files) == 3 + # Check content of output lstinfo file + out_lst = os.path.join(outdir, "LSTINFO-NA-filtered-0.0001_0.06.txt") + exp_lst = os.path.join(DBDIR, "exp_files", "exp_lstinfo_run_only-mash.lst") + assert tutil.compare_order_content(out_lst, exp_lst) + + -- GitLab