Best way to get a directory as input for q2cli

Hi everyone,

What is the best way to accept a directory as an input parameter for q2cli? I want to be able to point QIIME2 at a bunch of artifacts of the same type, but it isn’t very clear how to define a new semantic type for this purpose, so my solution for now is to get a directory supplied by the user, then sniff the artifacts with the zipfile lib to grab the content from the the artifact type(s) I need.

Thanks for your help!

Mike Hall

Hey @mwhall!

Sorry for the delayed response :frowning:

q2cli can’t quite handle exactly what you’re describing, but it can come kind of close.

You are looking for the List[] or Set[] containers, so for example you could say:
List[SomeSemanticType] or Set[SomeSemanticType] and q2cli will generate an interface that allows the argument to be repeated multiple times. This isn’t super ideal when you have all of your artifacts in a nice directory like that, but you can almost hack something together with bash-expansion.

This kind of pattern is probably much easier to do with the Artifact API, where you can just glob the directory, load them all as an artifact, and then pass a python list to the action.

Hopefully that helps!

1 Like