Skip to content

glob_wildcards foo #38

@ctb

Description

@ctb

Anneliek ter Horst
Hello!
I have a question regarding input files.
When defining input files at the top of a Snakefile, like this:
SAMPLES, = glob_wildcards('/group/ctbrowngrp2/scratch/annie/2023-sourmash-viruses/{ident}.fa
Why is the , needed after SAMPLES?
11:14 AM
titus
💬 glob_wildcards returns an object that (among other things) can be unpacked via iteration. The SAMPLES, says “please unpack this via iteration; I expect one element only.”

11:14 AM
it is equivalent to
SAMPLES = list(glob_wildcards(...))[0]
with the added bonus that if there is more than one element in the list, Python complains.
11:16 AM
The object itself is pretty cool. You could also do
wc_obj = glob_wildcards(...)
SAMPLES = wc_obj.ident
as a way of pulling out just the matches to ident . If you had multiple wildcards being learned by glob_wildcards, this would be a good way to access them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions