Skip to content

Commit

Permalink
fix #115 - taxa_search only ncbi for now, stop() on db=traitbank for now
Browse files Browse the repository at this point in the history
use messages param instead of verbose passed to get_uid internally within ncbi_searcher
  • Loading branch information
sckott committed Jun 28, 2019
1 parent e8e9114 commit cc95974
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions R/ncbi_searcher.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ncbi_searcher <- function(taxa = NULL, id = NULL, seqrange="1:3000",

# Convert 'taxa' to 'id' if 'taxa' is supplied ---------------------------------------------------
if (is.null(id)) {
id <- get_uid(taxa, verbose = verbose)
id <- get_uid(taxa, messages = verbose)
names(id) <- taxa
} else {
id <- as.character(id)
Expand Down Expand Up @@ -185,12 +185,12 @@ get_parent <- function(id, verbose) {
ancestry <- classification(id = id, db = "ncbi")[[1]]
if (nrow(ancestry) > 1) {
parent_name <- ancestry$name[nrow(ancestry) - 1]
return(get_uid(parent_name, verbose = verbose))
return(get_uid(parent_name, messages = verbose))
}
}
if (!is.null(names(id)) && grepl(" ", names(id))) { #if a name is given and looks like a species
parent_name <- strsplit(names(id), " ")[[1]][[1]]
return(get_uid(parent_name, verbose = verbose))
return(get_uid(parent_name, messages = verbose))
}
return(NA)
}
Expand Down
9 changes: 5 additions & 4 deletions R/taxa_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#'
#' @export
#' @param x (character) Taxonomic name(s) to search for
#' @param db (character) One of betydb, traitbank, ncbi, coral.
#' @param db (character) only 'ncbi' for now - other options
#' maybe in the future
#' @param ... Curl options passed on to \code{\link[httr]{GET}}
#' @return A \code{data.frame}
#' @author Scott Chamberlain \email{myrmecocystus@@gmail.com}
#' @examples \dontrun{
#' taxa_search("Poa annua", db = "traitbank")
#' taxa_search("Poa annua", db = "ncbi")
#' }
taxa_search <- function(x, db, ...) {
Expand All @@ -26,8 +26,9 @@ taxa_search.character <- function(x, db, ...) {
}
switch(db,
traitbank = {
id <- get_tb(x)
traitbank(pageid = id, ...)
stop("traitbank not working for now; see ?traits::traitbank")
# id <- get_tb(x)
# traitbank(pageid = id, ...)
},
ncbi = {
ncbi_searcher(taxa = x, ...)
Expand Down
4 changes: 2 additions & 2 deletions man/taxa_search.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cc95974

Please sign in to comment.