Search code examples
workflowrulessnakemake

snakemake only runs the first rule not all


My snakefile looks like this.

rule do00_download_step01_download_:
    input:
        
    output:
        "data/00_download/scores.pqt"
    run:
        from lib.do00_download import do00_download_step01_download_
        do00_download_step01_download_()
rule do00_download_step02_get_the_mean_:
    input:
        "data/00_download/scores.pqt"
    output:
        "data/00_download/cleaned.pqt"
    run:
        from lib.do00_download import do00_download_step02_get_the_mean_
        do00_download_step02_get_the_mean_()
rule do01_corr_step01_correlate:
    input:
        "data/00_download/cleaned.pqt"
    output:
        "data/01_corr/corr.pqt"
    run:
        from lib.do01_corr import do01_corr_step01_correlate
        do01_corr_step01_correlate()
rule do95_plot_step01_correlations:
    input:
        "data/01_corr/corr.pqt"
    output:
        "plot/heatmap.png"
    run:
        from lib.do95_plot import do95_plot_step01_correlations
        do95_plot_step01_correlations()
rule do95_plot_step02_plot_dist:
    input:
        "data/00_download/cleaned.pqt"
    output:
        "plot/dist.png"
    run:
        from lib.do95_plot import do95_plot_step02_plot_dist
        do95_plot_step02_plot_dist()
rule do99_figures_step01_make_figure:
    input:
        "plot/dist.png"
        "plot/heatmap.png"
    output:
        "figs/fig01.svg"
    run:
        from lib.do99_figures import do99_figures_step01_make_figure
        do99_figures_step01_make_figure()
rule all:
    input:
        "figs/fig01.svg"

I have arranged the rules in a sequential manner, hoping that this will make sure all the steps will be run in that order. However, when I run snakemake, it only runs the first rule and then it exits.

I have individually checked all the steps (functions that I import) if they work well, the paths of the input and output files. Everything looks ok. So I am guessing that the issue is with how I formatted the snakefile. I am new to snakemake (beginer-level). So it would be very helpful if somebody points out how I should fix this issue.


Solution

  • This is the intended behavior. Here's a relevalent section from the docs:

    Moreover, if no target is given at the command line, Snakemake will define the first rule of the Snakefile as the target. Hence, it is best practice to have a rule all at the top of the workflow which has all typically desired target files as input files. The output of the first rule is assumed to be the target.

    If you move the rule all: to the top of your Snakefile, it should work as expected.