Consider the following snakefile:
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}
"""
If I uncomment the wildcard_constraints section, the files marked temp are not deleted.
What could be the cause of this ?
wildcard_constraints in the rule:rule generate_text:
output:
text_file = temp("text_{num}.txt")
wildcard_constraints:
num="\d+"
shell:
"""
echo "test" > {output.text_file}
"""
This has the same effect: temp files are not deleted.
generate_text rule:rule generate_text:
output:
text_file = temp("text_{num,\d+}.txt")
shell:
"""
echo "test" > {output.text_file}
"""
In this case, temp files are deleted as expected.
gather_results rule:rule gather_results:
input:
expand("text_{num,\d+}.txt", num=NUMS)
output:
"all_text.txt"
shell:
"""
cat {input} > {output}
"""
This results in an error:
WildcardError in line 20 of /tmp/Snakefile:
No values given for wildcard 'num,\d+'.
File "/tmp/Snakefile", line 20, in
I suspect this is due to the use of expand.
I just checked the source code. You actually found a bug. When wildcard constraints are applied, the flags are lost. I have fixed it in the master branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With