Can I execute a snakemake rule only once?
1
0
Entering edit mode
9 months ago

Hello fellas,

I hope everyone is doing good!

I have another snakemake question.

I am trying to incorporate tools like kraken2 and GTDB-TK in my pipeline. The issue with these two is that before they actually perform the analysis they have to download/build a database.

So what I was thinking of creating a rule to run the downloading/building database separately from the kraken2/GTDB-TK analysis and, more importantly, only once.

Is that possible? Can I create a rule that will be executed only once in my pipeline? If yes, how can I do this?

Snakemake GTDB-TK Kraken2 • 367 views
3
Entering edit mode
9 months ago
liorglic ★ 1.1k

Sure you can. A rule that only creates one output file will run only once. You don't have to specify it in any special way. For example:

rule download_kraken_db:
output: "kraken.db"

rule run_kraken:
input:
db="kraken.db",
fq="{sample}.fq"
output: "{sample}_clean.fq"
shell: "kraken run {input.db} {input.fq} > {output}"


No matter how many times the rule run_kraken needs to run, download_kraken_db will still run only once.

0
Entering edit mode

Hello there!

Thank you very much