rentrez icon indicating copy to clipboard operation
rentrez copied to clipboard

Error in ans[[1]] : subscript out of bounds

Open drumstick90 opened this issue 1 year ago • 3 comments

I get this stupid error when running:

  • entrez_search(db = "pubmed", term = "cancer")

No problem if i run

  • entrez_search(db = "mesh", term = "cancer")

drumstick90 avatar Apr 19 '23 18:04 drumstick90

It works fine for me. Can you share a reproducible example (reprex)?

allenbaron avatar May 02 '23 13:05 allenbaron

Hey, I am also running into this error and have a reproducible example below. Like you, i can get @drumstick90 pubmed search to work, but am running into errors when searching the nucleotide database:

library(rentrez)

pubmed <- rentrez::entrez_search(db = "pubmed", term = "cancer")

result <- rentrez::entrez_search(db = "nucelotide", 
                                 term = "Abudefduf saxatilis[ORGN] AND 12S[ALL]")
#> Error in ans[[1]]: subscript out of bounds

traceback()
# 6: `[[.XMLInternalDocument`(x, "/eSearchResult/Count")
# 5: x[["/eSearchResult/Count"]]
# 4: xmlValue(x[["/eSearchResult/Count"]])
# 3: parse_esearch.XMLInternalDocument(parsed, history = use_history)
# 2: parse_esearch(parsed, history = use_history)
# 1: rentrez::entrez_search(db = "nucelotide", term = "Abudefduf saxatilis[ORGN] AND 12S[ALL]")

sessionInfo()
#> R version 4.3.0 (2023-04-21 ucrt)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19045)
#> 
#> Matrix products: default
#> 
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.utf8 
#> [2] LC_CTYPE=English_United States.utf8   
#> [3] LC_MONETARY=English_United States.utf8
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.utf8    
#> 
#> time zone: America/New_York
#> tzcode source: internal
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] rentrez_1.2.3
#> 
#> loaded via a namespace (and not attached):
#>  [1] digest_0.6.31   R6_2.5.1        XML_3.99-0.14   fastmap_1.1.1  
#>  [5] xfun_0.39       glue_1.6.2      knitr_1.42      htmltools_0.5.5
#>  [9] rmarkdown_2.21  lifecycle_1.0.3 cli_3.6.1       reprex_2.0.2   
#> [13] withr_2.5.0     compiler_4.3.0  httr_1.4.6      rstudioapi_0.14
#> [17] tools_4.3.0     curl_5.0.0      evaluate_0.21   yaml_2.3.7     
#> [21] jsonlite_1.8.4  rlang_1.1.1     fs_1.6.2

Created on 2023-05-19 with reprex v2.0.2

rfrancolini avatar May 19 '23 13:05 rfrancolini

@rfrancolini, thanks for trying. That example is reproducible but the problem is that the db is misspelled.

I think the main issue here is that rentrez could do a better job at passing through errors returned from the Entrez Utils system.

Until, and if, rentrez gets improved with better error messages, anyone who comes upon this error may want to first try to debugonce() whichever rentrez function being used and to examine the response from the EUtils system for more info. If the response from EUtils is not an error and rentrez can't parse it, please post it here for others.

allenbaron avatar May 22 '23 13:05 allenbaron