2016-12-02 88 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") 
相關問題