This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Matching Ids with respect to individual file

Hi,

I have number of files having information related to gene and its positions. And I have a list of Ids with respect to the number of files. I want to extract data with respect to ids. But my problem is different. As, I want my first id get searched in only first file not on others.

For example I have multiple files (more than 14000) like this:

000002|chr1:1158623-1159348-|NM_016176|SDF4 0000002 ACTCAAAGTGGATGAGGAA +
0000003|chr1:1158623-1159348-|NM_016176|SDF4    0000002 ACTCAAAGTGGATGAGGA  +
0000004|chr1:1158623-1159348-|NM_016176|SDF4    0000002 ACTCAAAGTGGATGAGG   +
0000005|chr1:1158623-1159348-|NM_016176|SDF4    0000002 ACTCAAAGTGGATGAG    +

My list of ids file is like this

000002|
000003|
000004|

My desired output for one file would be like this

000002|chr1:1158623-1159348-|NM_016176|SDF4 0000002 ACTCAAAGTGGATGAGGAA +

Any help is much appreciated.

Thanks

next-gen

1 answer

grep is your friend for this. Google how to grep the contents of one file using another.

excellent hint. I solved it by using grep in for loop.

Made my day!

Thanks

Log in to answer this question.