I'm looking for a way to define a target pattern rule (without input pattern) in Snakemake.
In this case, I want a rule that creates the files a
, b
and c
as part of a pattern on the target file where the input does not contain a pattern.
In GNU make, I would do it like this:
.PHONY: all
all: a b c
%:
echo x > $@
However, if I do the following in Snakemake:
rule test:
output:
"{filename}"
wildcard_constraints:
filename = "[abc]"
shell:
"echo x > {filename}"
WorkflowError: Target rules may not contain wildcards. Please specify concrete files or a rule without wildcards.
I can of course specify the output
using an expand()
call, but that would imply that the rule creates all files when called once, which is not the case. Rather, it should create one file when executing shell
with a certain argument ({filename}
in the example here).
Tims answer below basically contains the solution. But since you have asked me on Twitter, let me directly translate your Makefile:
All these basics are explained in the Snakemake tutorial.