Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glob_wildcards foo #38

Open
ctb opened this issue Apr 19, 2024 · 0 comments
Open

glob_wildcards foo #38

ctb opened this issue Apr 19, 2024 · 0 comments

Comments

@ctb
Copy link
Member

ctb commented Apr 19, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant