Skip to content

Documentation error: incorrect varible name in example for lookup() #3541

@banfelder

Description

@banfelder

Snakemake version

# snakemake --version
9.3.0

Describe the bug
The example code for the lookup() function in the Snakemake documentation uses the variable sample when it should be item.

In the Snakemake documentation at "Snakefiles and Rules"->"Helpers for defining rules"->"Semantic helpers"->"The lookup function", the example code...

collect("results/{item.sample}.txt", sample=lookup(query="someval > 2", within=samples))

...produces a WildcardError... No values given for wildcard 'item'. error.

The example code should be...

collect("results/{item.sample}.txt", item=lookup(query="someval > 2", within=samples))

Logs
With current example code:

# snakemake --cores=1 --force
WildcardError in file "/Users/jason/dev/learn/snakemake/learn/Snakefile", line 13:
No values given for wildcard 'item'.

Minimal example

# mkdir results
# touch results/{a,b,c}.txt

# cat Snakefile

import pandas as pd

samples = pd.DataFrame.from_records(
    (
        {"sample": "a", "someval": 4},
        {"sample": "b", "someval": 2},
        {"sample": "c", "someval": 8},
    ),
)

rule test_rule:
    input:
        collect("results/{item.sample}.txt", sample=lookup(query="someval > 2", within=samples))
    output:
        "output/sample_list"
    shell:
        """
        echo \\# $(date) > {output}
        echo The input files captured are... >> {output}
        echo '{input}' >> {output}
        """

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions