rule aggregate:
input:
expand("{dataset}/a.txt", dataset=DATASETS)
output:
"aggregated.txt"
shell:
...
wildcards
argument, which contains the wildcards resolved by the output filesdef myfunc(wildcards):
return [... a list of input files depending on given wildcards ...]
rule:
input: myfunc
output: "someoutput.{somewildcard}.txt"
shell: "..."
log:
but you have to make sure your code actually writes to them!rule abc:
input: "input.txt"
output: "output.txt"
log: "logs/abc.log"
shell: "somecommand --log {log} {input} {output}"
bids_dir: /path/to/bids_dir
seeds:
- ZI
- STN
$ snakemake --config yourparam=1.5
Can use the shell()
command inside any Python run:
blocks, even inside Python loops
for line in shell("somecommand {output.somename}", iterable=True):
... # do something in python
graphviz
package has a tool, dot
, to render these graphs$ snakemake --rulegraph | dot -Tpng > rulegraph.png
--dag
and --filegraph
options, but can be huge if many files$ snakemake --report
--lint
can let you know if you are following current best practicescookiecutter gh:snakemake-workflows/cookiecutter-snakemake-workflow
tar.gz
$ snakemake --archive my-workflow.tar.gz
tar -xf my-workflow.tar.gz
snakemake -n
conda
feature in snakemakewget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh
conda init
...
conda install -c conda-forge -c bioconda snakemake
module load python/3
virtualenv venv_smk
source venv_smk/bin/activate
pip install snakemake ...
conda
directivessh graham.computecanada.ca
git clone https://github.com/khanlab/neuroglia-helpers
~/neuroglia-helpers/setup.sh khanlab
...
snakemake
snakemake
(e.g. regularInteractive
)snakemake
(e.g. regularSubmit
)cc-slurm
profile
group:
directive to group rules in the same jobsnakemake_remotebatch
wrapper to split the DAG into batches and submit each as a separate jobint
E.g.: this rule is expected to use 4 cores, 4gb memory, and takes 6 hours
rule myjob:
...
threads: 4
resources:
mem = 4000,
time = 360
shell: ...
snakemake -j 8 --resources mem=4000
From your working folder on graham, run:
jupyter_snakemake
Then on your local computer use sshuttle
so you can connect to the remote host via your browser.
batch
optionSnakemake Documentation:
https://snakemake.readthedocs.io/en/stable/index.html
Neuroglia-helpers for Khanlab Snakemake environment: https://github.com/khanlab/neuroglia-helpers