2016-12-02 60 views
0

考虑以下的简单snakefile,这是写在一个run指令文件的尝试创建文件:Snakemake抱怨无法找到它应该在运行指令

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。显然,我没有找到正确的方式告诉蛇,这是我想要规则make_test创建的文件。

我还试图输出语法的以下修改:

误差是相同的。

发生了什么事?

回答

0

我发现这个错误的原因:我只是忘了打开写模式文件:

规则的所有: 输入: “的test.txt”

以下工作:

rule make_test: 
    output: 
     "test.txt" 
    run: 
     with open(output[0], "w") as f: 
      f.write("test") 
相关问题