I would like to be able to have my snakemake workflows continue running even when certain rules fail.
For example, I'm using a variety of tools in order to perform peak-calling of ChIP-seq data. However, certain programs issue an error when they are not able to identify peaks. I would prefer to create an empty output file in such cases, and not having snakemake fail (like some peak-callers already do).
Is there a snakemake-like way of handling such cases, using the "shell" and "run" keywords?
Thanks
For
shell
commands, you can always take advantage conditional "or",||
:Usually an exit code of zero (0) means success, and anything non-zero indicates failure. Including
|| true
ensures a successful exit when the command exits with a non-zero exit code (true
always returns0
).If you need to allow a specific non-zero exit code, you can use shell or Python to check the code. For Python, it would be something like the following. The
shlex.split()
module is used so shell commands do not need to passed as arrays of arguments.In shell script: