I am writing a snakemake that, up to now should
- use raw sequencing reads to produce a draft assembly using canu
- 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).