<p>you are starting <code>snakemake</code> the wrong way. </p>

<pre><code>snakemake snakemake
</code></pre>

<p>means "Running the pipeline in <code>Snakefile</code> until you reach a rule named <code>snakemake</code> or a file name <code>snakemake</code> is created."</p>

<p>If your snakefile is called <code>snakemake</code> and this is the pipeline you want to start, the correct syntax would be: </p>

<pre><code>snakemake -s snakemake
</code></pre>

CC BY-SA 4.0
2018-12-11T14:16:19.630Z
Thanks - another one of the stupid mistake - since dry runs are also automated; I didn't notice that the driver was using using `snakemake snakemake` - should have noticed it while posting the question. Although I discovered it earlier, I guess this question should still stay online.
Siddharth
CC BY-SA 4.0
2018-12-11T13:36:57.480Z
2018-12-11T14:15:52.097Z
2018-12-11T14:15:52.097Z
finswimmer
<p>Back again with another snakemake query. This time I decided to port my read cleaning and alignment pipeline to snakemake. Repeating the steps from previous question and trying not to make any typo here, I'm now receiving this "error" while trying a dry run using <code>snakemake snakemake -nr -s alignMake</code>:</p>

<pre><code>Building DAG of jobs...
MissingRuleException:
No rule to produce snakemake (if you use input functions make sure that they don't raise unexpected exceptions).
</code></pre>

<p>Below is my snakefile: </p>

<pre><code>import os
shell.executable("/bin/bash")

workdir: '/proj/uppstore2018136/publication/jupyterNotebooks'

pathToPEReads = 'raw_data/reads/BL6/totalRNA'
pathToSMReads = 'raw_data/reads/BL6/smallRNA'

pathToHISAT2index = 'indexes/hisat2/reference'
pathToBOWTIE2index = 'indexes/bowtie2/reference'

pathToTemp = 'temp/'
pathToBAM = 'processed_data/BAM'

readsPE, = glob_wildcards('raw_data/reads/BL6/totalRNA/{sample}_1.fastq.gz')
readsSE, = glob_wildcards('raw_data/reads/BL6/smallRNA/{sample}.fq.gz')

samToolsThreads = 6

rule all:
    input:
        expand('processed_data/BAM/{sample}.bam', sample=readsPE),
        expand('processed_data/BAM/{sample}.bam', sample=readsSE)

rule trimgalorePE:
    input:
        fastq1 = pathToPEReads + '{sample}_1.fastq.gz',
        fastq2 = pathToPEReads + '{sample}_2.fastq.gz'
    output:
        output1 = pathToTemp + '{sample}_1_val_1.fq.gz',
        output2 = pathToTemp + '{sample}_2_val_2.fq.gz'
    shell:
        '''
        module load bioinfo-tools
        module load cutadapt
        module load TrimGalore
        trim_galore --quality 20 --paired --length 80 --illumina --stringency 2 --clip_R1 11 --clip_R2 11 -o {pathToTemp} --paired {input.fastq1} {input.fastq2}
        '''

rule trimgaloreSEandDust:
    input:
        fastq = pathToSMReads + '{sample}.fq.gz',
    output:
        output = pathToTemp + '{sample}_trimmed.fq.gz',
    shell:
        '''
        module load bioinfo-tools
        module load cutadapt
        module load TrimGalore
        trim_galore --quality 20 --length 16 --max_length 32 --small_rna --fastqc --stringency 2 -o {pathToTemp} {input.fastq}
        '''

rule align_hisat2:
    input:
        fastq1 = pathToTemp + '{sample}_1_val_1.fq.gz',
        fastq2 = pathToTemp + '{sample}_2_val_2.fq.gz'
    output: 
        output = 'processed_data/BAM/{sample}.bam'
    threads: 10
    shell:
        '''
        module load bioinfo-tools
        module load HISAT2
        module load samtools
        hisat2 -q -p {threads} --no-discordant --no-mixed --rna-strandness RF --dta -x {pathToHISAT2index} -1 {input.fastq1} -2 {input.fastq2} | samtools sort -@ {samToolsThreads} -o {output}
        '''

rule align_bowtie2:
    input:
        fastq = pathToTemp + '{sample}_trimmed.fq.gz'
    output: 
        output = 'processed_data/BAM/{sample}.bam'
    threads: 10
    shell:
        '''
        module load bioinfo-tools
        module load bowtie2
        module load samtools
        bowtie2 --no-unal --end-to-end -D 20 -R 3 -N 1 -L 20 -i S,1,0.50 -p {threads} -x {pathToBOWTIE2index} -U {fastq} | samtools sort -@ {samToolsThreads} -o {output}
        '''

rule clean:
    shell:
        '''
        rm temp/*
        '''
</code></pre>

<p>I believe it is due snakemake being unable to find the first rule ? Maybe there is something wrong with parsing ? I tested the <code>glob_wildcards</code> and <code>expand</code> function independently and they appear to work properly. </p>

<p>Edit: Here is the directory tree:</p>

<pre><code>.
├── citations
├── doc
├── genome
│   ├── genome.fa
│   └── Mus_musculus.GRCm38.94.gtf
├── indexes
│   ├── bowtie2
│   │   ├── reference.1.bt2
│   │   ├── reference.2.bt2
│   │   ├── reference.3.bt2
│   │   ├── reference.4.bt2
│   │   ├── reference.rev.1.bt2
│   │   └── reference.rev.2.bt2
│   └── hisat2
│       ├── reference.1.ht2
│       ├── reference.2.ht2
│       ├── reference.3.ht2
│       ├── reference.4.ht2
│       ├── reference.5.ht2
│       ├── reference.6.ht2
│       ├── reference.7.ht2
│       └── reference.8.ht2
├── LICENSE
├── notebooks
├── plots
├── processed_data
│   └── BAM
├── raw_data
│   └── reads
│       └── BL6
│           ├── smallRNA
│           │   ├── smBL6_1.fq.gz
│           │   ├── smBL6_2.fq.gz
│           │   └── smBL6_3.fq.gz
│           └── totalRNA
│               ├── EKIxxxx012_1.fastq.gz
│               ├── EKIxxxx012_2.fastq.gz
│               ├── EKIxxxx013_1.fastq.gz
│               ├── EKIxxxx013_2.fastq.gz
│               ├── EKIxxxx014_1.fastq.gz
│               ├── EKIxxxx014_2.fastq.gz
│               ├── ESSxxxx077_1.fastq.gz
│               └── ESSxxxx077_2.fastq.gz
├── README.md
├── recipes
│   ├── alignMake
│   ├── cluster.json
│   ├── indexMake
│   ├── indexMakeScript.out
│   └── indexMakeScript.sh
├── results
├── scripts
├── slurmLogs
│   ├── slurm-6575541.out
│   ├── slurm-6575543.out
│   ├── slurm-6575815.out
│   └── slurm-6580867.out
├── source
└── temp
</code></pre>

CC BY-SA 4.0
2018-12-11T15:28:10.700Z
Loosely related, I think your rule `clean` is never executed unless your run snakemake as `snakemake [opts] clean`. If you want to clean up stuff on completion, maybe look at the *onsuccess* and similar [handlers](https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#onstart-onsuccess-and-onerror-handlers). Also consider the [temp](https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#protected-and-temporary-files) flag...
dariober
CC BY-SA 4.0
2018-12-12T13:11:21.687Z
@dariober - I agree. I didn't knew about onsuccess. I will include such handlers in future scripts. But the reason why I didn't want to automatically use clean was to manually check if things happened properly in background.
Siddharth
<python><snakemake>
Snakemake: Cannot find first rule?
# Snakemake: Cannot find first rule?

(Asked by: username_0 on 2018-12-10)

Back again with another snakemake query. This time I decided to port my read cleaning and alignment pipeline to snakemake. Repeating the steps from previous question and trying not to make any typo here, I'm now receiving this "error" while trying a dry run using snakemake snakemake -nr -s alignMake:
Building DAG of jobs...
MissingRuleException:
No rule to produce snakemake (if you use input functions make sure that they don't raise unexpected exceptions).

Below is my snakefile: 
import os
shell.executable("/bin/bash")

workdir: '/proj/uppstore2018136/publication/jupyterNotebooks'

pathToPEReads = 'raw_data/reads/BL6/totalRNA'
pathToSMReads = 'raw_data/reads/BL6/smallRNA'

pathToHISAT2index = 'indexes/hisat2/reference'
pathToBOWTIE2index = 'indexes/bowtie2/reference'

pathToTemp = 'temp/'
pathToBAM = 'processed_data/BAM'

readsPE, = glob_wildcards('raw_data/reads/BL6/totalRNA/{sample}_1.fastq.gz')
readsSE, = glob_wildcards('raw_data/reads/BL6/smallRNA/{sample}.fq.gz')

samToolsThreads = 6

rule all:
    input:
        expand('processed_data/BAM/{sample}.bam', sample=readsPE),
        expand('processed_data/BAM/{sample}.bam', sample=readsSE)

rule trimgalorePE:
    input:
        fastq1 = pathToPEReads + '{sample}_1.fastq.gz',
        fastq2 = pathToPEReads + '{sample}_2.fastq.gz'
    output:
        output1 = pathToTemp + '{sample}_1_val_1.fq.gz',
        output2 = pathToTemp + '{sample}_2_val_2.fq.gz'
    shell:
        '''
        module load bioinfo-tools
        module load cutadapt
        module load TrimGalore
        trim_galore --quality 20 --paired --length 80 --illumina --stringency 2 --clip_R1 11 --clip_R2 11 -o {pathToTemp} --paired {input.fastq1} {input.fastq2}
        '''

rule trimgaloreSEandDust:
    input:
        fastq = pathToSMReads + '{sample}.fq.gz',
    output:
        output = pathToTemp + '{sample}_trimmed.fq.gz',
    shell:
        '''
        module load bioinfo-tools
        module load cutadapt
        module load TrimGalore
        trim_galore --quality 20 --length 16 --max_length 32 --small_rna --fastqc --stringency 2 -o {pathToTemp} {input.fastq}
        '''

rule align_hisat2:
    input:
        fastq1 = pathToTemp + '{sample}_1_val_1.fq.gz',
        fastq2 = pathToTemp + '{sample}_2_val_2.fq.gz'
    output: 
        output = 'processed_data/BAM/{sample}.bam'
    threads: 10
    shell:
        '''
        module load bioinfo-tools
        module load HISAT2
        module load samtools
        hisat2 -q -p {threads} --no-discordant --no-mixed --rna-strandness RF --dta -x {pathToHISAT2index} -1 {input.fastq1} -2 {input.fastq2} | samtools sort -@ {samToolsThreads} -o {output}
        '''

rule align_bowtie2:
    input:
        fastq = pathToTemp + '{sample}_trimmed.fq.gz'
    output: 
        output = 'processed_data/BAM/{sample}.bam'
    threads: 10
    shell:
        '''
        module load bioinfo-tools
        module load bowtie2
        module load samtools
        bowtie2 --no-unal --end-to-end -D 20 -R 3 -N 1 -L 20 -i S,1,0.50 -p {threads} -x {pathToBOWTIE2index} -U {fastq} | samtools sort -@ {samToolsThreads} -o {output}
        '''

rule clean:
    shell:
        '''
        rm temp/*
        '''

I believe it is due snakemake being unable to find the first rule ? Maybe there is something wrong with parsing ? I tested the glob_wildcards and expand function independently and they appear to work properly. 
Edit: Here is the directory tree:
.
├── citations
├── doc
├── genome
│   ├── genome.fa
│   └── Mus_musculus.GRCm38.94.gtf
├── indexes
│   ├── bowtie2
│   │   ├── reference.1.bt2
│   │   ├── reference.2.bt2
│   │   ├── reference.3.bt2
│   │   ├── reference.4.bt2
│   │   ├── reference.rev.1.bt2
│   │   └── reference.rev.2.bt2
│   └── hisat2
│       ├── reference.1.ht2
│       ├── reference.2.ht2
│       ├── reference.3.ht2
│       ├── reference.4.ht2
│       ├── reference.5.ht2
│       ├── reference.6.ht2
│       ├── reference.7.ht2
│       └── reference.8.ht2
├── LICENSE
├── notebooks
├── plots
├── processed_data
│   └── BAM
├── raw_data
│   └── reads
│       └── BL6
│           ├── smallRNA
│           │   ├── smBL6_1.fq.gz
│           │   ├── smBL6_2.fq.gz
│           │   └── smBL6_3.fq.gz
│           └── totalRNA
│               ├── EKIxxxx012_1.fastq.gz
│               ├── EKIxxxx012_2.fastq.gz
│               ├── EKIxxxx013_1.fastq.gz
│               ├── EKIxxxx013_2.fastq.gz
│               ├── EKIxxxx014_1.fastq.gz
│               ├── EKIxxxx014_2.fastq.gz
│               ├── ESSxxxx077_1.fastq.gz
│               └── ESSxxxx077_2.fastq.gz
├── README.md
├── recipes
│   ├── alignMake
│   ├── cluster.json
│   ├── indexMake
│   ├── indexMakeScript.out
│   └── indexMakeScript.sh
├── results
├── scripts
├── slurmLogs
│   ├── slurm-6575541.out
│   ├── slurm-6575543.out
│   ├── slurm-6575815.out
│   └── slurm-6580867.out
├── source
└── temp

**Tags:** python, snakemake
> **Comments:**
> **username_1**: Loosely related, I think your rule `clean` is never executed unless your run snakemake as `snakemake [opts] clean`. If you want to clean up stuff on completion, maybe look at the *onsuccess* and similar [handlers](https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#onstart-onsuccess-and-onerror-handlers). Also consider the [temp](https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#protected-and-temporary-files) flag...  
> **username_0**: @dariober - I agree. I didn't knew about onsuccess. I will include such handlers in future scripts. But the reason why I didn't want to automatically use clean was to manually check if things happened properly in background.  

---

## 1 answers

### Answer by username_2 on 2018-12-11. Score: 9 | Accepted answer

you are starting snakemake the wrong way. 
snakemake snakemake

means "Running the pipeline in Snakefile until you reach a rule named snakemake or a file name snakemake is created."
If your snakefile is called snakemake and this is the pipeline you want to start, the correct syntax would be: 
snakemake -s snakemake

> **Comments:**
> **username_0**: Thanks - another one of the stupid mistake - since dry runs are also automated; I didn't notice that the driver was using using `snakemake snakemake` - should have noticed it while posting the question. Although I discovered it earlier, I guess this question should still stay online.  

---

