This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extract sequence ids from otu map based on representative sequence id

I have an otu map that I would like to extract sequences id corresponding to specific representative sequence ids. For just one representative sequence id I can do

grep "representativesequenceid" otu_map.txt > output.txt

But I would like to do this for a list of ~100 sequence ids, rather than do this 100 times :) Any ideas?

sequence next-gen

1 answer

grep -f ids_file otu_map.txt > output.txt

ids_file contains list of your representative sequence ids with one id per line.

grep usage:

$ grep --help | grep '\-f' 
  -f, --file=FILE           obtain PATTERN from FILE

Tried it but just got a blank text file. Any idea what I might've done wrong?

did you copy and paste your representative sequence ids into the ids_file ?

Yes, it is a tab-delimited file with one representative sequence id per line.

Please show several rows

New.CleanUp.ReferenceOTU236161
New.CleanUp.ReferenceOTU307379
New.CleanUp.ReferenceOTU403578
New.CleanUp.ReferenceOTU40971
New.CleanUp.ReferenceOTU128105
138304
New.CleanUp.ReferenceOTU19208
New.CleanUp.ReferenceOTU176865

It should be the \r in your IDs file. Did you create that file in Windows?

Run

dos2unix ids_file

And then

grep -f ids_file otu_map.txt > output.txt

This should work.

Log in to answer this question.