From 62a697fa7c45c7f078c695f4524bfb1a5d436039 Mon Sep 17 00:00:00 2001 From: Tamas Stirling Date: Mon, 11 Dec 2023 16:41:23 +0100 Subject: [PATCH] Rename ncbi_supported_dbs() to ncbi_dbs() --- R/link_uid.R | 8 ++++---- R/{ncbi_supported_dbs.R => ncbi_dbs.R} | 2 +- R/ncbi_get_meta.R | 4 ++-- R/ncbi_get_uid.R | 4 ++-- man/link_uid.Rd | 4 ++-- man/ncbi_get_meta.Rd | 2 +- man/ncbi_get_uid.Rd | 2 +- tests/testthat/test-ncbi_get_meta.R | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) rename R/{ncbi_supported_dbs.R => ncbi_dbs.R} (88%) diff --git a/R/link_uid.R b/R/link_uid.R index f7c4f24..d4aff35 100644 --- a/R/link_uid.R +++ b/R/link_uid.R @@ -6,12 +6,12 @@ #' This function links uids from one database with uids from another. #' @param query character; a vector of uids. #' @param from character; the database the queried uids come from. -#' \code{ncbi_supported_dbs()} lists all available options. +#' \code{ncbi_dbs()} lists all available options. #' @param to character; the database in which the function should look for links. #' @param cache_file character; the name of the cache file without the file #' extension. If \code{NULL}, results are not cached. #' @param verbose logical; should verbos messages be printed to the console? -#' \code{ncbi_supported_dbs()} lists all available options. +#' \code{ncbi_dbs()} lists all available options. #' @return A tibble #' @examples #' \dontrun{ @@ -27,8 +27,8 @@ link_uid <- function(query, if (any(is.na(as.numeric(query)))) { stop("Query must be a valid UID. Valid UIDs can be converted to 'numeric'.") } - from <- match.arg(from, ncbi_supported_dbs()) - to <- match.arg(to, ncbi_supported_dbs()) + from <- match.arg(from, ncbi_dbs()) + to <- match.arg(to, ncbi_dbs()) foo <- function(x) { if (verbose) webseq_message("query", x, appendLF = FALSE) res <- NULL diff --git a/R/ncbi_supported_dbs.R b/R/ncbi_dbs.R similarity index 88% rename from R/ncbi_supported_dbs.R rename to R/ncbi_dbs.R index e288566..77df88d 100644 --- a/R/ncbi_supported_dbs.R +++ b/R/ncbi_dbs.R @@ -1,4 +1,4 @@ -ncbi_supported_dbs <- function() { +ncbi_dbs <- function() { if (!dir.exists(tempdir())) dir.create(tempdir()) if (!file.exists(paste0(tempdir(), "/webseq.rds"))) { dbs <- rentrez::entrez_dbs() diff --git a/R/ncbi_get_meta.R b/R/ncbi_get_meta.R index 19c9e97..539c5a2 100644 --- a/R/ncbi_get_meta.R +++ b/R/ncbi_get_meta.R @@ -3,7 +3,7 @@ #' This function retrieves metadata from a given NCBI sequence database. #' @param term character; one or more search terms. #' @param db character; the database to search in. For options see -#' \code{ncbi_supported_dbs()}. Not all databases are supported. +#' \code{ncbi_dbs()}. Not all databases are supported. #' @param batch_size integer; the number of search terms to query at once. If #' the number of search terms is larger than \code{batch_size}, the search terms #' are split into batches and queried separately. @@ -34,7 +34,7 @@ ncbi_get_meta <- function( parse = TRUE, verbose = getOption("verbose") ) { - db <- match.arg(db, choices = ncbi_supported_dbs()) + db <- match.arg(db, choices = ncbi_dbs()) uids <- ncbi_get_uid( term = term, db = db, diff --git a/R/ncbi_get_uid.R b/R/ncbi_get_uid.R index 15b5680..40b3787 100644 --- a/R/ncbi_get_uid.R +++ b/R/ncbi_get_uid.R @@ -6,7 +6,7 @@ #' in other NCBI databases or to retrieve the data itself. #' @param term character; one or more search terms. #' @param db character; the database to search in. For options see -#' \code{ncbi_supported_dbs()} +#' \code{ncbi_dbs()} #' @param batch_size integer; the number of search terms to query at once. If #' the number of search terms is larger than \code{batch_size}, the search terms #' are split into batches and queried separately. @@ -36,7 +36,7 @@ ncbi_get_uid <- function( use_history = TRUE, verbose = getOption("verbose") ) { - db <- match.arg(db, choices = ncbi_supported_dbs()) + db <- match.arg(db, choices = ncbi_dbs()) if (all(is.na(term))) { stop("No valid search terms.") } else if (any(is.na(term))){ diff --git a/man/link_uid.Rd b/man/link_uid.Rd index 4dea34d..4f6a3c1 100644 --- a/man/link_uid.Rd +++ b/man/link_uid.Rd @@ -10,7 +10,7 @@ link_uid(query, from, to, cache_file = NULL, verbose = getOption("verbose")) \item{query}{character; a vector of uids.} \item{from}{character; the database the queried uids come from. -\code{ncbi_supported_dbs()} lists all available options.} +\code{ncbi_dbs()} lists all available options.} \item{to}{character; the database in which the function should look for links.} @@ -18,7 +18,7 @@ link_uid(query, from, to, cache_file = NULL, verbose = getOption("verbose")) extension. If \code{NULL}, results are not cached.} \item{verbose}{logical; should verbos messages be printed to the console? -\code{ncbi_supported_dbs()} lists all available options.} +\code{ncbi_dbs()} lists all available options.} } \value{ A tibble diff --git a/man/ncbi_get_meta.Rd b/man/ncbi_get_meta.Rd index fd444db..9e10915 100644 --- a/man/ncbi_get_meta.Rd +++ b/man/ncbi_get_meta.Rd @@ -17,7 +17,7 @@ ncbi_get_meta( \item{term}{character; one or more search terms.} \item{db}{character; the database to search in. For options see -\code{ncbi_supported_dbs()}. Not all databases are supported.} +\code{ncbi_dbs()}. Not all databases are supported.} \item{batch_size}{integer; the number of search terms to query at once. If the number of search terms is larger than \code{batch_size}, the search terms diff --git a/man/ncbi_get_uid.Rd b/man/ncbi_get_uid.Rd index 864ac2d..4dc2e80 100644 --- a/man/ncbi_get_uid.Rd +++ b/man/ncbi_get_uid.Rd @@ -16,7 +16,7 @@ ncbi_get_uid( \item{term}{character; one or more search terms.} \item{db}{character; the database to search in. For options see -\code{ncbi_supported_dbs()}} +\code{ncbi_dbs()}} \item{batch_size}{integer; the number of search terms to query at once. If the number of search terms is larger than \code{batch_size}, the search terms diff --git a/tests/testthat/test-ncbi_get_meta.R b/tests/testthat/test-ncbi_get_meta.R index 1233fbc..90e6590 100644 --- a/tests/testthat/test-ncbi_get_meta.R +++ b/tests/testthat/test-ncbi_get_meta.R @@ -8,7 +8,7 @@ test_that("ncbi_get_meta() works with Microthrix parvicella", { test_that("ncbi_get_meta() works with all supported dbs", { data(examples) - expect_true(all(names(examples) %in% ncbi_supported_dbs())) + expect_true(all(names(examples) %in% ncbi_dbs())) for (i in names(examples)) { res <- suppressWarnings(ncbi_get_meta(examples[[i]], db = i, parse = FALSE))