From 2c6462d377313c1a76cf1fecbf244e7b6f73c6be Mon Sep 17 00:00:00 2001 From: arvi1000 <2406749+arvi1000@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:20:13 -0700 Subject: [PATCH 1/4] epmc_search: populate the hit_count attribute even with zero results --- R/epmc_search.r | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/epmc_search.r b/R/epmc_search.r index 20e929c..b9c503d 100644 --- a/R/epmc_search.r +++ b/R/epmc_search.r @@ -104,7 +104,10 @@ epmc_search <- function(query = NULL, hits <- epmc_hits(query, synonym = synonym) if (hits == 0) { message("There are no results matching your query") - md <- NULL + # return an empty tibble + md <- tibble::tibble() + # populate the hit_count attribute even with zero results + attr(md, "hit_count") <- hits } else { limit <- as.integer(limit) limit <- ifelse(hits <= limit, hits, limit) From 8ec3dc2660ddf79e9b4825c40465e0e09ff8c4d1 Mon Sep 17 00:00:00 2001 From: arvi1000 <2406749+arvi1000@users.noreply.github.com> Date: Mon, 1 Jul 2024 11:19:44 -0400 Subject: [PATCH 2/4] Generated documentation changes --- DESCRIPTION | 2 +- docs/.DS_Store | Bin 6148 -> 6148 bytes man/epmc_annotations_by_id.Rd | 4 ++-- man/epmc_ftxt.Rd | 4 ++-- man/europepmc.Rd | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 00e768a..b4f1756 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,7 +36,7 @@ Imports: tibble, tidyr, rlang -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Suggests: testthat, knitr, diff --git a/docs/.DS_Store b/docs/.DS_Store index b4f3741620967f17a0166ec7aafb20b629ed0ed2..1339fb4b3f6275671ef22cf743f949c123c81ada 100644 GIT binary patch literal 6148 zcmeHKy-ve05I&a(1u8@tkQhK@VPT>xQ>cPqMCyt}X&e5OHWev?G0(vh@FWbp0#Cul z$lcjW9O3{ILg-Gizu0%qefb*aY5-8ZyKxtw0{}iYLT?#6hmoIJ&01z=9Z~T;Mvy=Z z**F^|wP=|T1w?_rrU30-AI{+x=5P(x{vD=if}6VTOfI|qQ97CNlPvBWxMC)06b+Mf zNWK^U=4o@~xgl=+qqy0Xo%4iJw~_7?#`w8;fHSzj5r29r?9}O7bEM62YrEjsaNkK< zGW|Zf!dDH5ug82dm^&C2KAY3=Uct%omn>X6b0T4YJli@X;B?tq9p}|}udeD?!il~<=bHq@3InD886sRh&pobl*|A)=z|LP(ci2|a)zfwSX zQ9tV8BbnM-dpN4K0k#1)GK$MJ@)GP!Ipzy0#T(ez&==4JVrVeeh%;#NM}TFJP89f6 G1wH^?QL#?| delta 71 zcmZoMXfc=|#>CJzu~2NHo+2aT!~knX#>qS^3Y$eZgjqH=crb5f=iui6s@N>Z@tt`x Zzlbg;BLf4&0U&0WY{MhHIYwj&GXQc*5NH4Z diff --git a/man/epmc_annotations_by_id.Rd b/man/epmc_annotations_by_id.Rd index 4d29040..80df5a3 100644 --- a/man/epmc_annotations_by_id.Rd +++ b/man/epmc_annotations_by_id.Rd @@ -36,8 +36,8 @@ full-text articles. } \examples{ \dontrun{ - annotations_by_id("MED:28585529") + epmc_annotations_by_id("MED:28585529") # multiple ids - annotations_by_id(c("MED:28585529", "PMC:PMC1664601")) + epmc_annotations_by_id(c("MED:28585529", "PMC:PMC1664601")) } } diff --git a/man/epmc_ftxt.Rd b/man/epmc_ftxt.Rd index 3923c69..487e2d8 100644 --- a/man/epmc_ftxt.Rd +++ b/man/epmc_ftxt.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/epmc_ftxt.r \name{epmc_ftxt} \alias{epmc_ftxt} -\title{Fetch Europe PMC full texts} +\title{Fetch Europe PMC full text} \usage{ epmc_ftxt(ext_id = NULL) } @@ -14,7 +14,7 @@ All full text publications have external IDs starting 'PMC_'} xml_document } \description{ -This function loads full texts into R. Full texts are in XML format and are +This function loads one full text into R. Full text is in XML format and is only provided for the Open Access subset of Europe PMC. } \examples{ diff --git a/man/europepmc.Rd b/man/europepmc.Rd index 3027064..86d065d 100644 --- a/man/europepmc.Rd +++ b/man/europepmc.Rd @@ -2,8 +2,8 @@ % Please edit documentation in R/europepmc.r \docType{package} \name{europepmc} -\alias{europepmc} \alias{europepmc-package} +\alias{europepmc} \title{europepmc - an R client for the Europe PMC RESTful article API} \description{ What is europepmc?: From 57f7c63b4d86662ae0d3ec88f870332d25ceee39 Mon Sep 17 00:00:00 2001 From: arvi1000 <2406749+arvi1000@users.noreply.github.com> Date: Mon, 1 Jul 2024 11:22:32 -0400 Subject: [PATCH 3/4] Update for smaller result set --- tests/testthat/test_epmc_db.r | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test_epmc_db.r b/tests/testthat/test_epmc_db.r index 750abe9..83e231c 100644 --- a/tests/testthat/test_epmc_db.r +++ b/tests/testthat/test_epmc_db.r @@ -2,7 +2,10 @@ context("testing epmc_db") test_that("epmc_db returns", { skip_on_cran() - a <- epmc_db("12368864", db = "uniprot", limit = 50) + # as of July 2024, this result only returns 10 results, so limit must + # be <= that + a_limit <- 7 + a <- epmc_db("12368864", db = "uniprot", limit = a_limit) b <- epmc_db("25249410", db = "embl") c <- epmc_db("14756321", db = "uniprot") d <- epmc_db("11805837", db = "pride") @@ -31,7 +34,7 @@ test_that("epmc_db returns", { - expect_equal(nrow(a), 50) + expect_equal(nrow(a), a_limit) # fails correctly expect_error(epmc_db("14756321"), "Please restrict reponse to a database") From dd395e1064567eac92883038b66b67d254ee1a54 Mon Sep 17 00:00:00 2001 From: arvi1000 <2406749+arvi1000@users.noreply.github.com> Date: Mon, 1 Jul 2024 14:20:08 -0400 Subject: [PATCH 4/4] update tests; blank results now return blank 0x0 tibbles, not NULL --- tests/testthat/test_epmc_search.r | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test_epmc_search.r b/tests/testthat/test_epmc_search.r index 4c59cf2..8ef0d0e 100644 --- a/tests/testthat/test_epmc_search.r +++ b/tests/testthat/test_epmc_search.r @@ -31,19 +31,19 @@ test_that("epmc_search returns", { expect_is(k, "list") expect_is(l, "data.frame") - #are diminsions correct? + # are dimensions correct? expect_equal(nrow(e), 250) expect_equal(ncol(e), 4) expect_equal(nrow(f), 25) expect_equal(nrow(h), 100) expect_equal(length(i), 125) + expect_equal(nrow(j), 0) expect_equal(nrow(l), 100) # fails correctly expect_message(epmc_search("123haha"), "There are no results matching your query") - expect_null(j) expect_error(epmc_search(query = "malaria", limit = TRUE)) expect_error(epmc_search(query = "malaria", verbose = "kdk")) expect_error(epmc_search(query = "malaria", synonym = "yes"))