Search code examples
pythonsnakemake

Running snakefile from directory that doesn't contain snakefile


I'm writing a pipeline that creates a snakefile in child directory.

The general structure looks like this.

> snakemake_pipeline.py
    > runs/
        > run1/
            > Snakefile
            > ... (all other necessary files for snakemake to run)         

So, each time I run snakemake_pipeline.py a new directory is created in the runs/ directory. I'd like to be able to run the snakefile in the run1/ directory from the snakemake_pipeline.py script.

At the end of my script I've tried the following.

os.chidir(path/to/run1)
os.system(snakemake -j5)

The end result of this is snakemake gets started, but is unable to find all the files that are in the run1/ directory.

I've also tried just

snakemake runs/run1/Snakefile -j5 and snakemake runs/run1/ -j5

Both of which yield the same error Error: no Snakefile found, tried Snakefile, snakefile, workflow/Snakefile, workflow/snakefile.


Solution

  • You are looking for the --snakefile or -s option.

    snakemake --snakefile runs/run1/Snakefile