How to target intermediary Snakemake rule that contains wildcards

Viewed 72

I have a workflow that, very simplified for this question, looks as follows:

rule all:
    input: multiext("final",".a",".b",".c",".d")

rule final_cheap:
    input: "intermediary.{ext}"
    output: "final.{ext}"
    #dummy for cheap but complicated operation
    shell: "cp {input} {output}"

rule intermediary_cheap:
    input: "start.{ext}"
    output: "intermediary.{ext}"
    #dummy for cheap complicated operation
    shell: "cp {input} {output}" 

rule start_expensive:
    output: "start.{ext}"
    #dummy for very expensive operation
    shell: "touch {output}" 

There's a very expensive first step and two complicated steps that follow.

After I've run this workflow once with snakemake -c1 I want to rerun the workflow but just from the intermediary rule onwards. How can I achieve this goal with command line flags?

snakemake intermediary_cheap all does not work, because intermediary_cheap contains wildcards, even though the inclusion of all really shows the values of the required wildcards.

Is there a command line flag that tells snakemake to run the rule and ignore all output from the rule intermediary_cheap, something like snakemake all --forcerule=intermediary_cheap? (I invented that --forcerule flag, it doesn't exist as far as I know.

The workaround I'm using right now is manually deleting the output of the rule intermediary_cheap, then forcing execution of the rule with --force and then running rule all, which notices that some upstream inputs have changed. But this requires knowledge of the precise file names that are produced, whereas knowledge of rules only would be preferable because it is at a higher level of abstraction.

1 Answers

I haven't used it before but I think you want:

snakemake -c 1 --forcerun intermediary_cheap
  --forcerun [TARGET [TARGET ...]], -R [TARGET [TARGET ...]]
                        Force the re-execution or creation of the given rules
                        or files. Use this option if you changed a rule and
                        want to have all its output in your workflow updated.
                        (default: None)
Related