This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Any idea how to retrieve DEFINITION field from ncbi using an accession numbers in a file

Hi everyone, I have a blastx file with no name in the sseqid just the accession number, I am thinking use this to obtain the DEFINITION field and add it as 13th column in my file. Could somebody help me with this task?

blast

2 answers

You need Entrez Direct for this:

cat gi-list 
807531832
195954015

for next in $(cat gi-list); do title=$(epost -db protein -id "$next" | efetch -format docsum | xtract -element Title); echo -e "$next\t$title"; done
807531832    ATP6 (mitochondrion) [Campethera nivosa]
195954015    atp6 (mitochondrion) [Ochrogaster lunifer]

Then you can use a tool like join.

EDirect 3.30 is now out on the NCBI ftp site. efetch -format docsum (and elink) can accept a single sequence accession number in the -id argument. For scripts that loop through one accession at a time, this will eliminate the epost step.

Here is some simplified code for doing that:

for next in $(cat gi-list)
do
  efetch -db protein -id "$next" -format docsum |
  xtract -pattern DocumentSummary -lbl "$next" -element Title
done

Log in to answer this question.