Snakemake 抱怨它找不到它应该在 运行 指令中创建的文件
Snakemake complains it can't find the file it is supposed to create in a run instruction
考虑以下简单的 snakefile,它试图在 run
指令中写入文件:
rule all:
input:
"test.txt"
rule make_test:
output:
filename = "test.txt"
run:
with open(output.filename) as f:
f.write("test")
运行 结果如下:
Provided cores: 1
Rules claiming more threads will be scaled down.
Job counts:
count jobs
1 all
1 make_test
2
rule make_test:
output: test.txt
Error in job make_test while creating output file test.txt.
RuleException:
FileNotFoundError in line 10 of /tmp/Snakefile:
[Errno 2] No such file or directory: 'test.txt'
File "/tmp/Snakefile", line 10, in __rule_make_test
Will exit after finishing currently running jobs.
Exiting because a job execution failed. Look above for error message
我对此感到惊讶 FileNotFoundError
。显然,我没有找到正确的方法来告诉 snakemake 这是我希望规则 make_test
创建的文件。
我还尝试了以下输出语法的修改:
rule all:
input:
"test.txt"
rule make_test:
output:
"test.txt"
run:
with open(output[0]) as f:
f.write("test")
还是一样的错误
发生了什么事?
我找到了错误的原因:我只是忘记了以写入模式打开文件:
统治一切:
输入:
"test.txt"
以下作品:
rule make_test:
output:
"test.txt"
run:
with open(output[0], "w") as f:
f.write("test")
考虑以下简单的 snakefile,它试图在 run
指令中写入文件:
rule all:
input:
"test.txt"
rule make_test:
output:
filename = "test.txt"
run:
with open(output.filename) as f:
f.write("test")
运行 结果如下:
Provided cores: 1
Rules claiming more threads will be scaled down.
Job counts:
count jobs
1 all
1 make_test
2
rule make_test:
output: test.txt
Error in job make_test while creating output file test.txt.
RuleException:
FileNotFoundError in line 10 of /tmp/Snakefile:
[Errno 2] No such file or directory: 'test.txt'
File "/tmp/Snakefile", line 10, in __rule_make_test
Will exit after finishing currently running jobs.
Exiting because a job execution failed. Look above for error message
我对此感到惊讶 FileNotFoundError
。显然,我没有找到正确的方法来告诉 snakemake 这是我希望规则 make_test
创建的文件。
我还尝试了以下输出语法的修改:
rule all:
input:
"test.txt"
rule make_test:
output:
"test.txt"
run:
with open(output[0]) as f:
f.write("test")
还是一样的错误
发生了什么事?
我找到了错误的原因:我只是忘记了以写入模式打开文件:
统治一切: 输入: "test.txt"
以下作品:
rule make_test:
output:
"test.txt"
run:
with open(output[0], "w") as f:
f.write("test")