diff --git a/R/ncbi_get_meta.R b/R/ncbi_get_meta.R index 27f708b..37e6f25 100644 --- a/R/ncbi_get_meta.R +++ b/R/ncbi_get_meta.R @@ -150,9 +150,7 @@ ncbi_get_meta <- function( if ("ncbi_uid" %in% class(query)) { query <- query$uid } - if (!is.numeric(query)) { - stop("Query must be an ncbi_uid object or a numeric vector or UIDs.") - } + query <- as_numeric(query) idlist <- get_idlist(query, batch_size, verbose) res <- sapply(idlist, function(x) { foo_from_ids(x, db = db) diff --git a/R/ncbi_get_summary.R b/R/ncbi_get_summary.R index 45138ee..9978ef2 100644 --- a/R/ncbi_get_summary.R +++ b/R/ncbi_get_summary.R @@ -81,9 +81,7 @@ ncbi_get_summary <- function( } return(res) } - if (!is.numeric(query)) { - stop("Query must be an ncbi_uid object or a numeric vector or UIDs.") - } + query <- as_numeric(query) idlist <- get_idlist(query, batch_size = batch_size, verbose = verbose) res <- lapply(idlist, function(x) { foo_from_ids(x, db = db, verbose = verbose) diff --git a/R/ncbi_link_uid.R b/R/ncbi_link_uid.R index 1536afa..6674976 100644 --- a/R/ncbi_link_uid.R +++ b/R/ncbi_link_uid.R @@ -131,9 +131,7 @@ ncbi_link_uid <- function( } else { query_vector <- query } - if (!is.numeric(query_vector)) { - stop("Query must be an ncbi_uid object or a numeric vector or UIDs.") - } + query_vector <- as_numeric(query_vector) idlist <- get_idlist(query_vector, batch_size, verbose) res <- lapply(idlist, function(x) { foo_from_ids( diff --git a/R/ncbi_recover_id.R b/R/ncbi_recover_id.R index 0f161bb..c15e30d 100644 --- a/R/ncbi_recover_id.R +++ b/R/ncbi_recover_id.R @@ -44,8 +44,8 @@ ncbi_recover_id <- function( msg <- "Specify a 'db' argument or query an object of class 'ncbi_uid'." stop(msg) } + query <- as_numeric(query) } - db <- match.arg(db, ncbi_dbs()) summaries <- ncbi_get_summary( query, db = db, @@ -64,6 +64,8 @@ ncbi_recover_id <- function( id <- unname(sapply(summaries, function(x) x$accessionversion)) } else if (db == "protein") { id <- unname(sapply(summaries, function(x) x$accessionversion)) + } else if (db == "pubmed") { + id <- unname(sapply(summaries, function(x) x$uid)) } else { stop("Not supported.") }