如何在snakemake中引用规则的输出

nha*_*aus 4 python workflow snakemake

我想知道是否可以直接使用一个规则的输出作为下一个规则的输入,而不必再次指定路径。

我想也许这样的东西会起作用,但在我的测试中却不起作用:

rule A:
    input:
         in_file = "path/to/in_file"

    output:
          out_file = "path/to/out_file"
    shell:
       "...."

rule B:
    input:
         in_file = A.output.out_file # reference the output of rule A doesnt work like this
         # in_file = "path/to/out_file" -> this works but is less elegant i think

    output:
          out_file = "path/to/out_file"
    shell:
       "...."
Run Code Online (Sandbox Code Playgroud)

任何帮助或见解表示赞赏!

干杯!

dar*_*ber 5

也许这就是您正在寻找的语法:

rule B:
    input:
         in_file = rules.A.output.out_file,
    ...
Run Code Online (Sandbox Code Playgroud)

尽管我更喜欢对文件名进行硬编码,因为它使脚本更具可读性。