Search code examples
snakemake

Snakemake - delete all non-output files produced by a workflow


I have a workflow that produces tons of files, most of them are not the output of any rule (they are intermediate results). I'd like to have the option of deleting everything that is not the output of any rule after the workflow is complete. This would be useful for archiving.
Right now the only way I found to do that is to define all outputs of all rules as protected, and then run snakemake --delete-all-output. Two questions:
1. Is this the way to go, or is there a better solution?
2. Is there a way to automatically define all outputs as protected, or do I have to go through the entire code and wrap all outputs with protected()?

Thanks!


Solution

  • Maybe the option --list-untracked helps?

      --list-untracked, --lu
                            List all files in the working directory that are not
                            used in the workflow. This can be used e.g. for
                            identifying leftover files. Hidden files and
                            directories are ignored.