[Python] How to use the default value of a param when import a rule in Snakemake?

Discussão em 'Python' iniciado por Stack, Agosto 4, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to generalize my snakemake workflow, but I see a weird behavior, which I am not sure if I am doing something wrong or if it is by default. I created a file analysis.smk rules and the evariable I tried to make a generic rule, to import it in many of my snakemake workflows, so I have, for instance in my analysis.smk rule:

    rule analysis:
    output: test.root
    input: input_test.root
    params:
    variable: "SvB"
    rebin: 10
    shell: `python run_analysis.py {params.variable} {params.rebin}`


    In another Snakefile, I am importing this rule and using it as:

    module analysis:
    snakefile: "analysis.smk"
    config: config

    use rule analysis from analysis as run_analysis with:
    output: f"{config['output']}/hist.root"
    input: f"{config['output']}/input_hist.root"
    params:
    rebin: 20


    And when I run my workflow, I am getting errors like:

    AttributeError: 'Params' object has no attribute 'variable', when formatting the following:


    Because I didn't define the variable. Is this expected? I would just like to change the value of some params, and use the default in others.

    I am using snakemake version 8.27.1

    Continue reading...

Compartilhe esta Página