rentrez icon indicating copy to clipboard operation
rentrez copied to clipboard

Using web history instead of ids returns more results than expected

Open stitam opened this issue 6 months ago • 5 comments

When I run entrez_search() with use_history and retmax = 5, the function will respect this and return 5 UIDs:

biosample_uid <- entrez_search(db = "biosample", term = "Microthrix parvicella", use_history = TRUE, retmax = 5)
length(biosample_uid$ids)
5

When I convert these to assembly UID without using web history, the entrez_link() will return 5 UIDs, as expected:

assembly_uid <- entrez_link(dbfrom = "biosample", id = biosample_uid$ids, db = "assembly")
length(assembly_uid$links$biosample_assembly)
5

However, when I use the web history, the function will return more than 5 UIDs:

assembly_uid <- entrez_link(dbfrom = "biosample", web_history = biosample_uid$web_history, db = "assembly")
length(assembly_uid$links$biosample_assembly)
14

Even if I set retmax:

assembly_uid <- entrez_link(dbfrom = "biosample", web_history = biosample_uid$web_history, db = "assembly", retmax = 5)
length(assembly_uid$links$biosample_assembly)
14

It seems this is not an entrez_link() thing, it also occurs e.g. with entrez_fetch():

meta <- entrez_fetch(db = "biosample", web_history = biosample_uid$web_history, rettype = "full", retmode = "xml")
xmllist <- xml2::as_list(xml2::read_xml(meta))[[1]]
length(xmllist)
16

Again, ids instead of web history work fine:

meta <- entrez_fetch(db = "biosample", id = biosample_uid$ids, rettype = "full", retmode = "xml")
xmllist <- xml2::as_list(xml2::read_xml(meta))[[1]]
length(xmllist)
5

Any idea what is going on here? Many thanks.

stitam avatar Jan 08 '24 22:01 stitam