Search code examples
relative-pathsnakemakeabsolute-path

Snakemake shadow rule when program writes to /tmp


I am using Snakemake to run the defense-finder program. This program creates and overwites generic temporary files in /tmp/defense-finder, i.e. the file names do not contain unique identifiers. When running my rule across separate cores on different input files, Snakemake crashes due to clashes in /tmp/defense-finder.

It appears that Shadow rules can help when different jobs write to the same files within the working directory. Is there a way to use Shadow rules when a program writes to the /tmp directory?


Solution

  • Following @Marmaduke's comment that file paths are hard-coded, a temporary workaround is to force snakemake to run the defense-finder jobs one at a time while allowing other jobs to run in parallel. You can do this with the resources directive:

    rule defense_finder:
        resources:
            n_defense= 1,
        input: ...
        output: ...
        shell: ...
    

    then run with:

    snakemake --resources n_defense=1 -j 10 ...