Can I execute a snakemake rule only once?
1
0
Entering edit mode
2.2 years ago
blackadder ▴ 30

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?

Thanking you in advance.

Snakemake GTDB-TK Kraken2 • 942 views
ADD COMMENT
3
Entering edit mode
2.2 years ago
liorglic ★ 1.4k

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"
    shell: "kraken download -o 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.

ADD COMMENT
0
Entering edit mode

Hello there!

Your reply worked!

Thank you very much

ADD REPLY

Login before adding your answer.

Traffic: 2629 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6