# snakemake - using output file not explicitly declared as input for subsequent rule

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:

rule minimap:
input:
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).

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.