Search code examples
snakemake

Snakemake: 'Unexpected keyword notebook in rule definition' when trying to implement Jupyter notebooks


I've been trying to use the Snakemake Jupyter notebook functionality for Snakemake, using the example given in the Snakemake wiki as a template (see: Jupyter notebook integration).

However when trying to run my Snakefile I get the error: Unexpected keyword notebook in rule definition (Snakefile, line 62). From my experience with Snakemake these kind of errors are often caused by inconsistent indentation, however I have been unable to solve this problem that way.

Any help is much appreciated

Full Snakefile:

# CONFIG
configfile: "config.yaml"

# PIPELINE RULES.
#include: "rules/preperation/get_remote_genome.snakefile"
include: "rules/preperation/get_remote_annovar_dbs.snakefile"
include: "rules/preperation/bwa_index.snakefile"
include: "rules/fastqc.snakefile"
include: "rules/trimmomatic.snakefile"
include: "rules/bwa_mem.snakefile"
include: "rules/samtools_sort.snakefile"
include: "rules/marked_duplicates.snakefile"
include: "rules/bamtools_split.snakefile"
include: "rules/samtools_mpileup.snakefile"
include: "rules/varscan.snakefile"
include: "rules/concat_vcf.snakefile"
include: "rules/annovar.snakefile"

rule all:
    input:
        expand("runs/{sample}/results/results_notebook.html",
               sample=config["samples"])

rule jupyter_to_html:
    input:
        "runs/{sample}/results/results_notebook.ipynb"
    output:
        "runs/{sample}/results/results_notebook.html"
    shell:
        "jupyter nbconvert --execute --to html {input}"

rule jupyter_report:
    input:
        expand("runs/{{sample}}/results/{{sample}}_{num}_fastqc.html",
               num = ["R1", "R2"]),
        expand("runs/{{sample}}/results/{{sample}}.{genome_build}_multianno.txt",
               genome_build = config["genome_build"])
    output:
        "runs/{sample}/results/results_notebook.ipynb"
    log:
        notebook = "runs/{sample}/results/results_notebook.ipynb"
    notebook:
        config["notebook"]

Solution

  • The notebook integration is available from Snakemake 5.10 onwards. Maybe your version of Snakemake is < 5.10?