Search code examples
syntax-errorrulessnakemake

Snakemake SyntaxError: No rule keywords allowed after run/shell/script/wrapper/cwl in rule


There is some problem in 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 = dup_fun
        output: protected(f'{dupDir}' + "/" + f'{mrDup}dup.bam')
        shell: "samtools {params.fun} -s {input} {output}"


Solution

  • I see a syntax error in your snippet: there is a closing bracket without an opening bracket in the input section:

    input: f'{bamDir}' + '/{sample}_sort.bam')
                                             ^ where is the opening bracket?
    

    There may be other syntax errors in your file, but you definitely provide just a small portion of it.