Automatically run rule when file changes in Snakemake

149 Views Asked by At

When working on compiled documents (LaTeX, RMarkdown, etc), I usually set up a rule for make using inotifywait to watch the input files and automatically rebuild the output file whenever the input files change.

For example:

dependencies = main.tex

main.pdf: $(dependencies)
    latexmk -lualatex --shell-escape $<

watch:
    while true; do inotifywait --event modify $(dependencies); $(MAKE); done

I'm now trying to migrate from make to snakemake. How can I set up something similar with snakemake?

1

There are 1 best solutions below

0
Dmitry Kuzminov On

Using Snakemake you get the power of Python. For example, you can use inotify python module to wait for updates and run the snakemake.snakemake function each time you detect updates. But it would be much easier to reuse the bash script that you have already: while true; do inotifywait --event modify $(dependencies); snakemake; done.