From 5edb7ce11289551706f95cb05bfbb6d731118d13 Mon Sep 17 00:00:00 2001 From: Finlay Maguire Date: Tue, 4 May 2021 16:30:27 -0300 Subject: [PATCH] Add optional configurable output directory for runs --- README.md | 5 +++++ workflow/rules/common.smk | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/README.md b/README.md index ffd1c27..4336262 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,11 @@ completeness_threshold: 0.9 # or the path to a local VCF file. # Built in lists: https://github.com/jts/ncov-watch/tree/master/ncov_watch/watchlists mutation_set: spike_mutations + +# user specifiable output directory +# defaults to just current working directory but otherwise +# will write output files to the specified directory +output_directory: run1_output ``` ## Running diff --git a/workflow/rules/common.smk b/workflow/rules/common.smk index a00704d..a67d34f 100644 --- a/workflow/rules/common.smk +++ b/workflow/rules/common.smk @@ -1,10 +1,22 @@ # # Helper functions and rules # +from pathlib import Path + include: "defaults.smk" configfile: "config.yaml" +# to handle custom output directories make input paths in config absolute +# paths then assign snakemake workdir to the specified config workdir +# as data_root is built into the remaining input paths +if 'output_directory' in config: + for input_path_config in ['data_root', 'primer_bed', 'reference_genome', 'tree_include_consensus']: + if input_path_config in config: + config[input_path_config] = str(Path(config[input_path_config]).absolute()) + workdir: config['output_directory'] + + def get_sample_names(): # if defined in the config, use that