0
$\begingroup$

I am writing a snakemake that, up to now should

  1. use raw sequencing reads to produce a draft assembly using canu
  2. use minimap2 to align the raw reads against the draft assembly, generated by canu.

The following two rules are described below:

rule canu:
    input:
        fqdir + "{sample}.fastq"
    output:
        directory("{sample}/canu")
    shell:
        "/home/bhinckel/downloads/canu-1.9/Linux-amd64/bin/canu genomeSize=4.1m -p {wildcards.sample} -d {output} -nanopore-raw {input}"


rule minimap:
    input:
        reads = fqdir + "{sample}.fastq",
        draft_assembly = "{sample}/canu/{sample}.contigs.fasta"
    output:
        "{sample}/aligned/{sample}.sam"
    conda:
        "envs/general.yaml"
    shell:
        "minimap2 -ax map-ont {input.draft_assembly} {input.reads} > {output}"

However, if I do snakemake -np I get Missing input files for rule minimap. Which does make sense, after all I am not specifying the input for rule minimap ({sample}/canu/{sample}.contigs.fasta) anywhere i.e. snakemake cannot know that the file {sample}/canu/{sample}.contigs.fasta will be generated by canu.

The thing is that canu produces several files as output (amongst which the file {sample}/canu/{sample}.contigs.fasta is one of them), that's why I specified its output as a directory.

One way of solving this I guess would be to specify all output files produced by canu as an individual rule output (e.g. {sample}/canu/{sample}.contigs.fasta, {sample}/canu/{sample}.report, {sample}/canu/{sample}.correctedReads.fasta.gz), though I am looking for a more robust way to do so (if that's possible at all).

$\endgroup$
1
$\begingroup$

Another way is to add one command after minimap: touch done.txt. This creates an empty file after minimap is finished. This can then be used in output rule for snakemake.

But specifying all the output files may not be a bad idea if these outputs are used in subsequent rules.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.