2
$\begingroup$

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
$\endgroup$
2
  • $\begingroup$ 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. Also consider the temp flag... $\endgroup$
    – dariober
    Dec 11, 2018 at 15:28
  • $\begingroup$ @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. $\endgroup$
    – Siddharth
    Dec 12, 2018 at 13:11

1 Answer 1

8
$\begingroup$

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
$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$
    – Siddharth
    Dec 11, 2018 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.