-
Notifications
You must be signed in to change notification settings - Fork 2
Rule dependencies
The core principle of Snakemake's execution is to compute a Directed Acyclic Graph (DAG) that summarize dependencies between all inputs and outputs required to generate the final desired output. For each job, starting from the jobs generating the final output, Snakemake checks if required inputs exist. If they do not, the software looks for a rule that generates the input; this process is repeated until all dependencies are resolved.
Let us look at this example from the xxx section:
rule first_step:
input:
'data/first_step.tsv'
output:
'results/first_step.txt'
shell:
'cp {input} {output}'According to the rule's definition, the input data/first_step.tsv is required to generate the output results/first_step.txt. In this case, data/first_step.tsv was an original input file for the pipeline, hence it already exists, and the dependency is resolved.
Now, let us define a second rule:
rule second_step:
input:
'results/first_step.txt'
output:
'results/second_step.txt'
shell:
'cat {input} | grep "snakemake" > {output}'- Defining rules
- Rule dependencies
- Wildcards
- Executing workflows
- The expand syntax
- Non-file rule parameters
- Executing Python code