I am creating my first snakemake file, and I got to the point where I need to perform a simple string operation on the value of my output
, so that my shell
command works as expected:
rule sketch:
input:
'out/genomes.txt'
output:
'out/genomes.msh'
shell:
'mash sketch -l {input} -k 31 -s 100000 -o {output}'
I need to apply the split
function to {output}
so that only the name of the file up to the extension is used. I couldn't find anything in the docs or in related questions.
Best is to use params
:
rule sketch:
input:
'out/genomes.txt'
output:
'out/genomes.msh'
params:
prefix=lambda wildcards, output: os.path.splitext(output[0])[0]
shell:
'mash sketch -l {input} -k 31 -s 100000 -o {params.prefix}'
It is always preferable to use params
instead of using the run
directive, because the run
directive cannot be combined with conda environments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With