snakemake running nanopolish and making it wait until previous rule is done

206 views Asked by At

Hi I can run the different steps of nanopolish with snakemake. But when I run it it will give an error that the index file created in the bwa rule isnt available yet. After it gives this error it creates the file it that the error was about. If I run snakemake again without removing files it works because the file is there. How can I tell snake make to wait with the next step until the first one is done? I have googled on any ways to solve this problem and all I could find was priority and ruleorder and I have used those but it still doesnt work. Here is the script that I use.

ruleorder: bwa > nanopolish
rule bwa:
    input:
        "nanopolish/assembly.fasta"
    output:
        "nanopolish/draft.fa"
    conda:
        "envs/nanopolish.yaml"
    priority:
        50
    shell:
        "bwa index {input} - > {output}"

rule nanopolish:
    input:
        "nanopolish/assembly.fasta",
        "zipped/zipped.gz"
    output:
        "nanopolish/reads.sorted.bam"
    conda:
        "envs/nanopolish.yaml"
    shell:
        "bwa mem -x ont2d {input} | samtools sort -o {output} -T reads.tmp"

1

There are 1 answers

0
Maarten-vd-Sande On

You should take a look again at the docs to properly understand the idea of SnakeMake.

Rules describe how to create output files from input files

A rule is not executed until all its input exists, so all you have to do is add the output of the bwa rule

rule nanopolish:
    input:
        "nanopolish/assembly.fasta",
        "nanopolish/draft.fa",  # <-- output of bwa
        "zipped/zipped.gz"

Ruleorder and priority are not relevant solutions for your problem.