Skip to content

Commit

Permalink
feat: allow toggling snippy --report flag
Browse files Browse the repository at this point in the history
  • Loading branch information
boasvdp committed Feb 23, 2024
1 parent 7dbea61 commit 0949a61
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bin/rules/snp_analysis.smk
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ rule snp_analysis:
basequal=13,
maxsoft="x",
sample="{sample}",
report=config["snippy"]["report"],
shell:
"""
snippy --cpus {threads} \
--outdir {output.res} \
--ref {input.ref} \
--R1 {input.r1} \
--R2 {input.r2} \
--report \
{params.report} \
--prefix {params.sample} \
--force 2>&1>{log}
"""
Expand Down
12 changes: 12 additions & 0 deletions juno_snp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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),
Expand All @@ -200,6 +211,7 @@ def setup(self) -> None:
"threshold": self.mash_threshold,
},
"tree": {"algorithm": self.tree_algorithm},
"snippy": {"report": snippy_report_cmd},
}


Expand Down

0 comments on commit 0949a61

Please sign in to comment.