<p>Given the Makefile you provided and which someone then deleted from the question, you should probably just add this line (this should be the first rule):</p>

<p><code>rule all: input: ["data/{}/genome.fa.gz".format(x) for x in species.split()]
</code></p>

<p>This rule just specifies a list of expected output files and corresponds to the following lines from the original <code>Makefile</code>:</p>

<p><code>GENOMES=$(patsubst %, data/%/genome.fa.gz, $(SPECIES))
all : $(GENOMES)</code></p>

CC BY-SA 3.0
2017-11-05T11:50:03.777Z
I have deleted Make equivalent since was not really related to the problem.
Kamil S Jaron
CC BY-SA 3.0
2017-11-03T18:01:05.533Z
2017-11-03T18:01:05.533Z
Karel Břinda
<p>The problem is that you need a master rule that requires all of your desired outputs as inputs, in your case it would be :</p>

<pre><code>rule all:
    input:
        expand("data/{sp}/genome.fa.gz", sp=species.split(' '))
</code></pre>

<p>You'll also need separate download link inputs for each species. You could make a separate <code>download_table.tsv</code> for each species, but it would probably be easier to make a config file with this information, and add a params keyword to your rule. Something like:</p>

<pre><code>rule download:
   params:
       url=config['locations']['sp']
   output :
       "data/{sp}/genome.fa.gz"
   shell :
       "scripts/download.sh {params.url}"
</code></pre>

CC BY-SA 3.0
2017-11-03T15:45:53.367Z
I wouldn't erase it if I were you. A lot of people get confused about Snakemake error messages, so its helpful to have some examples on here.
heathobrien
CC BY-SA 3.0
2017-11-03T15:47:27.163Z
Then I will at least dramatically edit it. (I try to do it in a way so your answer still fits)
Kamil S Jaron
CC BY-SA 3.0
2017-11-03T19:13:25.243Z
@KamilSJaron I agree the question should be kept, but maybe change the title to reflect the error message, this has nothing to do with NCBI
Chris_Rands
CC BY-SA 3.0
2017-11-06T10:51:58.353Z
Also note that Snakemake has an NCBI remote provider: http://snakemake.readthedocs.io/en/stable/snakefiles/remote_files.html#genbank-ncbi-entrez
Johannes Köster
CC BY-SA 3.0
2017-11-10T15:53:09.563Z
@JohannesKöster I was looking at it. But since I could not make it work without remote I have not even tried with remote. And then the problem I originally had with non-remote solution is very much unrelated to downloading of sequences. It's a good tip though, maybe work an answer?
Kamil S Jaron
CC BY-SA 3.0
2017-11-03T12:49:58.650Z
2017-11-05T11:52:23.763Z
2017-11-05T11:52:23.763Z
heathobrien
<p>I would like to do easily reproducible analysis using publicly available data from NCBI, so I have chosen a <code>snakemake</code>. </p>

<p>I would like to write a single rule, that would be able to download any genome given a species code name and separated table of species and their NCBI IDs. So I wrote a script <code>scripts/download.sh</code> that takes a species code and download the genome to <code>data/&lt;species_code&gt;/genome.fa.gz</code>. The script internally reads the table <code>tables/download_table.tsv</code>, where are corresponding species code names and NCBI IDs.</p>

<p>So I tried to do a <code>snakemake</code> like this :</p>

<pre><code>species='Cbir Avag Fcan Lcla Dcor Dpac Pdav Psp62 Psp79 Minc1 Minc2 Mjav Mare Mflo Mhap Pant'

rule download:
    input :
        "tables/download_table.tsv"
    output :
        "data/{sp}/genome.fa.gz"
    shell :
        "scripts/download.sh {sp}"
</code></pre>

<p>However, <code>snakemake</code> returned an error message I do not really understand :</p>

<pre><code>Target rules may not contain wildcards. Please specify concrete files or a rule without wildcards.`. 
</code></pre>

<p>Is there a way to write a single rule for downloading all the genomes?</p>

<snakemake>
How to resolve in snakemake error : "Target rules may not contain wildcards."
# How to resolve in snakemake error : "Target rules may not contain wildcards."

(Asked by: username_0 on 2017-11-03)

I would like to do easily reproducible analysis using publicly available data from NCBI, so I have chosen a snakemake. 
I would like to write a single rule, that would be able to download any genome given a species code name and separated table of species and their NCBI IDs. So I wrote a script scripts/download.sh that takes a species code and download the genome to data//genome.fa.gz. The script internally reads the table tables/download_table.tsv, where are corresponding species code names and NCBI IDs.
So I tried to do a snakemake like this :
species='Cbir Avag Fcan Lcla Dcor Dpac Pdav Psp62 Psp79 Minc1 Minc2 Mjav Mare Mflo Mhap Pant'

rule download:
    input :
        "tables/download_table.tsv"
    output :
        "data/{sp}/genome.fa.gz"
    shell :
        "scripts/download.sh {sp}"

However, snakemake returned an error message I do not really understand :
Target rules may not contain wildcards. Please specify concrete files or a rule without wildcards.`. 

Is there a way to write a single rule for downloading all the genomes?

**Tags:** snakemake

---

## 2 answers

### Answer by username_2 on 2017-11-03. Score: 9 | Accepted answer

The problem is that you need a master rule that requires all of your desired outputs as inputs, in your case it would be :
rule all:
    input:
        expand("data/{sp}/genome.fa.gz", sp=species.split(' '))

You'll also need separate download link inputs for each species. You could make a separate download_table.tsv for each species, but it would probably be easier to make a config file with this information, and add a params keyword to your rule. Something like:
rule download:
   params:
       url=config['locations']['sp']
   output :
       "data/{sp}/genome.fa.gz"
   shell :
       "scripts/download.sh {params.url}"

> **Comments:**
> **username_2**: I wouldn't erase it if I were you. A lot of people get confused about Snakemake error messages, so its helpful to have some examples on here.  
> **username_0**: Then I will at least dramatically edit it. (I try to do it in a way so your answer still fits)  
> **username_3**: @KamilSJaron I agree the question should be kept, but maybe change the title to reflect the error message, this has nothing to do with NCBI  
> **username_4**: Also note that Snakemake has an NCBI remote provider: http://snakemake.readthedocs.io/en/stable/snakefiles/remote_files.html#genbank-ncbi-entrez  
> **username_0**: @JohannesKöster I was looking at it. But since I could not make it work without remote I have not even tried with remote. And then the problem I originally had with non-remote solution is very much unrelated to downloading of sequences. It's a good tip though, maybe work an answer?  

---

### Answer by username_1 on 2017-11-03. Score: 3

Given the Makefile you provided and which someone then deleted from the question, you should probably just add this line (this should be the first rule):

`rule all: input: ["data/{}/genome.fa.gz".format(x) for x in species.split()]`

This rule just specifies a list of expected output files and corresponds to the following lines from the original `Makefile`:

`GENOMES=$(patsubst %, data/%/genome.fa.gz, $(SPECIES))
all : $(GENOMES)`

> **Comments:**
> **username_0**: I have deleted Make equivalent since was not really related to the problem.  

---

