ropensci / rentrez

talk with NCBI entrez using R
https://docs.ropensci.org/rentrez
Other
195 stars 38 forks source link

Error in make_entrez_query() client error: (414) Request-URI Too Long #45

Closed akshaynagpal closed 9 years ago

akshaynagpal commented 9 years ago

Error in make_entrez_query("esummary", db = db, config = config, retmode = retmode, : client error: (414) Request-URI Too Long

The above error occurs at line given below:

"pb_summary <- entrez_summary(db="pubmed",id=ps_2$pubmed_pubmed) "

My total code is :

library(rentrez) library(XML) ps <- entrez_search(db="pubmed","HRVA",retmode="xml") ps[] ps_2 <- entrez_link(dbfrom="pubmed",id=ps$ids,db="all") ps_2 entrez_db_summary("pubmed") pb_summary <- entrez_summary(db="pubmed",id=ps_2$pubmed_pubmed)

dwinter commented 9 years ago

Hi @akshaynagpal, thanks for reporting this. This error occurs when you send too many IDs, and the resuling URL becomes too long.

If you want to work on many IDs I'd suggest using the 'webenv' features. The CRAN version of rentrez doesn't handle these for entrez_link, but the dev version does:

library(devtools)
install_github("dwinter/rentrez")
library(rentrez)
ps <- entrez_search(db="pubmed","HRVA")
ps_2 <- entrez_link(dbfrom="pubmed",id=ps$ids,db="pubmed", cmd="neighbor_history")
ps_2

This object will contain a WebEnv ( basically a cookie) and a list of keys for each database matched by the search.

elink object with contents:
 $WebEnv: A WebEnv (cookie) value 
 $QueryKeys: A list of QUeryKeys for each included database

You can use that to get your big entrez summay list

res <- entrez_summary("pubmed", WebEnv=ps_2$WebEnv, query_key = ps_2$QueryKeys$pubmed_pubmed, version = "1.0")
List of  1093 esummary records. First record:

 $`25672409`
esummary result with 25 items:
 [1] PubDate         EPubDate        Source          AuthorList      LastAuthor      Title           Volume         
 [8] Issue           Pages           LangList        NlmUniqueID     ISSN            ESSN            PubTypeList    
[15] RecordStatus    PubStatus       ArticleIds      DOI             History         References      HasAbstract    
[22] PmcRefCount     FullJournalName ELocationID     SO       

There is also a useful new function, extract_from_esummary

dois <- extract_from_esummary(res, "DOI")
head(dois)
$`25672409`
[1] "10.7883/yoken.JJID.2014.090"

$`25001076`
[1] "10.1007/s00234-014-1399-y"

$`24389019`
[1] "10.1016/j.jinf.2013.12.010"

$`24267739`
[1] "10.1016/j.jns.2013.10.039"

$`22865548`
[1] "10.1002/lary.23411"

$`22087272`
[1] "10.1371/journal.pone.0027247"

I will make sure the development versions hints at this solution when a user runs into this error (#46)

akshaynagpal commented 9 years ago

Thanks a lot! Will try webenv asap! Loved your work in this R package by the way ! Will keep contributing in any way possible! Cheers!

dwinter commented 9 years ago

Thankw @akshaynagpal . As I say, the webenv features are new, so there may well be cases that break what I've written. Let me know if you find any problems :)

akshaynagpal commented 9 years ago

install_github("dwinter/rentrez")

This gives the following error:

Downloading github repo dwinter/rentrez@master Error in download(dest, src, auth) : client error: (404) Not Found

dwinter commented 9 years ago

Oh, yeah, this isn't under by account! try

install_github("ropensci/rentrez")