Here is a short example from the advanced section of snakemake tutorial:
rule bwa_map:
input:
"data/genome.fa",
lambda wildcards: config["samples"][wildcards.sample]
output:
"mapped_reads/{sample}.bam"
threads: 8
shell:
"bwa mem -t {threads} {input} | samtools view -Sb - > {output}"
Now lets say that I wrote this rule months ago and I don't remember the output file name. My understanding is that I cannot run snakemake by invoking the rule name because this would lead to an error:
$ snakemake bwa_map
InputFunctionException in line 9 of Snakefile:
AttributeError: 'Wildcards' object has no attribute 'sample'
Wildcards:
$
First, I don't understand why snakemake cannot use the lambda function to deduce input files from the configuration file as it is quite clear that I refer to the "samples" section.
Second, is there a workaround to this? Because it is very easy to do with good old Makefile to just use an old Makefile and run the same bwa_map rule by typing something like
$ make bwa_map INPUT=data/samples/A.fastq
Thanks in advance for your help. Benoist