-
Notifications
You must be signed in to change notification settings - Fork 2
Executing workflows
The easiest way to execute a workflow is to simply run snakemake in the workflow's main directory, which is defined as the directory containing Snakefile. Run this way, Snakemake will execute the workflow implemented in Snakefile using the current directory as working directory (i.e. all paths in rule definitions will be relative to the current directory).
When executed, Snakemake tries to generate a specific output called target, and resolve all dependencies bsaed on this target. By default, the target is the output of the first rule in Snakefile; in this case, the rule cannot contain wildcards, as they could not be resolved. Targets can also be specified in the command-line arguments with the syntax snakemake <target>, which is how we executed examples in the previous sections:
snakemake results/first_step.txt.
With this syntax, a target can be any output that can be generated by any rule in the workflow. You cannot use wildcards in targets.
By default, existing outputs are only generated again if the input of the rule that generates them is newer than them, based on file modification dates. You can force snakemake to generate a target with the following syntax: snakemake --force <target>. To force generate all outputs, use snakemake --forceall.
Sometimes, you want to test your workflow without actually running it. To do so, you can perform a dry-run by running Snakemake with the -n flag: snakemake -n <target>. Snakemake will then display all jobs required to generate the target. To obtain additional information on why a specific job is necessary, run Snakemake will the -r flag (which can be and is usually combined with -n): snakemake -n -r <target>. For each job, Snakemake will print a reason field explaining why the job was required.
Snakemake allows you to visualize the DAG for your workflow. To do so, run Snakemake with the --dag flag: snakemake --dag. The output is not meant to be human-readable; the usual way to visualize the DAG is to generate a graph from this output with the dot software from the Graphviz library. If you installed Snakemake with Conda like recommended, Graphviz will be automatically installed at the same time. To generate a plot of the DAG for your workflow, pipe the output of snakemake --dag to dot and save the output to a file:
snakemake --dag | dot -Tpng > dag.pngThe -T parameter of dot control the plot's format. Available formats are listed here.
- Defining rules
- Rule dependencies
- Wildcards
- Executing workflows
- The expand syntax
- Non-file rule parameters
- Executing Python code