Query redbiom using a file

Hi,

I would like to obtain sample IDs that have qiita_prep_id in a list
something like
redbiom search metadata "where (qiita_prep_id in data/prep.ids)" > samples_of_interest.ids

How can I read qiita_prep_id in data/prep.ids within the search?

Thanks

Hi @Sahar,

One way to accomplish this would be to do something like:

redbiom search metadata "where qiita_prep_id in (1234, 5678, 9012)" > samples_of_interest.ids"

The trick is to construct the content within the parentheses. You can do that with something like:

preps=$(cat your_preps.ids | tr "\n" "," | awk '{ print "(" $1 ")" }')
redbiom search metadata "where qiita_prep_id in ${preps}" > samples_of_interest.ids"

While this is a way to construct a list of entities to match against in a search, I do not believe this search will work. redbiom search is oriented at sample metadata that is preparation invariant. What I think is necessary instead is to find samples for your study(s) of interest, and then refine the search using "redbiom select samples-from-metadata" which accepts a --context argument and a similar type of query (e.g., the where ... piece). The use of context will require redbiom expose preparation specific information, which will include the prep ID.

Best,
Daniel

1 Like

Thank you Daniel. That was very helpful.

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.