Snakemake
A workflow tool similar to GNU Make, but with much more power with Python.
Examples
Tips
General
Rerun upon input changes
Snakemake doesn’t automatically rerun rules when input files are added. But the rerun can be triggered by snakemake -n --forcerun $(snakemake --list-input-changes)
There are also --list-code-changes, --lc
, --list-params-changes, --lp
.
script directive
when used, it injects snakemake
variable. For instance, input files can be accessed via snakemake.input[0]
. It is convenient, but it makes the script not technically correct and may make it harder to test.
Temporary & protected output files
You can use temp()
or protected()
in output directive.
Print command
-p
option prints the shell commands. It can be useful for debugging.
Modularization
You can either include another snakefile or use another (complete) Snakefile as a sub-workflow.
Parameterization
See Parameter space exploration
Formatting
snakefmt
There is a package called snakefmt that is derived from Black.
Flake8
To remove the errors/warnings from flake8 about the variable snakemake
that snakemake injects into scripts, you can add to builtins = snakemake
to ~/.config/flake8
or run with the option --builtins=snakemake
.