Hello,
Is it possible to define a snakemake rule's output based on a dictionary from a wildcard? I have a dictionary, let's call it 'transform', that contains key:value so that {sample}:new name. I want to write a snakemake rule like this example:
rule example:
input:
i = "path/{sample}.vcf"
output:
o = "path/transform[{sample}].vcf"
shell:
"""
somecommand -i {input.i} -o {output.o}
"""
I've been looking around the internet for similar questions that have been resolved, although their solutions seem too specific. I'm unsure on what would work best. Reading through snakemake's documentation has further confused me on what is accepted for output and params.
Right now I'm looking at it like this:
input: i = "path/{sample}.vcf"
output: o = "path/{params.value}.vcf"
params: value = lambda wcs: transform[wcs.sample]
Does anyone know how I could make this work?
Thank you.
The way snakemake works is that you write implicit wildcard rules and then ask for explicit outputs.
So you can definitely map arbitrary inputs and outputs using a lambda function and a dictionary but in the end you will still need to explicitly ask for the outputs.
Your transform function must take an output and generate the correct input, not the other way around.
Thank you for your answer! You're right, I was thinking about this the wrong way, had input and output mistaken.