首页 > 解决方案 > 如何在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:
       "...."

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

干杯!

标签: pythonworkflowsnakemake

解决方案


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

rule B:
    input:
         in_file = rules.A.output.out_file,
    ...

虽然我更喜欢硬编码文件名,因为它使脚本更具可读性。


推荐阅读