我使用的是Snakemake 7.23.1版本。 我在 snakemake 中使用模块化,但出现了奇怪的行为。我想寻求您的帮助,以便更深入地了解 snakemake 的工作原理。
我有以下程序:
workflow.smk
rule A:
input: "init.txt"
output: "A.txt"
shell: "touch A.txt"
rule B:
input: "init.txt"
output: "B.txt"
shell: "touch B.txt"
Snakefile
module workflow:
snakefile:
"workflow.smk"
use rule * from workflow
rule C:
input: "A.txt", "B.txt"
output: "C.txt"
shell: "touch C.txt"
有了这个设置,如果我运行
snakemake -j1 -F C
,我会得到以下错误:
AttributeError in file /Users/cayssolm/Desktop/snakemake/Snakefile, line 7:
module 'snakemake.workflow' has no attribute 'rule'
File "/Users/cayssolm/Desktop/snakemake/Snakefile", line 7, in <module>
我找到的唯一解决方案是在
rule C
之前定义use rule * from workflow
,例如:
Snakefile
module workflow:
snakefile:
"workflow.smk"
rule C:
input: "A.txt", "B.txt"
output: "C.txt"
shell: "touch C.txt"
use rule * from workflow
有了这个设置,就可以了。
为什么会有这样的行为?为什么我们需要在
rule C
语句之前定义use rule * from worfklow
?
提前感谢您的帮助!
我希望这个合成器能工作:
Snakefile
module workflow:
snakefile:
"workflow.smk"
use rule * from workflow
rule C:
input: "A.txt", "B.txt"
output: "C.txt"
shell: "touch C.txt"
这似乎没有在任何地方(还)明确记录,但
workflow
是保留名称。在Snakefile
中更改模块名称将导致可执行文件:
module my_workflow:
snakefile:
"workflow.smk"
use rule * from my_workflow
rule C:
input: "A.txt", "B.txt"
output: "C.txt"
shell: "touch C.txt"
已通过this PR添加了相关文档注释。