Question: Row extraction problems
1
gravatar for Janey
3.7 years ago by
Janey30
USA
Janey30 wrote:

Hi At first I thought that this work is so simple for me. I have File1 (ID list) and File2 (reference file). I want to extract some full rows by ID list from File2. I am not familiar to R and Python. I used "grep -f File1 File2" and some other commands but i got errors. Can anyone show me a simple solution to solve this problem.

rna-seq • 801 views
ADD COMMENTlink written 3.7 years ago by Janey30

man join / http://superuser.com/questions/25302

ADD REPLYlink modified 3.7 years ago • written 3.7 years ago by Pierre Lindenbaum130k

What errors did you get? grep -f is a pretty standard approach.

ADD REPLYlink written 3.7 years ago by Alex Reynolds30k

Hi Alex I run this command "grep -f File1.txt (IDs) File2.txt(Ref) > output" several times for avoiding error but I output file containing the entire of file 2.

ADD REPLYlink written 3.7 years ago by Janey30
1

Maybe you need a literal string search, if you need exact matches: $ grep -Ff file1.txt file2.txt > output

ADD REPLYlink written 3.7 years ago by Alex Reynolds30k

I thank you very much Alex, your command solved my problem.

ADD REPLYlink written 3.7 years ago by Janey30

when I extracted the columns, folowing command was pretty good: cut -f 1,2,3 File_name | sed 's/[\t]/,/g' > output

ADD REPLYlink written 3.7 years ago by Janey30
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1286 users visited in the last hour