title: Please explain me why i am getting this error in snakemake? I´ve been strugling for days please advise me on whats going wrong
body: <p>I wrote this pipeline in snakemake to process my fastq files and get the raw counts but for some reason that I don't understand in the last rule (featurecounts) I get this error:</p>
  <blockquote>
  <p>WildcardError in line 175 of /mnt/c/Users/manso/Desktop/hel/pe.py:
  Wildcards in input files cannot be determined from output files: 'sample'</p>
  </blockquote>
  <p>Other rules use the same input as featureCounts rule so I don't understand why it returns this error for that specific rule.</p>
  <p>I'd really appreciate your help.</p>
  <p>Here is my snakefile:</p>
  <pre><code>(SAMPLE,FRR) = glob_wildcards(&quot;rawReads/{sample}_{frr}.fastq.gz&quot;)
  
  rule all:
      input:
          #raw_FASTQC
          expand(&quot;rawQC/fastqc/{sample}_{frr}_fastqc.html&quot;, sample=SAMPLE, frr=FRR),
          expand(&quot;rawQC/fastqc/{sample}_{frr}_fastqc.zip&quot;, sample=SAMPLE, frr=FRR),
          #raw_MultiQC
          &quot;rawQC/multiqc_report.html&quot;,
          #FASTP
          expand(&quot;trimmedReads/{sample}_1.fastq.gz&quot;, sample=SAMPLE),
          expand(&quot;trimmedReads/{sample}_2.fastq.gz&quot;, sample=SAMPLE),
          expand(&quot;trimmedReads/{sample}_fastp_report.html&quot;, sample=SAMPLE),        
          #trimmed_FASTQC
          expand(&quot;trimmedQC/fastqc/{sample}_{frr}_fastqc.html&quot;, sample=SAMPLE, frr=FRR),
          expand(&quot;trimmedQC/fastqc/{sample}_{frr}_fastqc.zip&quot;, sample=SAMPLE, frr=FRR),
          #trimmed_MultiQC
          &quot;trimmedQC/multiqc_report.html&quot;,
          #get fa and gtf files
          &quot;genome/Homo_sapiens.GRCh38.dna_sm.primary_assembly.fa&quot;,
          &quot;genome/Homo_sapiens.GRCh38.106.gtf.gz&quot;,
          #HISAT2_index
          [&quot;index.&quot;  + str(i) + &quot;.ht2&quot; for i in range(1,9)],
          #HISAT_align
          expand(&quot;aligned/{sample}.bam&quot;, sample=SAMPLE),
          #samtools
          expand(&quot;aligned/{sample}.sorted.bam&quot;, sample=SAMPLE),
          expand(&quot;samtools_stats/{sample}.stats.txt&quot;, sample=SAMPLE),
          expand(&quot;samtools_stats/{sample}.flagstat.txt&quot;, sample=SAMPLE),
          #rawCounts
          &quot;raw_Counts&quot;
  
  
  rule raw_FASTQC:
      input:
          &quot;rawReads/{sample}_{frr}.fastq.gz&quot;,
      output:
          html=&quot;rawQC/fastqc/{sample}_{frr}_fastqc.html&quot;,
          zip= &quot;rawQC/fastqc/{sample}_{frr}_fastqc.zip&quot;, # the suffix _fastqc.zip is necessary for multiqc to find the file. If not using multiqc, you are free to choose an arbitrary filename
      params: &quot;--quiet&quot;
      log:
          &quot;logs/fastqc/{sample}_{frr}.log&quot;
      threads: 16
      wrapper:
          &quot;v1.7.0/bio/fastqc&quot;
  
  
  rule raw_MultiQC:
      input:
          expand(&quot;rawQC/fastqc/{sample}_{frr}_fastqc.zip&quot;, sample=SAMPLE, frr=FRR),
      params:
          path=&quot;rawQC/fastqc&quot;
      output:
         &quot;rawQC/multiqc_report.html&quot;
      shell:
          &quot;multiqc --force -n {output} {params.path}&quot; 
  
  
  rule FASTP:
      input:
           read1=&quot;rawReads/{sample}_1.fastq.gz&quot;,
           read2=&quot;rawReads/{sample}_2.fastq.gz&quot;,
      output:
          trimmed1=&quot;trimmedReads/{sample}_1.fastq.gz&quot;,
          trimmed2=&quot;trimmedReads/{sample}_2.fastq.gz&quot;,
          report_html= &quot;trimmedReads/{sample}_fastp_report.html&quot;,
      threads: 16
      shell:
           &quot; fastp --thread {threads} -i {input.read1} -I {input.read2} -o {output.trimmed1} -O {output.trimmed2} -h {output.report_html} &quot;
  
  
  rule trimmed_FASTQC:
      input:
          &quot;trimmedReads/{sample}_{frr}.fastq.gz&quot;
      output:
          html=&quot;trimmedQC/fastqc/{sample}_{frr}_fastqc.html&quot;, 
          zip=&quot;trimmedQC/fastqc/{sample}_{frr}_fastqc.zip&quot;,  # the suffix _fastqc.zip is necessary for multiqc to find the file. If not using multiqc, you are free to choose an arbitrary filename
      params: &quot;--quiet&quot;
      log:
          &quot;logs/fastqc/{sample}_{frr}.log&quot;
      threads: 16
      wrapper:
          &quot;v1.7.0/bio/fastqc&quot;
          
  
  rule trimmed_MultiQC:
      input:
          expand(&quot;trimmedQC/fastqc/{sample}_{frr}_fastqc.zip&quot;, sample=SAMPLE, frr=FRR),
      params:
          path=&quot;trimmedQC/fastqc&quot;
      output:
         &quot;trimmedQC/multiqc_report.html&quot;
      shell:
          &quot;multiqc --force -n {output} {params.path} &quot;
  
  
  #Get annotation GTF
  rule get_genome_gtf:
      &quot;Downloading Genome annotation file from Ensemble, Homo sapiens primary assembly (GRCh38)&quot;
      output:
          gtf = &quot;genome/Homo_sapiens.GRCh38.106.gtf.gz&quot;
      shell:
          &quot;cd genome&quot;
          &quot; &amp;&amp; wget ftp://ftp.ensembl.org/pub/release-106/gtf/homo_sapiens/Homo_sapiens.GRCh38.106.gtf.gz&quot;
          &quot; &amp;&amp; gunzip -k Homo_sapiens.GRCh38.106.gtf.gz &quot;
  
  
  # Get genome fa
  rule get_genome_fa:
      &quot;Downloading Genome sequence, Homo sapiens primary assembly (GRCh38)&quot;
      output:
          fa = &quot;genome/Homo_sapiens.GRCh38.dna_sm.primary_assembly.fa&quot;
      shell:
          &quot;cd genome&quot;
          &quot; &amp;&amp; wget ftp://ftp.ensembl.org/pub/release-106/fasta/homo_sapiens/dna/Homo_sapiens.GRCh38.dna_sm.primary_assembly.fa.gz&quot;
          &quot; &amp;&amp; gunzip -k Homo_sapiens.GRCh38.dna_sm.primary_assembly.fa &quot;
  
  
  rule HISAT2_index:
      input:
          fa = rules.get_genome_fa.output.fa
      output:
          [&quot;index.&quot; + str(i) + &quot;.ht2&quot; for i in range(1,9)],
      message:
          &quot;indexing genome&quot;
      threads: 16
      shell:
          &quot; hisat2-build -p {threads} {input.fa} index --quiet&quot;
  
  
  rule HISAT2_align:
      input:
          read1=rules.FASTP.output.trimmed1,
          read2=rules.FASTP.output.trimmed2,
          index=rules.HISAT2_index.output
      output:
          bam=&quot;aligned/{sample}.bam&quot;,
          metrics=&quot;logs/{sample}_HISATmetrics.txt&quot;
      threads: 16
      shell:
          &quot; hisat2 --threads {threads} -x index -1 {input.read1} -2 {input.read2} 2&gt; {output.metrics}&quot;
          &quot; | samtools view -Sbh -o {output.bam} &quot;
  
  
  rule samtools_sort:
      input:
          aligned=rules.HISAT2_align.output.bam
          #&quot;aligned/{sample}.bam&quot;
      output:
          &quot;aligned/{sample}.sorted.bam&quot;
      threads: 8 
      shell:
         &quot;samtools sort {input.aligned} -o {output}&quot;
  
  
  rule samtools_stats:
      input:
          &quot;aligned/{sample}.sorted.bam&quot;,
      output:
          &quot;samtools_stats/{sample}.stats.txt&quot;,
      shell:
         &quot;samtools stats {input} &gt; {output} &quot;
  
  rule samtools_flagstat:
      input:
          &quot;aligned/{sample}.sorted.bam&quot;,
      output:
          &quot;samtools_stats/{sample}.flagstat.txt&quot;,
      shell:
          &quot;samtools flagstat {input} &gt; {output} &quot;
          
  
  rule featureCounts:
      input:
          samples=&quot;aligned/{sample}.sorted.bam&quot;,   
          gtf=rules.get_genome_gtf.output.gtf
      output:
          &quot;raw_Counts&quot;
      threads:
          16
      shell:
          &quot;featureCounts -T {threads} -a {input.gtf} -o {output} {input.samples}&quot;
  ´´´
  </code></pre>