为什么在 snakefile 中设置“wildcard_constraints”会阻止删除标记为“temp”的文件?

Why does setting `wildcard_constraints` in a snakefile prevent the deletion of files marked `temp`?

考虑以下蛇文件:

NUMS = ["1", "2"]

#wildcard_constraints:
#    num="\d+"

rule all:
    input:
        "all_text.txt"

rule generate_text:
    output:
        text_file = temp("text_{num}.txt")
    shell:
        """
        echo "test" > {output.text_file}
        """

rule gather_results:
    input:
        expand("text_{num}.txt", num=NUMS)
    output:
        "all_text.txt"
    shell:
        """
        cat {input} > {output}
        """

如果我取消注释 wildcard_constraints 部分,则不会删除标记为 temp 的文件。

这可能是什么原因?

更多测试

wildcard_constraints 放入规则中:

rule generate_text:
    output:
        text_file = temp("text_{num}.txt")
    wildcard_constraints:
        num="\d+"
    shell:
        """
        echo "test" > {output.text_file}
        """

这具有相同的效果:temp 个文件未被删除。

将通配符约束放入 generate_text 规则的输出文件名中:

rule generate_text:
    output:
        text_file = temp("text_{num,\d+}.txt")
    shell:
        """
        echo "test" > {output.text_file}
        """

在这种情况下,temp 个文件已按预期删除。

将约束放入 gather_results 规则的输入文件名中:

rule gather_results:
    input:
        expand("text_{num,\d+}.txt", num=NUMS)
    output:
        "all_text.txt"
    shell:
        """
        cat {input} > {output}
        """

这会导致错误:

WildcardError in line 20 of /tmp/Snakefile:
No values given for wildcard 'num,\d+'.
File "/tmp/Snakefile", line 20, in

我怀疑这是由于使用了 expand

我刚刚查看了源代码。您实际上发现了一个错误。当应用通配符约束时,标志将丢失。我已经在 master 分支修复它了。