snakemake

How to run a rule with the working dir being the local storage prefix?


Snakemake 8.20.3

In my configuration, I set

default-storage-provider: fs
local-storage-prefix: /wrk-vakka/users/$USER/local

However, when I run a rule such as

localrules: test_lf
rule test_lf:
    output: "touched_file.txt"
    shell:  """
        echo $(pwd)
        touch touched_file.txt
    """

Then it creates touched_file.txt in the directory where my Snakefile is, and not under the specified local-storage-prefix.

How can I make a shell rule that uses the local-storage-prefix as the working directory for its shell script?


Solution

  • The solution was to use the output wildcard inside the script as follows:

    localrules: test_lf
    rule test_lf:
        output: "touched_file.txt"
        shell:  """
            echo $(pwd)
            touch {output}
        """