Question: Snakemake SyntaxError: No rule keywords allowed after run/shell/script/wrapper/cwl in rule
1
gravatar for msimmer92
9 weeks ago by
msimmer92250
Uruguay
msimmer92250 wrote:

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}"
ADD COMMENTlink modified 9 weeks ago • written 9 weeks ago by msimmer92250
1

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

ADD REPLYlink written 9 weeks ago by Devon Ryan95k

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 REPLYlink modified 9 weeks ago • written 9 weeks ago by msimmer92250
1

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

ADD REPLYlink written 9 weeks ago by Devon Ryan95k
2
gravatar for msimmer92
9 weeks ago by
msimmer92250
Uruguay
msimmer92250 wrote:

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 COMMENTlink modified 9 weeks ago • written 9 weeks ago by msimmer92250
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1419 users visited in the last hour