SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Reply
 
Thread Tools
Old 12-13-2016, 12:34 PM   #1
joseangelivan
Junior Member
 
Location: Guadalajara, Mexico

Join Date: May 2016
Posts: 5
Unhappy Help

Hi everyone

I have a file 1 with a column of several NCBI ID's like NC_014251.1 and a file B with several lines containing ID's and the description, i want to generate a file C with my IDs from file 1 ans its description from file B

for one record i did this
grep -w "NC_014251.1" ident_allbac160615.txt > NNSV15DNABNNSV15RNAB_R1R1q20allhg38nmIDsnum1.txt

but when i am trying to do it for all file A with
grep -wf NNSV15DNABNNSV15RNAB_R1R1q20allhg38nmIDsnum.txt ident_allbac160615.txt > NNSV15DNABNNSV15RNAB_R1R1q20allhg38nmIDsnumA.txt

i am losing IDs and its order (from 34140 just 1440 ), any idea whats going on?

I will appreciate any help
joseangelivan is offline   Reply With Quote
Old 12-13-2016, 10:58 PM   #2
wdecoster
Member
 
Location: Antwerp, Belgium

Join Date: Oct 2015
Posts: 97
Default

Just as a side note, perhaps you should consider a more informative title for your post...
wdecoster is offline   Reply With Quote
Old 12-14-2016, 06:09 AM   #3
skbrimer
Member
 
Location: OP Kansas

Join Date: Mar 2014
Posts: 53
Default

you can use the join command, below is a quick tutorial

https://shapeshed.com/unix-join/
skbrimer is offline   Reply With Quote
Old 12-14-2016, 02:04 PM   #4
joseangelivan
Junior Member
 
Location: Guadalajara, Mexico

Join Date: May 2016
Posts: 5
Default

Hi everyone

This time i will try to be more clear, i am using grep to search a string on a file, individually works fine but now i have a file with a column of strings many of them are the same and the result is only one for those that are the same.

grep -wFf file_A Pattern_file > result


Like:

Pattern_file
aQ2nVEJb
aQ2nVEJb
DFGTYHDF
aQ2nVEJb

file_A
aQ2nVEJb 12
DFGTYHDF 15
sdfgRTYH 18

The result is
DFGTYHDF 15
aQ2nVEJb 12

I would like this
aQ2nVEJb 12
aQ2nVEJb 12
DFGTYHDF 15
aQ2nVEJb 12

Any idea how to solve this?

Tks
joseangelivan is offline   Reply With Quote
Old 12-15-2016, 07:46 AM   #5
skbrimer
Member
 
Location: OP Kansas

Join Date: Mar 2014
Posts: 53
Default

I'm not sure if grep does duplicates so I don't know how to do it in grep. However if you do this it will work:
Code:
sort pattern_file > pattern_file_sorted
sort file_a > file_a_sorted
join pattern_file_sorted file_a_sorted > results
You will get the list you are after.
skbrimer is offline   Reply With Quote
Reply

Tags
linux commands grep

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 11:53 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO