I expected Snakemake to allow wildcards to be empty strings, alas, this isn't the case.
How can I make a wildcard accept an empty string?
Wildcards by default only match the regex .+
meaning everything but empty strings. This is unfortunately not documented beyond a Google group conversation.
To make a wildcard accept empty strings, simply add a custom wildcard constraint wildcard_constraints: foo=".*"
, either within the scope of a rule or globally:
# Option 1
wildcard_constraints:
foo=".*"
rule a:
input: in{foo}.txt
output: out{foo}.txt
wildcard_constraints: foo=".*" # Option 2
shell: "cp {input} {output}"