grep extract command will remove replicates automatically
1
0
Entering edit mode
4.3 years ago

Dear all,

I have a file 1, containing many gene ID, and also has replicates for the gene ID. I want to extract the corresponding line from an gff file, I have a script can accomplish this, but this script will remove the replicates automatically, if I don't want to remove the replicates and want to keep the output just like the order in file 1, if there is anyway I could do this...

Here is file 1:

gene14184
gene25736
gene14184
gene8906
gene25736
gene14775
gene4224
gene8906
gene14184
gene24702

Here is the script I am using:

grep -Fwf file1.txt 001660625_genomic.gff > output.txt
RNA-Seq • 823 views
ADD COMMENT
1
Entering edit mode

I don't know if I really understand what you want to do, but try this:

(for ID in $(cat file1); do echo -e $ID"\t"$(grep $ID gff1); done;) > output.txt
ADD REPLY
0
Entering edit mode
4.3 years ago

Solved!! and Vlookup in excel could also do this. Thanks!!

ADD COMMENT
2
Entering edit mode
ADD REPLY
0
Entering edit mode

Excel can do many things, but once a file gets larger it will crash plus user interaction with it is irreproducable in terms of coding it up in a script. If it helped you this time it is fine but I strongly recommend to learn how to do things outside of Excel. Imagine one of the files was 10Gb in size...what then.

ADD REPLY

Login before adding your answer.

Traffic: 2515 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6