def enabled(key):
v = config.get(key, False)
if isinstance(v, str):
return v.lower() in ("yes","y","true","1")
return bool(v)
def all_targets():
targets = [
"results/denoising/read_count_tracking.tsv",
"results/asv/ASVs.fa",
"results/asv/ASVs_counts.tsv",
"results/asv/ASVs_taxonomy.tsv",
"results/phyloseq/starting_phyla_table.tsv",
"results/phyloseq/prevalence_graph.png",
"results/phyloseq/Phyloseq.RData",
"results/phyloseq/ASVs_good.fasta",
"results/phyloseq/plots/plot_1.tiff",
]
if enabled("preprocess"):
targets += [
"results/multiQC/report_R1.html",
"results/multiQC/report_R2.html",
"results/multiQC_trimmed/report_R1.html",
"results/multiQC_trimmed/report_R2.html",
]
if enabled("phylogeny"):
targets += [
"results/phyloseq/ASV_alignment.mafft",
"results/phyloseq/ASV_alignment.mafft.treefile",
]
return targets
rule all:
input: all_targets()
Summary:
Implementation notes / concrete refactor steps (proposed):
config_templates/basic.yamluse YAML booleans (e.g.,preprocess: true,phylogeny: true).enabled(key)helper in theSnakefileto accept multiple truthy formats (strings, integers, booleans).Example:
rule alltargets dynamicallymyoutputlist + manual appends with a functionall_targets()that returns the final target list depending on flags.Example:
ifblocks. Instead define rules always and use theenabled()helper insiderun/shellblocks to branch behavior.intermediate/trimmed/*with a singleprepare_trimmedrule that either runstrim_galoreor copies raw files depending onenabled("preprocess").rules/preprocess.smk,rules/phylogeny.smk, etc., and useif enabled("preprocess"): include: "rules/preprocess.smk". Use this only for large modules to keep the top-levelSnakefiletidy.print()calls from theSnakefile.mkdir -pordirectory()outputs instead of ad-hocmkdirguards.runs/demowithconfig.yamltogglingpreprocessandphylogenyand runsnakemake --configfile runs/demo/config.yaml --directory runs/demo -nto assert the DAG only contains intended targets.Testing / Acceptance checklist for this issue
config_templates/basic.yamlwith boolean flags.enabled()andall_targets()toSnakefile.myoutputusage withall_targets().prepare_trimmedrule.snakemake -nwith permutations of the flags and confirm the DAG and planned jobs match expectations.Notes on scope
Snakefileand possible newconfig_templates/basic.yaml.