snakemake / snakemake-storage-plugin-fs

A Snakemake storage plugin that reads and writes from a locally mounted filesystem using rsync.
MIT License
2 stars 2 forks source link

How to combine param paths with a fs storage #23

Open IceFreez3r opened 1 month ago

IceFreez3r commented 1 month ago

Disclaimer: This might be more of a general question on storages, but I'm not sure on that.

Say I have this rule from the docs:

rule:
    input:
        ...
    params:
        prefix="somedir/{sample}"
    output:
        "somedir/{sample}.csv"
    shell:
        "somecommand -o {params.prefix}"

The rule is executed as somecommand -o somedir/sample1. Since the storage plugin doesn't change the pwd, this will create an output file "somedir/sample1.csv" relative to the Snakefile, which might already be bad if there are a lot of writes on a slow IO system. But worse, since snakemake expects the output file in the storage directory it fails with a MissingOutputException. Is there a smart way to prevent this? The only way I can think of is to use a lambda function for the prefix that splits of ".csv" from the output path in this case. But this would need to be adjusted to each case, since there might be more complex cases where it's not only a file extension that needs to get removed.

Thanks in advance!