让我们看两个snakefiles,一个主文件和一个子工作流程:
./Snakefile:
subworkflow sub:
workdir: "."
snakemake: "subworkflow/Snakefile"
rule all:
input: sub("subresult")
./subworkflow/Snakefile:
rule sub_all:
output: "subresult"
shell: "touch {output}"
这段代码效果很好。现在让我们介绍一个小改动:在主文件中用“./subresult”替换“subresult”:output: "./subresult"
这仍然有效,但是如果我在子工作流程中进行相同的更改,我会得到异常:
MissingRuleException:
No rule to produce subresult
如果我在子工作流规则的输出中指定任何其他子文件夹,则抛出相同的异常:
subworkflow sub:
workdir: "."
snakemake: "subworkflow/Snakefile"
rule all:
input: sub("ANY_PATH/subresult")
rule sub_all:
output: "ANY_PATH/subresult"
shell: "touch {output}"
我想这不是正常行为。我的代码有什么问题吗?有没有办法在子文件夹中指定子工作流程的目标?
OS: Windows + Ming W
Python 3.6.5
Snakemake 5.4.5,5.2
更新:
我尝试了@JeeYem提供的示例,甚至数据子目录也无法在我的系统上运行。经过一番调查后,我发现这是针对Windows或Windows / MinGW组合的特定于平台的问题。下面是有效的代码并显示问题(我留下原始代码进行了评论以进行比较):
文件Snakefile:
subworkflow otherworkflow:
workdir:
"."
snakefile:
"kingmaker.Snakefile"
rule all:
input:
otherworkflow('data/a.txt')
子工作流文件kingmaker.Snakefile:
rule write_file:
output:
#'data/a.txt'
'data\\a.txt'
shell:
#'touch {output}'
'touch data/a.txt'
请注意,我甚至无法在shell部分中使用{output}变量。
我将向Snakemake存储库提交一张票。
根据我的测试,我的猜测是你在./
或/和input
的那些路径的开头使用output
,这是导致问题的原因。我不确定确切的原因,但是snakemake似乎指出了问题的原因(见答案的结尾)。
在我的示例脚本中,如下所示,我可以在两个Snakefiles中使用子目录data
而没有任何问题。但是,如果我使用./data
(即子目录开头的./
),则snakemake无法正常工作。
文件Snakefile
:
subworkflow otherworkflow:
workdir:
"."
snakefile:
"kingmaker.Snakefile"
rule all:
input:
otherworkflow('data/a.txt')
子工作流文件kingmaker.Snakefile
:
rule write_file:
output:
'data/a.txt'
shell:
'touch {output}'
实际上,如果你在输出路径的开头用snakemake -s kingmaker.Snakefile
自行运行子工作流(即../
),那么snakemake强烈反对使用此警告:
Relative file path './data/a.txt' starts with './'.
This is redundant and strongly discouraged.
It can also lead to inconsistent results of the file-matching approach used by Snakemake.
You can simply omit the './' for relative file paths.
我在mac上使用snakemake v5.4.0
。