Cornelius Roemer
Cornelius Roemer

Reputation: 7819

Refer to input or output files of another Snakemake rule

How can I programmatically refer to attributes of another Snakemake rule? What do I need to replace <whatever is in test1's input> with, for this to work?

rule test1:
    input: 'a.txt'

rule test2:
    output: <whatever is in test1's input>   <---- ?
    shell: 'touch {output}'

Upvotes: 2

Views: 475

Answers (1)

Cornelius Roemer
Cornelius Roemer

Reputation: 7819

Other rules can be referred to by rules.<rule_name> as explained in the documentation. However, the rule that's referenced needs to come first, that is be defined above the rule that's referencing:

rule test1:
    input: 'a.txt'

rule test2:
    output: rules.test1.input  <---
    shell: 'touch {output}'

Upvotes: 1

Related Questions