diff --git a/DESCRIPTION b/DESCRIPTION index 9c1686a..fbb972e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,10 +1,9 @@ Package: traits Title: Species Trait Data from Around the Web Description: Species trait data from many different sources, including - sequence data from 'NCBI', plant trait data from 'BETYdb', plant data - from the USDA plants database, data from 'EOL' 'Traitbank', - Coral traits data (), 'Birdlife' International, - and more. + sequence data from 'NCBI' (), + plant trait data from 'BETYdb', data from 'EOL' 'Traitbank', + 'Birdlife' International, and more. Version: 0.5.0 Authors@R: c( person("Scott", "Chamberlain", role = c("aut", "cre"), diff --git a/R/birdlife.R b/R/birdlife.R index 4b46950..a44d05a 100644 --- a/R/birdlife.R +++ b/R/birdlife.R @@ -2,10 +2,10 @@ #' #' @export #' @param id A single IUCN species ID -#' @return a \code{data.frame} with level 1 and level 2 habitat classes, as +#' @return a `data.frame` with level 1 and level 2 habitat classes, as #' well as importance ratings and occurrence type (e.g. breeding or #' non-breeding). The habitat classification scheme is described -#' at \url{http://bit.ly/1e6gKBr} +#' at https://www.iucnredlist.org/resources/classification-schemes #' @author David J. Harris \email{harry491@@gmail.com} #' @family birdlife #' @examples \dontrun{ @@ -31,7 +31,7 @@ birdlife_habitat <- function(id) { #' #' @export #' @inheritParams birdlife_habitat -#' @return a \code{data.frame} with the species ID and two levels of threat +#' @return a `data.frame` with the species ID and two levels of threat #' descriptions, plus stresses, timing, scope, severity, and impact associated #' with each stressor. #' @author David J. Harris \email{harry491@@gmail.com} diff --git a/R/coral.R b/R/coral.R index cadc757..847101b 100644 --- a/R/coral.R +++ b/R/coral.R @@ -1,111 +1,45 @@ #' Search for coral data on coraltraits.org -#' -#' @name coral -#' @param taxon A taxon id -#' @param trait A trait id -#' @param location A location id -#' @param methodology A methodology id -#' @param resource A resource id -#' @param taxonomy logical; Include contextual data. Default: `FALSE` -#' @param contextual logical; Include contextual data. Default: `TRUE` -#' @param global logical; Include contextual data. Default: `FALSE` -#' @param ... Curl options passed on to [crul::verb-GET] +#' +#' DEFUNCT: As far as we can tell the coraltraits.org API is down +#' for good +#' +#' @name coral-defunct +#' @keywords internal +#' @param ... ignored #' @references https://coraltraits.org/ -#' @author Scott Chamberlain \email{myrmecocystus@@gmail.com} -#' @examples \dontrun{ -#' # Get the species and their Ids -#' head( coral_species() ) -#' -#' # Get data by taxon -#' coral_taxa(8) -#' -#' # Get data by trait -#' coral_traits(3) -#' -#' # Get data by methodology -#' coral_methodologies(2) -#' -#' # Get data by location -#' coral_locations(132) -#' -#' # Get data by resource -#' coral_resources(9) -#' -#' # curl options -#' coral_taxa(8, verbose=TRUE) -#' } #' @export -#' @rdname coral -coral_taxa <- function(taxon, taxonomy = FALSE, contextual = TRUE, - global = FALSE, ...) { - args <- list(taxonomy = lsw(taxonomy), contextual = lsw(contextual), - global = lsw(global)) - coral_GET(coral_url("species", taxon), args, ...) +#' @rdname coral-defunct +coral_taxa <- function(...) { + .Defunct(msg = "the coraltraits.org API is down for good") } #' @export -#' @rdname coral -coral_traits <- function(trait, taxonomy = FALSE, contextual = TRUE, - global = FALSE, ...) { - args <- list(taxonomy = lsw(taxonomy), contextual = lsw(contextual), - global = lsw(global)) - coral_GET(coral_url("traits", trait), args, ...) +#' @rdname coral-defunct +coral_traits <- function(...) { + .Defunct(msg = "the coraltraits.org API is down for good") } #' @export -#' @rdname coral -coral_locations <- function(location, taxonomy = FALSE, contextual = TRUE, - global = FALSE, ...) { - args <- list(taxonomy = lsw(taxonomy), contextual = lsw(contextual), - global = lsw(global)) - coral_GET(coral_url("locations", location), args, ...) +#' @rdname coral-defunct +coral_locations <- function(...) { + .Defunct(msg = "the coraltraits.org API is down for good") } #' @export -#' @rdname coral -coral_methodologies <- function(methodology, taxonomy = FALSE, - contextual = TRUE, global = FALSE, ...) { - args <- list(taxonomy = lsw(taxonomy), contextual = lsw(contextual), - global = lsw(global)) - coral_GET(coral_url("methodologies", methodology), args, ...) +#' @rdname coral-defunct +coral_methodologies <- function(...) { + .Defunct(msg = "the coraltraits.org API is down for good") } #' @export -#' @rdname coral -coral_resources <- function(resource, taxonomy = FALSE, contextual = TRUE, - global = FALSE, ...) { - args <- list(taxonomy = lsw(taxonomy), contextual = lsw(contextual), - global = lsw(global)) - coral_GET(coral_url("resources", resource), args, ...) +#' @rdname coral-defunct +coral_resources <- function(...) { + .Defunct(msg = "the coraltraits.org API is down for good") } #' @export -#' @rdname coral +#' @rdname coral-defunct coral_species <- function(...) { - con <- crul::HttpClient$new("https://coraltraits.org/species", - opts = list(...)) - res <- con$get(query = list(all="true")) - res$raise_for_status() - html <- xml2::read_html(res$parse("UTF-8")) - ids <- gsub("\n+|\t+|\\s+", "", - xml2::xml_text(xml2::xml_find_all(html, - '//li[@class="list-group-item"]//div[@style="color: lightgrey;"]'))) - nms <- xml2::xml_text( - xml2::xml_find_all(html, - '//li[@class="list-group-item"]//div[@class="col-sm-5"]//a')) - tibble::as_tibble(data.frame(name = nms, id = ids, stringsAsFactors = FALSE)) + .Defunct(msg = "the coraltraits.org API is down for good") } - -coral_GET <- function(url, args, ...) { - con <- crul::HttpClient$new(url, opts = list(...)) - res <- con$get(query = args) - res$raise_for_status() - txt <- res$parse("UTF-8") - tibble::as_tibble( - utils::read.csv(text = txt, header = TRUE, stringsAsFactors = FALSE)) -} - -coralbase <- function() 'https://coraltraits.org' -coral_url <- function(var, id) paste0(file.path(coralbase(), var, id), ".csv") -lsw <- function(x) if (x) "on" else "off" diff --git a/R/defunct.R b/R/defunct.R index 94c767a..ad32526 100644 --- a/R/defunct.R +++ b/R/defunct.R @@ -1,6 +1,6 @@ #' Defunct functions in traits #' -#' These functions have been removed. See package `originr` +#' These functions have been removed. #' #' - `eol_invasive_`: This function has moved to a new package. #' See `originr::eol` @@ -11,6 +11,12 @@ #' - `is_native`: This function has moved to a new package. See #' `originr::is_native` #' - `tr_usda`: the API behind this function is down for good +#' - `coral_locations`: API down for good, as far as I can tell +#' - `coral_methodologies`: API down for good, as far as I can tell +#' - `coral_resources`: API down for good, as far as I can tell +#' - `coral_species`: API down for good, as far as I can tell +#' - `coral_taxa`: API down for good, as far as I can tell +#' - `coral_traits`: API down for good, as far as I can tell #' #' @name traits-defunct NULL diff --git a/R/ncbi_byid.R b/R/ncbi_byid.R index 29933f9..8305c31 100644 --- a/R/ncbi_byid.R +++ b/R/ncbi_byid.R @@ -27,7 +27,7 @@ #' @details If bad ids are included with good ones, the bad ones are #' silently dropped. If all ids are bad you'll get a stop with error message. #' @seealso [ncbi_searcher()], ncbi_byname()] -#' @author Scott Chamberlain \email{myrmecocystus@@gmail.com}, Rupert Collins +#' @author Scott Chamberlain, Rupert Collins #' @examples \dontrun{ #' # A single gene #' ncbi_byid(ids="360040093") diff --git a/R/ncbi_byname.R b/R/ncbi_byname.R index fede399..ae1b991 100644 --- a/R/ncbi_byname.R +++ b/R/ncbi_byname.R @@ -11,7 +11,7 @@ #' picking the longest available for the given gene. #' @return data.frame #' @seealso [ncbi_searcher()], [ncbi_byid()] -#' @author Scott Chamberlain \email{myrmecocystus@@gmail.com} +#' @author Scott Chamberlain #' @examples \dontrun{ #' # A single species #' ncbi_byname(taxa="Acipenser brevirostrum") diff --git a/R/ncbi_searcher.R b/R/ncbi_searcher.R index 6a3fe05..5742d0a 100644 --- a/R/ncbi_searcher.R +++ b/R/ncbi_searcher.R @@ -25,8 +25,7 @@ #' @return \code{data.frame} of results if a single input is given. A list of #' \code{data.frame}s if multiple inputs are given. #' @seealso \code{\link{ncbi_byid}}, \code{\link{ncbi_byname}} -#' @author Scott Chamberlain \email{myrmecocystus@@gmail.com}, Zachary Foster -#' \email{zacharyfoster1989@@gmail.com} +#' @author Scott Chamberlain, Zachary Foster \email{zacharyfoster1989@@gmail.com} #' @section Authentication: #' NCBI rate limits requests. If you set an API key you have a higher rate limit. #' Set your API key like `Sys.setenv(ENTREZ_KEY="yourkey")` or you can use diff --git a/R/taxa_search.R b/R/taxa_search.R index 7101b6a..956e08d 100644 --- a/R/taxa_search.R +++ b/R/taxa_search.R @@ -6,7 +6,7 @@ #' 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} +#' @author Scott Chamberlain #' @examples \dontrun{ #' taxa_search("Poa annua", db = "ncbi") #' } diff --git a/R/traits-package.r b/R/traits-package.r index 92e091c..e312c09 100644 --- a/R/traits-package.r +++ b/R/traits-package.r @@ -7,7 +7,6 @@ #' - National Center for Biotechnology Information - NCBI #' http://www.ncbi.nlm.nih.gov/ - `ncbi_` #' - Encyclopedia of Life Traitbank - `traitbank_` -#' - Coral Traits Database https://coraltraits.org/ - `coral_` #' - Birdlife International https://www.birdlife.org/ - #' `birdlife_` #' - LEDA Traitbase http://www.leda-traitbase.org/LEDAportal/index.jsp - @@ -17,17 +16,6 @@ #' #' See also [traits-defunct] #' -#' @examples \dontrun{ -#' library("traits") -#' -#' ## Search the Coral database -#' ## Get the species list and their ids -#' coral_species() -#' -#' ## Get data by taxon -#' coral_taxa(80) -#' } -#' #' @importFrom httr GET POST content stop_for_status warn_for_status #' authenticate #' @importFrom crul HttpClient @@ -42,7 +30,7 @@ #' @name traits-package #' @aliases traits #' @docType package -#' @author Scott Chamberlain \email{myrmecocystus@@gmail.com} +#' @author Scott Chamberlain #' @author Ignasi Bartomeus #' @author Zachary Foster #' @author David LeBauer diff --git a/README.Rmd b/README.Rmd index 7f6010d..cb98f90 100644 --- a/README.Rmd +++ b/README.Rmd @@ -56,11 +56,6 @@ Included in `traits` with the associated function prefix or function name: traitbank_ https://github.com/EOL/eol_website/blob/master/doc/api.md - - Coral Traits Database - coral_ - https://coraltraits.org/ - Birdlife International birdlife_ diff --git a/README.md b/README.md index 328003c..278b644 100644 --- a/README.md +++ b/README.md @@ -49,11 +49,6 @@ Included in `traits` with the associated function prefix or function name: traitbank_ https://github.com/EOL/eol_website/blob/master/doc/api.md - - Coral Traits Database - coral_ - https://coraltraits.org/ - Birdlife International birdlife_ diff --git a/man/birdlife_habitat.Rd b/man/birdlife_habitat.Rd index ef75b92..4a024ee 100644 --- a/man/birdlife_habitat.Rd +++ b/man/birdlife_habitat.Rd @@ -13,7 +13,7 @@ birdlife_habitat(id) a \code{data.frame} with level 1 and level 2 habitat classes, as well as importance ratings and occurrence type (e.g. breeding or non-breeding). The habitat classification scheme is described -at \url{http://bit.ly/1e6gKBr} +at https://www.iucnredlist.org/resources/classification-schemes } \description{ Get bird habitat information from BirdLife/IUCN diff --git a/man/coral-defunct.Rd b/man/coral-defunct.Rd new file mode 100644 index 0000000..f4e717e --- /dev/null +++ b/man/coral-defunct.Rd @@ -0,0 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/coral.R +\name{coral-defunct} +\alias{coral-defunct} +\alias{coral_taxa} +\alias{coral_traits} +\alias{coral_locations} +\alias{coral_methodologies} +\alias{coral_resources} +\alias{coral_species} +\title{Search for coral data on coraltraits.org} +\usage{ +coral_taxa(...) + +coral_traits(...) + +coral_locations(...) + +coral_methodologies(...) + +coral_resources(...) + +coral_species(...) +} +\arguments{ +\item{...}{ignored} +} +\description{ +DEFUNCT: As far as we can tell the coraltraits.org API is down +for good +} +\references{ +https://coraltraits.org/ +} +\keyword{internal} diff --git a/man/coral.Rd b/man/coral.Rd deleted file mode 100644 index 52a0dc6..0000000 --- a/man/coral.Rd +++ /dev/null @@ -1,94 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/coral.R -\name{coral} -\alias{coral} -\alias{coral_taxa} -\alias{coral_traits} -\alias{coral_locations} -\alias{coral_methodologies} -\alias{coral_resources} -\alias{coral_species} -\title{Search for coral data on coraltraits.org} -\usage{ -coral_taxa(taxon, taxonomy = FALSE, contextual = TRUE, global = FALSE, ...) - -coral_traits(trait, taxonomy = FALSE, contextual = TRUE, global = FALSE, ...) - -coral_locations( - location, - taxonomy = FALSE, - contextual = TRUE, - global = FALSE, - ... -) - -coral_methodologies( - methodology, - taxonomy = FALSE, - contextual = TRUE, - global = FALSE, - ... -) - -coral_resources( - resource, - taxonomy = FALSE, - contextual = TRUE, - global = FALSE, - ... -) - -coral_species(...) -} -\arguments{ -\item{taxon}{A taxon id} - -\item{taxonomy}{logical; Include contextual data. Default: \code{FALSE}} - -\item{contextual}{logical; Include contextual data. Default: \code{TRUE}} - -\item{global}{logical; Include contextual data. Default: \code{FALSE}} - -\item{...}{Curl options passed on to \link[crul:verb-GET]{crul::verb-GET}} - -\item{trait}{A trait id} - -\item{location}{A location id} - -\item{methodology}{A methodology id} - -\item{resource}{A resource id} -} -\description{ -Search for coral data on coraltraits.org -} -\examples{ -\dontrun{ -# Get the species and their Ids -head( coral_species() ) - -# Get data by taxon -coral_taxa(8) - -# Get data by trait -coral_traits(3) - -# Get data by methodology -coral_methodologies(2) - -# Get data by location -coral_locations(132) - -# Get data by resource -coral_resources(9) - -# curl options -coral_taxa(8, verbose=TRUE) -} -} -\references{ -https://coraltraits.org/ -} -\author{ -Scott Chamberlain \email{myrmecocystus@gmail.com} -} diff --git a/man/ncbi_byid.Rd b/man/ncbi_byid.Rd index 00b5ac7..578fd7b 100644 --- a/man/ncbi_byid.Rd +++ b/man/ncbi_byid.Rd @@ -55,5 +55,5 @@ ncbi_byid(ids=c("360040093","347448433")) \code{\link[=ncbi_searcher]{ncbi_searcher()}}, ncbi_byname()] } \author{ -Scott Chamberlain \email{myrmecocystus@gmail.com}, Rupert Collins +Scott Chamberlain, Rupert Collins } diff --git a/man/ncbi_byname.Rd b/man/ncbi_byname.Rd index b75d233..c4deeea 100644 --- a/man/ncbi_byname.Rd +++ b/man/ncbi_byname.Rd @@ -57,5 +57,5 @@ ncbi_byname(taxa=species, gene = c("coi", "co1"), seqrange = "1:2000") \code{\link[=ncbi_searcher]{ncbi_searcher()}}, \code{\link[=ncbi_byid]{ncbi_byid()}} } \author{ -Scott Chamberlain \email{myrmecocystus@gmail.com} +Scott Chamberlain } diff --git a/man/ncbi_searcher.Rd b/man/ncbi_searcher.Rd index a743260..c0563ae 100644 --- a/man/ncbi_searcher.Rd +++ b/man/ncbi_searcher.Rd @@ -116,6 +116,5 @@ two <- ncbi_searcher(taxa = "Salmonella enterica") \code{\link{ncbi_byid}}, \code{\link{ncbi_byname}} } \author{ -Scott Chamberlain \email{myrmecocystus@gmail.com}, Zachary Foster -\email{zacharyfoster1989@gmail.com} +Scott Chamberlain, Zachary Foster \email{zacharyfoster1989@gmail.com} } diff --git a/man/taxa_search.Rd b/man/taxa_search.Rd index 0fedc2c..989b822 100644 --- a/man/taxa_search.Rd +++ b/man/taxa_search.Rd @@ -26,5 +26,5 @@ taxa_search("Poa annua", db = "ncbi") } } \author{ -Scott Chamberlain \email{myrmecocystus@gmail.com} +Scott Chamberlain } diff --git a/man/traits-defunct.Rd b/man/traits-defunct.Rd index e8e9288..876562c 100644 --- a/man/traits-defunct.Rd +++ b/man/traits-defunct.Rd @@ -4,7 +4,7 @@ \alias{traits-defunct} \title{Defunct functions in traits} \description{ -These functions have been removed. See package \code{originr} +These functions have been removed. } \details{ \itemize{ @@ -17,5 +17,11 @@ See \code{originr::gisd} \item \code{is_native}: This function has moved to a new package. See \code{originr::is_native} \item \code{tr_usda}: the API behind this function is down for good +\item \code{coral_locations}: API down for good, as far as I can tell +\item \code{coral_methodologies}: API down for good, as far as I can tell +\item \code{coral_resources}: API down for good, as far as I can tell +\item \code{coral_species}: API down for good, as far as I can tell +\item \code{coral_taxa}: API down for good, as far as I can tell +\item \code{coral_traits}: API down for good, as far as I can tell } } diff --git a/man/traits-package.Rd b/man/traits-package.Rd index a3708a0..b4584b5 100644 --- a/man/traits-package.Rd +++ b/man/traits-package.Rd @@ -15,7 +15,6 @@ function prefix: \item National Center for Biotechnology Information - NCBI http://www.ncbi.nlm.nih.gov/ - \code{ncbi_} \item Encyclopedia of Life Traitbank - \code{traitbank_} -\item Coral Traits Database https://coraltraits.org/ - \code{coral_} \item Birdlife International https://www.birdlife.org/ - \code{birdlife_} \item LEDA Traitbase http://www.leda-traitbase.org/LEDAportal/index.jsp - @@ -25,22 +24,9 @@ http://www.ncbi.nlm.nih.gov/ - \code{ncbi_} } See also \link{traits-defunct} -} -\examples{ -\dontrun{ -library("traits") - -## Search the Coral database -## Get the species list and their ids -coral_species() - -## Get data by taxon -coral_taxa(80) -} - } \author{ -Scott Chamberlain \email{myrmecocystus@gmail.com} +Scott Chamberlain Ignasi Bartomeus diff --git a/vignettes/traits.Rmd b/vignettes/traits.Rmd index 6f53ce7..77ef089 100644 --- a/vignettes/traits.Rmd +++ b/vignettes/traits.Rmd @@ -158,71 +158,6 @@ traitbank(query = "MATCH (n:Trait) RETURN n LIMIT 1;") #> 1 Froese, R. and D. Pauly. Editors. 2019. FishBase. World Wide Web electronic publication. www.fishbase.org, version (08/2019). Accessed at on 25 May 2020. ``` -## Coral - -Get the species list and their ids - - -```r -coral_species() -#> # A tibble: 1,548 x 2 -#> name id -#> -#> 1 Acanthastrea brevis 3 -#> 2 Acanthastrea echinata 4 -#> 3 Acanthastrea hemprichi 6 -#> 4 Acanthastrea ishigakiensis 8 -#> 5 Acanthastrea regularis 12 -#> 6 Acanthastrea rotundoflora 13 -#> 7 Acanthastrea subechinata 14 -#> 8 Acropora abrolhosensis 16 -#> 9 Acropora abrotanoides 17 -#> 10 Acropora aculeus 18 -#> # … with 1,538 more rows -``` - -Get data by taxon - - -```r -coral_taxa(80) -#> # A tibble: 3,540 x 25 -#> observation_id access user_id specie_id specie_name location_id location_name -#> -#> 1 157133 1 10 80 Acropora h… 1 Global estim… -#> 2 156961 1 14 80 Acropora h… 409 Indo-Pacific… -#> 3 5781 1 1 80 Acropora h… 1 Global estim… -#> 4 156610 1 2 80 Acropora h… 500 Tiao-Shi, Na… -#> 5 158118 1 10 80 Acropora h… 409 Indo-Pacific… -#> 6 119211 1 49 80 Acropora h… 1 Global estim… -#> 7 158211 1 10 80 Acropora h… 413 Big Broadhur… -#> 8 90294 1 15 80 Acropora h… 341 Xiaodonghai,… -#> 9 90294 1 15 80 Acropora h… 341 Xiaodonghai,… -#> 10 90294 1 15 80 Acropora h… 341 Xiaodonghai,… -#> # … with 3,530 more rows, and 18 more variables: latitude , -#> # longitude , resource_id , resource_secondary_id , -#> # measurement_id , trait_id , trait_name , standard_id , -#> # standard_unit , methodology_id , methodology_name , -#> # value , value_type , precision , precision_type , -#> # precision_upper , replicates , notes -``` - -Get data by trait - - -```r -coral_traits(105) -#> # A tibble: 0 x 25 -#> # … with 25 variables: observation_id , access , user_id , -#> # specie_id , specie_name , location_id , location_name , -#> # latitude , longitude , resource_id , -#> # resource_secondary_id , measurement_id , trait_id , -#> # trait_name , standard_id , standard_unit , -#> # methodology_id , methodology_name , value , -#> # value_type , precision , precision_type , -#> # precision_upper , replicates , notes -``` - ## Birdlife International Habitat data diff --git a/vignettes/traits.Rmd.og b/vignettes/traits.Rmd.og index 2c2495c..2d104dc 100644 --- a/vignettes/traits.Rmd.og +++ b/vignettes/traits.Rmd.og @@ -68,26 +68,6 @@ head(out) traitbank(query = "MATCH (n:Trait) RETURN n LIMIT 1;") ``` -## Coral - -Get the species list and their ids - -```{r} -coral_species() -``` - -Get data by taxon - -```{r} -coral_taxa(80) -``` - -Get data by trait - -```{r} -coral_traits(105) -``` - ## Birdlife International Habitat data