<p>Read <a href="https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#targets-and-aggregation" rel="nofollow noreferrer">the snakemake documentation</a>. <code>all</code> is a pseudo-rule that accepts a set of one or more final output files as input and does nothing with them.</p>

CC BY-SA 4.0
2022-06-03T16:06:31.400Z
One clarification: Snakemake defaults to trying the first rule in the file (whether called the idiomatic `all` or anything else) and since in your case that has a sample wildcard, it doesn't know what to fill in for that wildcard.  (A typical `all` rule might use something like `input: expand("mapped_reads/{sample}.bam", sample=SAMPLES)` for example.)
Jesse
CC BY-SA 4.0
2022-06-03T19:14:19.557Z
Even more to the point: move `bcftools_call` to the top of the file and it will behave as your `all` rule.
Jesse
CC BY-SA 4.0
2022-06-02T18:14:48.407Z
2022-06-02T18:14:48.407Z
Ram RS
<p>I am learning to use snakemake. I am following the tutorial (<a href="https://snakemake.readthedocs.io/en/stable/tutorial/tutorial.html" rel="nofollow noreferrer">https://snakemake.readthedocs.io/en/stable/tutorial/tutorial.html</a>). In the section called &quot;Basics&quot;, steps 1  to 4 worked well, processing one sample at a time, from mapping reads until indexing alignments.</p>
<pre><code>snakemake --cores 2 sorted_reads/{A,B,C}.bam.bai
</code></pre>
<p>However, when I add the rule for joint variant calling (step 5):</p>
<pre><code>snakemake --cores 2
</code></pre>
<p>I get the following error:</p>
<pre><code>&quot;WorkflowError:
Target rules may not contain wildcards. Please specify concrete files or a rule without wildcards at the command line, or have a rule without wildcards at the very top of your workflow (e.g. the typical &quot;rule all&quot; which just collects all results you want to generate in the end).&quot;
</code></pre>
<p>It looks like I need to do this &quot;rule all&quot; step, any idea how to set this up?</p>
<p>This is how the snakemake file looks like:</p>
<pre><code>SAMPLES = [&quot;A&quot;, &quot;B&quot;, &quot;C&quot;]

rule bwa_map:
    input:
        &quot;data/genome.fa&quot;,
        &quot;data/samples/{sample}.fastq&quot;
    output:
        &quot;mapped_reads/{sample}.bam&quot;
    shell:
        &quot;bwa mem {input} | samtools view -Sb - &gt; {output}&quot;

rule samtools_sort:
    input:
        &quot;mapped_reads/{sample}.bam&quot;
    output:
        &quot;sorted_reads/{sample}.bam&quot;
    shell:
        &quot;samtools sort -T sorted_reads/{wildcards.sample} &quot;
        &quot;-O bam {input} &gt; {output}&quot;

rule samtools_index:
    input:
        &quot;sorted_reads/{sample}.bam&quot;
    output:
        &quot;sorted_reads/{sample}.bam.bai&quot;
    shell:
        &quot;samtools index {input}&quot;

rule bcftools_call:
    input:
        fa=&quot;data/genome.fa&quot;,
        bam=expand(&quot;sorted_reads/{sample}.bam&quot;, sample=SAMPLES),
        bai=expand(&quot;sorted_reads/{sample}.bam.bai&quot;, sample=SAMPLES)
    output:
        &quot;calls/all.vcf&quot;
    shell:
        &quot;bcftools mpileup -f {input.fa} {input.bam} | &quot;
        &quot;bcftools call -mv - &gt; {output}&quot;
</code></pre>

<variant-calling><snakemake>
snakemake tutorial stuck in basics-step-5 (variant calling)
# snakemake tutorial stuck in basics-step-5 (variant calling)

(Asked by: username_0 on 2022-06-02)

I am learning to use snakemake. I am following the tutorial (https://snakemake.readthedocs.io/en/stable/tutorial/tutorial.html). In the section called "Basics", steps 1  to 4 worked well, processing one sample at a time, from mapping reads until indexing alignments.
snakemake --cores 2 sorted_reads/{A,B,C}.bam.bai

However, when I add the rule for joint variant calling (step 5):
snakemake --cores 2

I get the following error:
"WorkflowError:
Target rules may not contain wildcards. Please specify concrete files or a rule without wildcards at the command line, or have a rule without wildcards at the very top of your workflow (e.g. the typical "rule all" which just collects all results you want to generate in the end)."

It looks like I need to do this "rule all" step, any idea how to set this up?
This is how the snakemake file looks like:
SAMPLES = ["A", "B", "C"]

rule bwa_map:
    input:
        "data/genome.fa",
        "data/samples/{sample}.fastq"
    output:
        "mapped_reads/{sample}.bam"
    shell:
        "bwa mem {input} | samtools view -Sb - > {output}"

rule samtools_sort:
    input:
        "mapped_reads/{sample}.bam"
    output:
        "sorted_reads/{sample}.bam"
    shell:
        "samtools sort -T sorted_reads/{wildcards.sample} "
        "-O bam {input} > {output}"

rule samtools_index:
    input:
        "sorted_reads/{sample}.bam"
    output:
        "sorted_reads/{sample}.bam.bai"
    shell:
        "samtools index {input}"

rule bcftools_call:
    input:
        fa="data/genome.fa",
        bam=expand("sorted_reads/{sample}.bam", sample=SAMPLES),
        bai=expand("sorted_reads/{sample}.bam.bai", sample=SAMPLES)
    output:
        "calls/all.vcf"
    shell:
        "bcftools mpileup -f {input.fa} {input.bam} | "
        "bcftools call -mv - > {output}"

**Tags:** variant-calling, snakemake

---

## 1 answers

### Answer by username_1 on 2022-06-02. Score: 2

Read [the snakemake documentation](https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#targets-and-aggregation). `all` is a pseudo-rule that accepts a set of one or more final output files as input and does nothing with them.

> **Comments:**
> **username_2**: One clarification: Snakemake defaults to trying the first rule in the file (whether called the idiomatic `all` or anything else) and since in your case that has a sample wildcard, it doesn't know what to fill in for that wildcard.  (A typical `all` rule might use something like `input: expand("mapped_reads/{sample}.bam", sample=SAMPLES)` for example.)  
> **username_2**: Even more to the point: move `bcftools_call` to the top of the file and it will behave as your `all` rule.  

---

