4

I am using BioPython to query the Pubmed database through the eutils API. The esearch endpoint has a sort option, but the API documentation doesn't list all of the options for this value.

http://www.ncbi.nlm.nih.gov/books/NBK25499/#_chapter4_ESearch_

Example call:

Entrez.esearch(db="pubmed", term=search_term, rettype=rettype, retmax=retmax,
               sort=sort_method)

Values that I know work for sort_method:

  • 'pub date'
  • 'relevance'
  • 'first author'
  • 'last author'
  • 'title'
  • 'journal'

However, I am not sure how to specify the default sort order, which is "Most Recent"; in practice, this appears to be sorted by Pubmed ID value. 'recent', 'most recent', 'pmid', 'id', and 'default' all give the OutputMessage "Unknown sort schema....".

Anyone else know how to explicitly specify the default order?

adamc
  • 800
  • 6
  • 9

3 Answers3

1

Not 100% sure if I got your question right. If you don't specify a sort order the default sort order will be used.

handle = Entrez.esearch(db="pubmed", term='TRPV1')
records = Entrez.read(handle)
print('\n'.join(records['IdList']))

will give you the IDs in the same order as on the PubMed web page.

Maximilian Peters
  • 30,348
  • 12
  • 86
  • 99
0

It is sort='relevance'. If you go to the PubMed site and use sort=relevance in the url: https://pubmed.ncbi.nlm.nih.gov/?term=dengue&sort=relevance&size=200 it will use Best Match as shown on the site. When you use sort=pubdate or sort=date it will be Publication Date and Most Recent respectively.

jimh
  • 1,651
  • 2
  • 15
  • 28
0

If your goal is just to sort the results in Most Recent order, just don't specify the sort parameter in esearch() method.

Do this:

Entrez.esearch(db="pubmed", term=search_term, rettype=rettype, retmax=retmax)

instead of:

Entrez.esearch(db="pubmed", term=search_term, rettype=rettype, retmax=retmax, sort=sort_method)

You should be getting a bunch of UIDs/results in Most Recent order as seen on Pubmed Web. Although you might find some UIDs missing from the resultset when compared with the results viewed on Pubmed Web, as Pubmed and Entrez seem to be using different indexes for displaying the results. This part has been discussed about in this talk

sort="pub date" might lead to results you don't expect if you want to retrieve Most recent articles.

Sandeep Gusain
  • 127
  • 1
  • 1
  • 10