Snakemake SyntaxError: No rule keywords allowed after run/shell/script/wrapper/cwl in rule
1
1
Entering edit mode
13 months ago
msimmer92 ▴ 290

There is some problem with my samtools_dup rule.

It says "SyntaxError in line 201 of /data/mypipeline.smk: No rule keywords allowed after run/shell/script/wrapper/cwl in rule samtools_dup. (mypipeline.smk, line 201)".

If I google the error, I found that a person says that, in their code, might be that he placed the "log:" after the "shell:" (and that the shell should be the last thing in each rule), but in my code that is not the case. In many other forums I saw people posting it but no answer was recorded. I am not sure where else this mistake can be... any thoughts? Thank you !

Here I post the code for you to take a look.

dup_fun = "rmdup"
# Mark or remove duplicates with Samtools
if ( mrDup == "mark" or mrDup == "rm" ):
    rule samtools_dup:
        input: f'{bamDir}' + '/{sample}_sort.bam')
        params: fun = "rmdup"
        output: protected(f'{dupDir}' + "/" + f'{mrDup}dup.bam')
        shell: "samtools {params.fun} -s {input} {output}"

Edited: when I delete this rule from the pipeline, the error goes away with it. What comes next in the code is my bigwig rule:

# Bigwig with Deeptools bamCoverage
if ( bigWig == "yes" ):
    rule bigwig:
        input:
            bam = f'{bamDir}' + '/{sample}.bam',
            bai = f'{bamDir}' + '/{sample}.bai'
        output: f'{bwDir}' + '/{sample}.bw'
        params:
            xtnd = bwXtnd ,
            bs = binSize ,
            nrm = normBW ,
            effgs = effGS ,
            bl = f'-bl {blBed}'
        conda:
            "envs/deeptools.yaml"
        threads: maxThreads
        shell:
            "bamCoverage -b {input.bam} -bs {params.bs} --normalizeUsing {params.nrm} --effectiveGenomeSize {params.effgs} -o {output} {params.xtnd} {params.bl}"
snakemake syntaxerror rule keywords • 812 views
ADD COMMENT
1
Entering edit mode

What comes after the shell: line? Most likely you have an indentation problem later, since what you posted looks fine.

ADD REPLY
0
Entering edit mode

There is an empty line (two enters, from the end of the shell line) and then what you see in the second code panel (the bigwig rule - I added it now to this question). When I delete the samtools_dup rule, the code works. I'll try to put it again and double-check indentations, but the next rule's first two lines don't have any (the comment and the if clause). (ps: this is for chip-seq data)

ADD REPLY
1
Entering edit mode

My only guess is that there's a single space missing somewhere, since otherwise everything looks fine to me.

ADD REPLY
2
Entering edit mode
13 months ago
msimmer92 ▴ 290

Dmitry Kuzminov solved it in StackOverflow. I share the answer here, in case someone has the same doubt! It seems there is an extra parenthesis at the end of the "input" line in the samtools_dup rule. I honestly didn't spot it, and also the error message made me think the problem wasn't there but around the "shell" statement.

https://stackoverflow.com/questions/60914204/snakemake-syntaxerror-no-rule-keywords-allowed-after-run-shell-script-wrapper-c/60924399#60924399

ADD COMMENT

Login before adding your answer.

Traffic: 2003 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6