6
votes

I have created a workflow within snakemake, I Have a problem when I want to run just one rule. Indeed it runs for me the rules where the output is the input of my rule even if those one are already created before.

Example :

rule A:
 input A
 output A

rule b:
 input b = output A
 output b

rule c:
 input c = output b
 output c

How can I run just the rule C?

3
What is the command you use to run snakemake? It would be better if you could show us real example instead of pseudocode, as something could be wrong with the code.Manavalan Gajapathy
By default snakemake runs only the first rule of a workflow. If its inputs are not available, it will look for other rules to produce them.rioualen
Without a more specific example I can't really help, but you could experiment with --until. From the help for snakemake: --until TARGET [TARGET ...], -U TARGET [TARGET ...] Runs the pipeline until it reaches the specified rules or files. Only runs jobs that are dependencies of the specified rule or files, does not run sibling DAGs.Russ Hyde
@JeeYem snakemake -p my_rule --config run-date=22_01_2019. my_rule take as an input an output of a previous rule(x) but in my case this output is already generated, and when I want to run my_rule he is starting from rule (x).BioManil
It appears something is wrong with the code. Seeing the actual code would help.Manavalan Gajapathy

3 Answers

6
votes

If there are dependencies, I have found that only --until works if you want to run rule C just run snakemake -R --until c. If there are assumed dependencies, like shared input or output paths, it will force you to run the upstream rules without the use of --until. Always run first with -n for a dry-run.

2
votes

You just run:

snakemake -R b

To see what this will do in advance:

snakemake -R b -n

-R selects the one rule (and all its dependent rules also!), -n does a "dry run", it just prints what it would do without -n.

2
votes

You can used the --allowed-rules option.

snakemake --allowed-rules c

Snakemake will try to rerun upstream rules linked by the input/output chain to your downstream rule if the output file(s) of the upstream rule(s) have changed (including if they've been re-created but the content hasn't changed). This behavior makes Snakemake reproducible, but maybe isn't desirable if you're trying to debug a specific part of your pipeline and don't want to run all the intermediate steps.

See this discussion: https://bitbucket.org/snakemake/snakemake/issues/688/execute-specified-rule-only-and-not