snakemake temp()导致不必要的规则重新运行



我正在使用snakemake v 5.4.0,我遇到了temp()的问题。在假设的情况下:

Rule A --> Rule B1 --> Rule C1
     |
      --> Rule B2 --> Rule C2 
where Rule A generates temp() files used by both pathways 1 (B1 + C1) and 2 (B2 + C2).

如果我运行管道,则在两种路径中使用后,由rulea生成的temp()文件将被删除,这是我期望的。但是,如果我想重新运行路径2,则必须重新创建用于rulea的temp()文件,这会触发整个管道的重新运行,而不仅仅是pathway2。对于长管道来说,这在计算上变得非常昂贵。除了不使用temp()之外,还有一个很好的方法可以防止这种方法,在我的情况下,这需要多余的额外硬盘驱动空间?

您可以创建输入文件列表以规则 all,或者任何第一个规则所调用的任何规则,取决于路径2的输出是否已经存在(并满足一些理智检查)。

output= ['P1.out']
if not os.path.exists('P2.out'): # Some more conditions here...
    output.append('P2.out')
rule all:
    input:
        output
rule make_tmp:
    output:
        temp('a.out')
    shell:
        r"""
        touch {output}
        """
rule make_P1:
    input:
        'a.out'
    output:
        'P1.out'
    shell:
        r"""
        touch {output}
        """
rule make_P2:
    input:
        'a.out'
    output:
        'P2.out'
    shell:
        r"""
        touch {output}
        """

但是,这有些打败了使用snakemake的重点。如果必须重新创建路径1的输入,那么您如何确定其输出仍然是最新的?

最新更新