Skip to content

Commit

Permalink
Do not require numeric uids but require that they are coercible
Browse files Browse the repository at this point in the history
  • Loading branch information
stitam committed Dec 22, 2024
1 parent 8519771 commit 2e8b5f0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
4 changes: 1 addition & 3 deletions R/ncbi_get_meta.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions R/ncbi_get_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions R/ncbi_link_uid.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion R/ncbi_recover_id.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.")
}
Expand Down

0 comments on commit 2e8b5f0

Please sign in to comment.