From 0832c2dc3fc297c9da14f229c039fc75dc34bfd4 Mon Sep 17 00:00:00 2001 From: Amandine PERRIN <amandine.perrin@pasteur.fr> Date: Mon, 12 Oct 2020 16:13:26 +0200 Subject: [PATCH] Always get uniq contig IDs with prokka use --centre prokka option --- .../annotate_module/annotation_functions.py | 2 +- .../test_annotation_functions-prokka.py | 26 ++++++++++++------- .../test_annotate/test_format_func.py | 7 ++++- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/PanACoTA/annotate_module/annotation_functions.py b/PanACoTA/annotate_module/annotation_functions.py index 41497d50..beefeeee 100755 --- a/PanACoTA/annotate_module/annotation_functions.py +++ b/PanACoTA/annotate_module/annotation_functions.py @@ -258,7 +258,7 @@ def run_prokka(arguments): # - if outdir exists exists but force, remove this outdir. # So, outdir does not exist -> run prokka cmd = (f"prokka --outdir {prok_dir} --cpus {threads} " - f"--prefix {name} {gpath}") + f"--prefix {name} --centre prokka {gpath}") error = (f"Error while trying to run prokka on {name} from {gpath}") logger.details("Prokka command: " + cmd) prokf = open(prok_logfile, "w") diff --git a/test/test_unit/test_annotate/test_annotation_functions-prokka.py b/test/test_unit/test_annotate/test_annotation_functions-prokka.py index 5195543b..e160d620 100644 --- a/test/test_unit/test_annotate/test_annotation_functions-prokka.py +++ b/test/test_unit/test_annotate/test_annotation_functions-prokka.py @@ -490,9 +490,13 @@ def test_run_prokka_out_exists_force(): # we cannot compare the whole file. with open(out_tbl, "r") as outt: lines = [line.strip() for line in outt.readlines()] - assert ">Feature H561_S27" in lines - assert ">Feature H561_S28" in lines - assert ">Feature H561_S29" in lines + # Check that there are 3 contigs + feature = 0 + for line in lines: + if 'Feature' in line: + feature += 1 + assert feature == 3 + # Check that there are 16 CDS CDS = 0 for line in lines: if "CDS" in line: @@ -512,7 +516,7 @@ def test_run_prokka_out_exists_force(): assert q.get().message == ("Prokka command: prokka " "--outdir test/data/annotate/generated_by_unit-tests/" "H299_H561.fasta-prokkaRes --cpus 2 --prefix test_runprokka_H299 " - "test/data/annotate/genomes/H299_H561.fasta") + "--centre prokka test/data/annotate/genomes/H299_H561.fasta") assert q.get() .message.startswith("End annotating test_runprokka_H299 " "from test/data/annotate/genomes/H299_H561.fasta") @@ -547,9 +551,13 @@ def test_run_prokka_out_doesnt_exist_ok(): # we cannot compare the whole file. with open(out_tbl, "r") as outt: lines = [line.strip() for line in outt.readlines()] - assert ">Feature H561_S27" in lines - assert ">Feature H561_S28" in lines - assert ">Feature H561_S29" in lines + # Check that there are 3 contigs + feature = 0 + for line in lines: + if 'Feature' in line: + feature += 1 + assert feature == 3 + # Check that there are 16 CDS CDS = 0 for line in lines: if "CDS" in line: @@ -566,7 +574,7 @@ def test_run_prokka_out_doesnt_exist_ok(): assert q.get().message == ("Prokka command: prokka " "--outdir test/data/annotate/generated_by_unit-tests/" "H299_H561.fasta-prokkaRes --cpus 2 --prefix test_runprokka_H299 " - "test/data/annotate/genomes/H299_H561.fasta") + "--centre prokka test/data/annotate/genomes/H299_H561.fasta") assert q.get().message.startswith("End annotating") @@ -592,6 +600,6 @@ def test_run_prokka_out_problem_running(): "--outdir test/data/annotate/generated_by_unit-tests/" "H299_H561bis.fasta-prokkaRes --cpus 2 " "--prefix test_runprokka_H299-error " - "test/data/annotate/genomes/H299_H561bis.fasta") + "--centre prokka test/data/annotate/genomes/H299_H561bis.fasta") assert q.get().message == ("Error while trying to run prokka on test_runprokka_H299-error " "from test/data/annotate/genomes/H299_H561bis.fasta") diff --git a/test/test_unit/test_annotate/test_format_func.py b/test/test_unit/test_annotate/test_format_func.py index 727db37d..d7f22623 100755 --- a/test/test_unit/test_annotate/test_format_func.py +++ b/test/test_unit/test_annotate/test_format_func.py @@ -35,7 +35,12 @@ def setup_teardown_module(): - remove directory with generated results """ # utils.init_logger(LOGFILE_BASE, 0, 'test_fastme', verbose=1) - os.mkdir(GENEPATH) + if os.path.isdir(GENEPATH): + content = os.listdir(GENEPATH) + for f in content: + assert f.startswith(".fuse") + else: + os.mkdir(GENEPATH) print("setup") yield -- GitLab