小编sap*_*pjw的帖子

Snakemake 有没有办法像 GNU Make 中的 `eval` 那样评估动态 Snakefile 结构?

我希望在我的 Snakemake 工作流程中拥有各种动态“快捷方式”(规则名称),而不需要标记文件。我想到的方法与evalGNU Make 中的方法类似,但 Snakemake 似乎无法评估 Snakefile 语法中的变量扩展代码。有办法做到这一点吗?

这是一个简化的示例 Snakefile。我想要一个与每个输出“阶段”相对应的规则名称,现在我必须手动定义它们。想象一下,如果我有更多“阶段”和“步骤”,并且希望有一个规则,如果我添加这些阶段,可以生成所有“b”、“d”或“z”文件。动态定义规则名称比定义每次添加新阶段时更新的每个组合要简洁得多。

stages = ['a', 'b']
steps = [1, 2]

rule all:
    input:
        expand('{stage}{step}_file', stage=stages, step=steps)

rule:
    output:
        touch('{stage}{step}_file')

# Can these two be combined so that I don't have to add more
# rules for each new "stage" above while retaining the shorthand
# rule name corresponding to the stage?
rule a:
    input: expand('a{step}_file', step=steps)

rule b:
    input: expand('b{step}_file', step=steps)
Run Code Online (Sandbox Code Playgroud)

python bash eval gnu-make snakemake

7
推荐指数
1
解决办法
125
查看次数

标签 统计

bash ×1

eval ×1

gnu-make ×1

python ×1

snakemake ×1