snakemake 规则的日志部分中定义的文件与输出部分中定义的文件有很大不同吗?

Are files defined in the log section of a snakemake rule much different from the ones defined in the output section?

据我了解the documentation for the log section of a snakemake rule,必须"manually"将内容发送到日志文件。在我看来,使用 output 部分中定义的文件可以获得相同的结果。

这两种可能的方法之间的重要区别是什么?

log 部分的真正用处是什么?

对我来说,最好的日志练习是 Snakemake 就是这样:

rule example1:
  input:
    file = <input>

  log: 
    out = '_stdout.log',
    err = '_stderr.err'

  output:
    <output>

  shell: 
    'Script/Tool {input.file} 2> {log.err} 1> {log.out}'

我觉得log section很有用。大多数程序或工具会在 standard outstandard error 上生成一些日志。这有助于用户了解工具或程序在哪一步失败。

当然你可以在输出部分像下面的代码那样做:

rule example2:
  input:
    file = <input>

  output:
    file = <output>
    out = '_stdout.log',
    err = '_stderr.err'

  shell: 
    'Script/Tool {input.file} 2> {output.err} 1> {output.out}'

这将产生与 example1 规则相同的结果。但是 output section 的目的是使 dependencies 与其他规则或只是提供您需要的结果文件。在大多数情况下,日志不是这些文件,除非在规则中检查某些参数或文件。

将日志放在输出上有一个很大的缺点。当 Snakemake 中的规则失败时,Snakemake 会删除所有可能因失败而损坏的输出。所以你的日志也将被删除,你可能无法看到它在程序的哪一步失败或失败的原因

雨果