How To Make Snakemake Input Optional But Not Empty?
I'm building an SQL script out of text data. The (part of) script shall consist of a CREATE TABLE statement and an optional INSERT INTO statement. The values for INSERT INTO statem
Solution 1:
my solution would be something along the lines that you should not force snakemake to use or not to use a rule inside the rule but specify which outputs do you need and snakemake will decide if it needs to use the rule. So for your example, I would do something as:
def required_files(filelist):
return [file for file in filelist ifos.path.isfile(file)]
rule what_to_gen:
input:
merged = [] if required_files(expand("path_to_data/{dataset}/values", dataset=["A", "B", "C"])) else'merged_files.txt'
rule merge_values:
input: required_files(expand("path_to_data/{dataset}/values", dataset=["A", "B", "C"]))
output: 'merged_files.txt'
shell: ...
This will execute the rule merge_values only if required_files is non-empty.
Post a Comment for "How To Make Snakemake Input Optional But Not Empty?"