Snakemake:如何在没有明确输出文件且仅使用指定输入和日志文件的情况下创建规则?
Snakemake: how to create rule without explicit output file, and only with specified input, and log files?
我想创建一个 Snakemake 规则,其中有:输入、日志、shell 部分。没有输出,我只想作为命令的结果来捕获日志。
只要告诉Snakemake日志文件就是输出:
rule myrule:
input: "myfile.txt"
output: "logfile.log"
shell: "mycommand {input} > {output}"
您可以跳过 output:
,只在规则中使用 log:
。这些日志文件可以用作目标或作为其他规则的输入。 As per the doc:
Log files can be used as input for other rules, just like any other output file. However, unlike output files, log files are not deleted upon error. This is obviously necessary in order to discover causes of errors which might become visible in the log file.
所以代码看起来像:
rule some_rule:
input: "a.txt"
log: "a.log"
shell: "mycommand {input} > {log}"
这里的优点是,与 output
文件不同,日志文件将在作业失败时保留。然而,这个优点也是一个缺点,因为如果你重新运行管道,snakemake 将不会重新运行失败的作业,因为规则的输出文件(即这里的日志文件)已经存在。因此,除非在作业失败时保留日志很重要,否则 Maarten-vd-Sande.
建议的解决方案可能会更好地为您服务
我想创建一个 Snakemake 规则,其中有:输入、日志、shell 部分。没有输出,我只想作为命令的结果来捕获日志。
只要告诉Snakemake日志文件就是输出:
rule myrule:
input: "myfile.txt"
output: "logfile.log"
shell: "mycommand {input} > {output}"
您可以跳过 output:
,只在规则中使用 log:
。这些日志文件可以用作目标或作为其他规则的输入。 As per the doc:
Log files can be used as input for other rules, just like any other output file. However, unlike output files, log files are not deleted upon error. This is obviously necessary in order to discover causes of errors which might become visible in the log file.
所以代码看起来像:
rule some_rule:
input: "a.txt"
log: "a.log"
shell: "mycommand {input} > {log}"
这里的优点是,与 output
文件不同,日志文件将在作业失败时保留。然而,这个优点也是一个缺点,因为如果你重新运行管道,snakemake 将不会重新运行失败的作业,因为规则的输出文件(即这里的日志文件)已经存在。因此,除非在作业失败时保留日志很重要,否则 Maarten-vd-Sande.