How do I make snakemake rebuild missing inputs?

Viewed 123

Is there a way for snakemake to behave like make in cases when inputs are missing? Is the current behavior of snakemake a bug or a feature?

$ ls
b  Makefile  Snakefile

$ cat Makefile
b: a
    touch b
a:
    touch a

$ make -n
touch a
touch b


$ cat Snakefile
rule b:
   input: "a"
   output: touch("b")

rule a:
   output: touch("a")


$ snakemake -n
Building DAG of jobs...
Nothing to be done.

$ snakemake -v
5.20.1
1 Answers

In your case, a is only intermediate output to generate b. Since b is already there, the Snakefile will do nothing.

You can either call snakemake with the -F parameter to redo intermediate steps

snakemake -n -F

or define a target rule where both a and b are designated as final output

rule all:
   input: "a", "b"

rule b:
   input: "a"
   output: touch("b")

rule a:
   output: touch("a")
Related