From 0949a61b522b29a89d33f4be9805ccbc31ccfcae Mon Sep 17 00:00:00 2001 From: boasvdp Date: Fri, 23 Feb 2024 11:39:03 +0100 Subject: [PATCH] feat: allow toggling snippy --report flag --- bin/rules/snp_analysis.smk | 3 ++- juno_snp.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/bin/rules/snp_analysis.smk b/bin/rules/snp_analysis.smk index 78ab30c..fb7b807 100644 --- a/bin/rules/snp_analysis.smk +++ b/bin/rules/snp_analysis.smk @@ -79,6 +79,7 @@ rule snp_analysis: basequal=13, maxsoft="x", sample="{sample}", + report=config["snippy"]["report"], shell: """ snippy --cpus {threads} \ @@ -86,7 +87,7 @@ snippy --cpus {threads} \ --ref {input.ref} \ --R1 {input.r1} \ --R2 {input.r2} \ - --report \ + {params.report} \ --prefix {params.sample} \ --force 2>&1>{log} """ diff --git a/juno_snp.py b/juno_snp.py index ab3a724..b223e58 100644 --- a/juno_snp.py +++ b/juno_snp.py @@ -147,6 +147,11 @@ def _add_args_to_parser(self) -> None: choices=["upgma", "nj"], help="Algorithm to use for making the tree. It can be 'upgma' or 'nj' (neighbor-joining). Default is upgma", ) + self.add_argument( + "--snippy-report", + action="store_true", + help="If set, the pipeline will run Snippy with --report option. This requires quite some extra time and storage, especially if there a lot of variants", + ) def _parse_args(self) -> argparse.Namespace: args = super()._parse_args() @@ -160,6 +165,7 @@ def _parse_args(self) -> argparse.Namespace: self.sketch_size: int = args.sketch_size self.mash_threshold: float = args.mash_threshold self.tree_algorithm: str = args.tree_algorithm + self.snippy_report: bool = args.snippy_report self.dryrun: bool = args.dryrun return args @@ -180,6 +186,11 @@ def setup(self) -> None: parameters_dict = yaml.safe_load(f) self.snakemake_config.update(parameters_dict) + if self.snippy_report: + snippy_report_cmd = "--report" + else: + snippy_report_cmd = "" + self.user_parameters = { "input_dir": str(self.input_dir), "output_dir": str(self.output_dir), @@ -200,6 +211,7 @@ def setup(self) -> None: "threshold": self.mash_threshold, }, "tree": {"algorithm": self.tree_algorithm}, + "snippy": {"report": snippy_report_cmd}, }