# Query redbiom using a file

**URL:** https://forum.qiime2.org/t/query-redbiom-using-a-file/22332
**Category:** Other Bioinformatics Tools
**Tags:** redbiom
**Created:** [February 28, 2022, 11:11pm UTC](https://forum.qiime2.org/t/query-redbiom-using-a-file/22332 "2022-02-28T23:11:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Sahar](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sahar/32/12985_2.png) [@Sahar](https://forum.qiime2.org/u/Sahar)
#### Post date: [February 28, 2022, 11:11pm UTC](https://forum.qiime2.org/t/query-redbiom-using-a-file/22332/1 "2022-02-28T23:11:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![wasade](https://forum.qiime2.org/user_avatar/forum.qiime2.org/wasade/32/2317_2.png) [@wasade](https://forum.qiime2.org/u/wasade)
#### Post date: [March 1, 2022, 4:29pm UTC](https://forum.qiime2.org/t/query-redbiom-using-a-file/22332/4 "2022-03-01T16:29:39Z")

</div>

Hi @Sahar,

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

```auto
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:

```auto
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

---

<div class="post-metadata">

### Author: ![Sahar](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sahar/32/12985_2.png) [@Sahar](https://forum.qiime2.org/u/Sahar)
#### Post date: [March 1, 2022, 7:01pm UTC](https://forum.qiime2.org/t/query-redbiom-using-a-file/22332/5 "2022-03-01T19:01:28Z")

</div>

Thank you Daniel. That was very helpful.

---

<div class="post-metadata">

### Author: ![system](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/3X/2/1/21af5fe23cb6f4579467c66a9ed94e55274ca7bd.svg) [@system](https://forum.qiime2.org/u/system)
#### Post date: [April 2, 2022, 1:02am UTC](https://forum.qiime2.org/t/query-redbiom-using-a-file/22332/6 "2022-04-02T01:02:11Z")

</div>

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