Skip to content

Solutions: first workflow

2.1 Request one result

No run_app job is needed: output_7.txt already exists and is up to date. The explicit filename replaces the default target for this invocation. Snakemake works backwards from that file; it does not also request all.

2.2 Recover two missing files

snakemake --cores 2 --scheduler greedy --dry-run
snakemake --cores 2 --scheduler greedy
ls output_*.txt

Expect two run_app jobs (for indices 2 and 8), plus the target rule all. The other eight files are reused. The completed directory contains output_0.txt through output_9.txt. Random values can repeat, so a repeated number does not show that the job failed to execute; use the execution log and file existence to check the recovery.

2.3 Extension: twelve results

The first line becomes:

RESULTS = expand("output_{i}.txt", i=range(12))

With the original ten results present, two extra jobs produce output_10.txt and output_11.txt:

snakemake --cores 2 --scheduler greedy --dry-run
snakemake --cores 2 --scheduler greedy
cat output_10.txt output_11.txt

range(12) includes 0 and excludes 12. The output pattern in run_app needs no change: it already describes both new filenames. Changing a target list is different from changing the command that creates each result.

Continue with rules, targets and wildcards.