繁体   English   中英

Snakemake抱怨找不到在运行指令中应该创建的文件

[英]Snakemake complains it can't find the file it is supposed to create in a run instruction

考虑以下简单的蛇文件,这是尝试在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")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM