snakemake Unexpected keyword bam in rule definition
Entering edit mode
7 weeks ago
Aidand • 0

I am trying to automate GVF calling via DeepVariant using snakemake with this file based on snakemakes own documentation on using deepvariant via wrapper (

# check if logfile exists or make new if it doesn't
import os.path

if not os.path.exists("slurm_logs"):

# define samples used for the whole process
(INDIV,) = glob_wildcards(

# this rule collects results and is the final step of the code
# once the input of rule all is reached, snakemake knows that it's finished
rule all:
            expand('pangenome_gvcfs/{id}.g.vcf.gz', id=INDIV)

# variant call intermediate VCFs from individual bams
rule deepvariant_GVCF :
        bam = "aligned_sorted_marked_rg/{id}.sorted.marked.rg.bam",
        ref = "Pangenome/Chickpea3000_pangenome_nr.fa"
        gvcf = "pangenome_gvcfs/{id}.g.vcf.gz",
        vcf = "pangenome_gvcfs/{id}.vcf.gz"
        model = "wgs"
        extra = ""
    threads: 2

however when I try to run this it returns this error:

Unexpected keyword bam in rule definition (snakefile-DV, line 25)

Is there some mistake in the indentation?

snakemake • 399 views
Entering edit mode

That's not the error I get when running what your provided.
First, the first line has a syntax error, and so I skipped including your first line when copy-pasting. When I ran lines 2 through the end of your code, I got:

SyntaxError in line 31 of /home/jovyan/Snakefile:
invalid syntax

I corrected that buy adding a comma to the end of the line model = "wgs".

After that edit, it ran without any error. I didn't have any bam files where I was running it.

So I made a file directory, aligned_sorted_marked_rg and inside that I put two files with no content that matched the name pattern {id}.sorted.marked.rg.bam. Then I ran again. I didn't see the error you talk about. I saw a different error which seemed to involve Pangenome/Chickpea3000_pangenome_nr.fa which is after the line you are suggesting Snakemake is having an issue with.

I was testing with Snakemake 7.18.2. What version are you using? Check with snakemake -v.

So either it is something specific to your version of Snakemake or when you have the files necessary to really run it? Or something unusual. It'd help more to debug if you could provide a minimal reproducible example.

Entering edit mode

I'm running version 7.18.1, the first line is missing a \ at the beginning but the first section of the file is just for setting up a log file directory so it's not relevant.

Entering edit mode

Any chance it is an indentation issue that isn't caused by what you aren't sharing here? See here.

You may be able to test it by making a copy if your file and reducing it close to what I say didn't give that error and then part parts in the top part back.


Login before adding your answer.

Traffic: 1365 users visited in the last hour
Help About
Access RSS

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

Powered by the version 2.3.6