text: user3452: 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).
  
  user4766: 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. 
  
original_text: 3452: <p>I am writing a snakemake that, up to now should</p>
  
  <ol>
  <li>use raw sequencing reads to produce a draft assembly using <a href="https://github.com/marbl/canu" rel="nofollow noreferrer">canu</a> </li>
  <li>use <a href="https://github.com/lh3/minimap2" rel="nofollow noreferrer">minimap2</a> to align the raw reads against the draft assembly, generated by canu.</li>
  </ol>
  
  <p>The following two rules are described below:</p>
  
  <pre><code>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} &gt; {output}"
  </code></pre>
  
  <p>However, if I do <code>snakemake -np</code> I get <code>Missing input files for rule minimap</code>. Which does make sense, after all I am not specifying the input for rule <code>minimap</code> (<code>{sample}/canu/{sample}.contigs.fasta</code>) anywhere i.e. snakemake cannot know that the file <code>{sample}/canu/{sample}.contigs.fasta</code> will be generated by canu. </p>
  
  <p>The thing is that <code>canu</code> produces several files as output (amongst which the file <code>{sample}/canu/{sample}.contigs.fasta</code> is one of them), that's why I specified its output as a <code>directory</code>.</p>
  
  <p>One way of solving this I guess would be to specify <a href="https://canu.readthedocs.io/en/latest/tutorial.html#outputs" rel="nofollow noreferrer">all output files</a> produced by canu as an individual rule output (e.g. <code>{sample}/canu/{sample}.contigs.fasta</code>, <code>{sample}/canu/{sample}.report</code>, <code>{sample}/canu/{sample}.correctedReads.fasta.gz</code>), though I am looking for a more robust way to do so (if that's possible at all).</p>
   4766: <p>Another way is to add one command after minimap: <code>touch done.txt</code>. This creates an empty file after minimap is finished. This can then be used in output rule for snakemake.</p>
  
  <p>But specifying all the output files may not be a bad idea if these outputs are used in subsequent rules. </p>
  