Snakemake: name rule instead of target file
<p>Here is a short example from the advanced section of snakemake tutorial:</p>

<pre><code>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 - &gt; {output}"
</code></pre>

<p>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:</p>

<pre><code>$ snakemake bwa_map
InputFunctionException in line 9 of Snakefile:
AttributeError: 'Wildcards' object has no attribute 'sample'
Wildcards:

$
</code></pre>

<p>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.</p>

<p>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</p>

<pre><code>$ make bwa_map INPUT=data/samples/A.fastq
</code></pre>

<p>Thanks in advance for your help.
Benoist</p>