snakemake Unexpected keyword bam in rule definition
0
0
Entering edit mode
10 months 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 (https://snakemake-wrappers.readthedocs.io/en/stable/wrappers/deepvariant.html#deepvariant):

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

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

# define samples used for the whole process
(INDIV,) = glob_wildcards(
    "aligned_sorted_marked_rg/{id}.sorted.marked.rg.bam"
)


# 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:
    input:
        [
            expand('pangenome_gvcfs/{id}.g.vcf.gz', id=INDIV)
        ]


# variant call intermediate VCFs from individual bams
rule deepvariant_GVCF :
    input:
        bam = "aligned_sorted_marked_rg/{id}.sorted.marked.rg.bam",
        ref = "Pangenome/Chickpea3000_pangenome_nr.fa"
    output:
        gvcf = "pangenome_gvcfs/{id}.g.vcf.gz",
        vcf = "pangenome_gvcfs/{id}.vcf.gz"
    params:
        model = "wgs"
        extra = ""
    threads: 2
    log:
        "logs/{id}.variant_called.log",
    benchmark:
        "benchmarks/{id}.variant_called.benchmark"
    wrapper:
        "v1.22.0/bio/deepvariant"

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 • 854 views
ADD COMMENT
2
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.

ADD REPLY
0
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.

ADD REPLY
1
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.

ADD REPLY

Login before adding your answer.

Traffic: 2173 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