簡體   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