This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to extract gene IDs from a tabular file based on a list of locus tags?

I have a file like:

GeneID Locus tag Protein name
839580 AT1G01010 NAC domain containing protein 1
839569 AT1G01020 ARV1 family protein
839569 AT1G01020 ARV1 family protein
839569 AT1G01020 ARV1 family protein

I also have a list of locus tags (arround 5000) which I want to extract from the entire file.

e.g if I want to extract gene Id and protein name of

AT1G01010

AT1G01020

I should get

839580 NAC domain containing protein 1

839569 ARV1 family protein

r

2 answers

If it is a data frame , you can simply use merge function

merge(file1 , file2, by.x = "Locus",by.y = "Locus",all.x  = TRUE)

One approach using Unix tools:

$ grep -Fwf locusTags.txt geneAnnotations.txt > answer.txt

Log in to answer this question.