├── .github └── workflows │ └── R-CMD-check.yaml ├── .gitignore ├── .travis.yml ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── NEWS ├── R ├── OnAttach.R ├── api_key.R ├── download_col_china.R ├── find_synonyms.R ├── get_col_global.R ├── get_col_taiwan.R ├── get_province.R ├── get_redlist_china.R ├── get_top20.R ├── list_df.R ├── open_url.R ├── search_checklist.R ├── search_family_id.R ├── search_taxon_id.R ├── zoology_dbase_name.R ├── zoology_description.R └── zoology_description_type.R ├── README.md ├── SP2000.Rproj ├── _config.yml ├── inst ├── figures │ └── logo.png └── htmlwidgets │ ├── mywidget.js │ └── mywidget.yaml └── man ├── SP2000-package.Rd ├── api_key.Rd ├── download_col_china.Rd ├── find_synonyms.Rd ├── get_col_global.Rd ├── get_col_taiwan.Rd ├── get_province.Rd ├── get_redlist_china.Rd ├── get_top20.Rd ├── list_df.Rd ├── open_url.Rd ├── search_checklist.Rd ├── search_family_id.Rd ├── search_taxon_id.Rd ├── zoology_dbase_name.Rd └── zoology_description.Rd /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | pull_request: 6 | branches: 7 | - master 8 | 9 | name: R-CMD-check 10 | 11 | jobs: 12 | R-CMD-check: 13 | runs-on: ${{ matrix.config.os }} 14 | 15 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 16 | 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | config: 21 | - {os: windows-latest, r: '4.0'} 22 | - {os: macOS-latest, r: '4.0'} 23 | # - {os: macOS-latest, r: 'devel'} 24 | - {os: ubuntu-16.04, r: '4.0', rspm: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"} 25 | 26 | env: 27 | R_REMOTES_NO_ERRORS_FROM_WARNINGS: true 28 | RSPM: ${{ matrix.config.rspm }} 29 | 30 | steps: 31 | - uses: actions/checkout@v2 32 | 33 | - uses: r-lib/actions/setup-r@master 34 | with: 35 | r-version: ${{ matrix.config.r }} 36 | 37 | - uses: r-lib/actions/setup-pandoc@master 38 | 39 | - name: Query dependencies 40 | run: | 41 | install.packages('remotes') 42 | saveRDS(remotes::dev_package_deps(dependencies = TRUE), "depends.Rds", version = 2) 43 | shell: Rscript {0} 44 | 45 | - name: Cache R packages 46 | if: runner.os != 'Windows' 47 | uses: actions/cache@v1 48 | with: 49 | path: ${{ env.R_LIBS_USER }} 50 | key: ${{ runner.os }}-r-${{ matrix.config.r }}-2-${{ hashFiles('depends.Rds') }} 51 | restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-2- 52 | 53 | - name: Install system dependencies 54 | if: runner.os == 'Linux' 55 | env: 56 | RHUB_PLATFORM: linux-x86_64-ubuntu-gcc 57 | run: | 58 | Rscript -e "remotes::install_github('r-hub/sysreqs')" 59 | sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))") 60 | sudo -s eval "$sysreqs" 61 | - name: Install macOS system dependencies 62 | if: matrix.config.os == 'macOS-latest' && matrix.config.r == 'devel' 63 | # the xml2 thing is a hack / experiment 64 | run: | 65 | brew install imagemagick@6 66 | Rscript -e "remotes::install_github('r-lib/xml2') 67 | Rscript -e "remotes::install_github('r-lib/XML') 68 | - name: Install dependencies 69 | run: | 70 | remotes::install_deps(dependencies = TRUE) 71 | remotes::install_cran("rcmdcheck") 72 | shell: Rscript {0} 73 | 74 | - name: Configure Git user 75 | run: | 76 | git config --global user.email "ghau@example.com" 77 | git config --global user.name "GitHub Actions User" 78 | - name: Check 79 | run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "warning", check_dir = "check") 80 | shell: Rscript {0} 81 | 82 | - name: Upload check results 83 | if: failure() 84 | uses: actions/upload-artifact@master 85 | with: 86 | name: ${{ runner.os }}-r${{ matrix.config.r }}-results 87 | path: check 88 | 89 | - name: Reveal testthat details 90 | run: find . -name testthat.Rout -exec cat '{}' ';' 91 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # History files 2 | .Rhistory 3 | .Rapp.history 4 | 5 | # Session Data files 6 | .RData 7 | 8 | # User-specific files 9 | .Ruserdata 10 | 11 | # Example code in package build process 12 | *-Ex.R 13 | 14 | # Output files from R CMD build 15 | /*.tar.gz 16 | 17 | # Output files from R CMD check 18 | /*.Rcheck/ 19 | 20 | # RStudio files 21 | .Rproj.user/ 22 | 23 | # produced vignettes 24 | vignettes/*.html 25 | vignettes/*.pdf 26 | 27 | # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 28 | .httr-oauth 29 | 30 | # knitr and R markdown default cache directories 31 | *_cache/ 32 | /cache/ 33 | 34 | # Temporary files created by R markdown 35 | *.utf8.md 36 | *.knit.md 37 | 38 | # R Environment Variables 39 | .Renviron 40 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: r 2 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: SP2000 2 | Type: Package 3 | Title: Catalogue of Life Toolkit 4 | Version: 0.2.0 5 | Date: 2020-10-26 6 | Authors@R: c( 7 | person(given = "Liuyong", family = "Ding", email = "ly_ding@126.com", role = c("aut", "cre"), comment = c(ORCID="0000-0002-5490-182X")), 8 | person(given = "Minrui", family = "Huang", email = "minrui-huang@mail.ynu.edu.cn", role = "ctb"), 9 | person(given = "Ke", family = "Yang", email = "ydyangke@163.com", role = "ctb"), 10 | person(given = "Jun", family = "Wang", email = "wangjun168@ynu.edu.cn", role = "ctb", comment = c(ORCID="0000-0003-2481-1409")), 11 | person(given = "Juan", family = "Tao", email = "taojuanat@gmail.com", role = "ctb"), 12 | person(given = "Chengzhi", family = "Ding", email = "chzhding@ynu.edu.cn", role = "ctb", comment = c(ORCID="0000-0001-5215-7374")), 13 | person(given = "Daming", family = "He", email = "dmhe@ynu.edu.cn", role = "ctb") 14 | ) 15 | Maintainer: Liuyong Ding 16 | Description: A programmatic interface to , re-written based on an accompanying 'Species 2000' API. Access tables describing catalogue of the Chinese known species of animals, plants, fungi, micro-organisms, and more. This package also supports access to catalogue of life global , China animal scientific database and catalogue of life Taiwan . The development of 'SP2000' package were supported by Biodiversity Survey and Assessment Project of the Ministry of Ecology and Environment, China <2019HJ2096001006>,Yunnan University's "Double First Class" Project and Yunnan University's Research Innovation Fund for Graduate Students <2019227>. 17 | Depends: R (>= 3.0.0) 18 | Imports: 19 | jsonlite, 20 | tibble, 21 | pbmcapply, 22 | purrr, 23 | rlist, 24 | XML, 25 | xml2, 26 | DT, 27 | urltools 28 | Suggests: 29 | utils, 30 | testthat 31 | License: Artistic-2.0 32 | URL: https://otoliths.github.io/SP2000/ 33 | BugReports: https://github.com/Otoliths/SP2000/issues 34 | Encoding: UTF-8 35 | LazyData: true 36 | RoxygenNote: 7.1.1 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Liuyong Ding 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(download_col_china) 4 | export(find_synonyms) 5 | export(get_col_global) 6 | export(get_col_taiwan) 7 | export(get_province) 8 | export(get_redlist_china) 9 | export(get_top20) 10 | export(list_df) 11 | export(open_url) 12 | export(search_checklist) 13 | export(search_family_id) 14 | export(search_taxon_id) 15 | export(set_search_key) 16 | export(zoology_dbase_name) 17 | export(zoology_description) 18 | export(zoology_description_type) 19 | importFrom(DT,"%>%") 20 | importFrom(DT,datatable) 21 | importFrom(DT,formatStyle) 22 | importFrom(DT,styleEqual) 23 | importFrom(XML,xmlToDataFrame) 24 | importFrom(jsonlite,fromJSON) 25 | importFrom(pbmcapply,pbmclapply) 26 | importFrom(purrr,transpose) 27 | importFrom(rlist,list.extract) 28 | importFrom(rlist,list.filter) 29 | importFrom(rlist,list.rbind) 30 | importFrom(tibble,as_tibble) 31 | importFrom(tibble,tibble) 32 | importFrom(urltools,url_encode) 33 | importFrom(utils,browseURL) 34 | importFrom(utils,data) 35 | importFrom(utils,download.file) 36 | importFrom(xml2,download_xml) 37 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | 0.2.0 2 | - Update DESCRIPTION 3 | - Added China animal scientific database 4 | - Fixed bugs of the download_col_china function 5 | - Fixed bugs of the find_synonyms function 6 | 7 | 0.1.0 8 | - Update DESCRIPTION 9 | - Upgrade 'Species 2000' API (version 2) 10 | 11 | 0.0.10 12 | - Update DESCRIPTION 13 | - Fixed bugs of the list_df function 14 | 15 | 0.0.9 16 | - Update DESCRIPTION 17 | - Delete the duplicates of the result returned by the find_synonyms function 18 | - Added SP2000 alias 19 | - Update search_checklist,find_synonyms,get_col_global,search_taxon_id and search_family_id functions 20 | 21 | 0.0.8 22 | - Update DESCRIPTION 23 | - Update all function names in lowercase for user input 24 | 25 | 0.0.7 26 | - Update DESCRIPTION 27 | - Update download_CoLChina 28 | - Added get_RedlistChina function 29 | 30 | 0.0.6 31 | - Update DESCRIPTION 32 | - Update search_checklist function 33 | - Update search_familyID function 34 | - Update search_taxonID function 35 | - Added set_search_key function 36 | - Added get_CoLGlobal function 37 | - Added get_CoLTaiwan function 38 | - Added find_Synonyms function 39 | 40 | 0.0.5 41 | - Initial release 42 | -------------------------------------------------------------------------------- /R/OnAttach.R: -------------------------------------------------------------------------------- 1 | ##\nTo cite SP2000 in publications, please use: 2 | ##\nDing LY, Li H, Tao J, Zhang JL, Huang MR, Yang K, Wang J, He DM, Ding CZ (2020) SP2000: An open source R package for querying the catalogue of life. Biodiversity Science. 3 | 4 | .onAttach <- function(libname, pkgname){ 5 | packageStartupMessage(sprintf("Welcome to R Package SP2000 %s !!! 6 | \n\nTo start with the SP2000, please digit: 7 | \nhttps://cran.r-project.org/package=SP2000(R) 8 | \nhttps://pypi.org/project/SP2000(Python)", 9 | utils::packageVersion("SP2000")),sep = "\n") 10 | 11 | syst <- Sys.info()[['sysname']] 12 | if(syst == "Windows"){ 13 | # Ensure that Chinese Characters could be displayed properly. 14 | suppressMessages(Sys.setlocale(category = "LC_ALL", locale = "Chinese")) 15 | } 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /R/api_key.R: -------------------------------------------------------------------------------- 1 | #' @title SP2000 API keys 2 | #' @description Apply for the apiKey variable to be used by all search_* functions and zoology_* functions, 3 | #' register for \url{http://sp2000.org.cn/api/document} and use an API key. This function allows users to set this key. 4 | #' Note: The daily API visits of ordinary users are 2000, 5 | #' If you want to apply for increasing the daily API request limit, 6 | #' please fill in the application form \url{http://col.especies.cn/doc/API.docx} and send an email to \email{SP2000CN@ibcas.ac.cn} entitled "Application for increasing API Request Times". 7 | #' @rdname api_key 8 | #' @param key \code{string} Value to set apiKey to (i.e. your API key). 9 | #' @param db \code{string} Set up the database API, db = c("sp2000","zoology"). 10 | #' @return A logical of length one, TRUE is the value was set FALSE if not. 11 | #' value is returned inside invisible(), i.e. it is not printed to screen 12 | #' when the function is called. 13 | #' @author Liuyong Ding \email{ly_ding@126.com} 14 | #' @examples 15 | #' \dontrun{ 16 | #' #Set the apiKey variable to be used by all search_* functions 17 | #' set_search_key("your apiKey",db = "sp2000") 18 | #' 19 | #' #Set the apiKey variable to be used by all zoology_* functions 20 | #' set_search_key("your apiKey",db = "zoology") 21 | #' 22 | #'} 23 | #' @export 24 | set_search_key <- function(key, db = "sp2000"){ 25 | switch(db, 26 | sp2000 = { 27 | Sys.setenv(sp2000_apiKey = key) 28 | }, 29 | zoology = { 30 | Sys.setenv(zoology_apiKey = key) 31 | } 32 | ) 33 | } 34 | 35 | is_search_key_set <- function(){ 36 | !identical(Sys.getenv('sp2000_apiKey'), "") 37 | } 38 | 39 | #China Animal Scientific Database 40 | is_query_key_set <- function(){ 41 | !identical(Sys.getenv('zoology_apiKey'), "") 42 | } 43 | -------------------------------------------------------------------------------- /R/download_col_china.R: -------------------------------------------------------------------------------- 1 | #' @title Download 'Catalogue of Life China': Annual Checklist 2 | #' @description Organized by the Biodiversity Committee of Chinese Academy of Sciences (BC-CAS), Catalogue of Life China Annual Checklist edition has been compiled by Species 2000 China Node. 3 | #' @rdname download_col_china 4 | #' @name download_col_china 5 | #' @param version \code{integer} Release version of annual checklist,the default value is 2020. 6 | #' @param OS \code{character} Supported operating system,c("MacOS", "Ubuntu" ,"Windows"),the default value is "MacOS". 7 | #' @param dir A non-empty character vector giving the directory name by user,the default value is dir = tempdir(),see \code{\link{tempdir}} for details. 8 | #' @param mode A character string specifying the mode with which to write the file. Useful values are "w", "wb" (binary), "a" (append) and "ab". see \code{\link{download.file}} for details. 9 | #' @param ... Allow additional arguments to be passed, unused. see \code{\link{download.file}} for details. 10 | #' @return URL 11 | #' @author Liuyong Ding \email{ly_ding@126.com} 12 | #' @details Visit the website \url{http://sp2000.org.cn/download} for more details. 13 | #' @importFrom utils download.file 14 | #' @importFrom utils browseURL 15 | #' @examples 16 | #' \dontrun{ 17 | #' dir <- tempdir() 18 | #' download_col_china(version = "2020",OS = "MacOS", dir = dir) 19 | #' } 20 | #' @export 21 | download_col_china <- function(version = "2020", OS = "MacOS", dir = tempdir(), mode, ...) { 22 | cat(sprintf("Download date: %s",Sys.Date()),sep = "\n") 23 | version <- match.arg(version, 2018:as.integer(substr(Sys.Date(), 1, 4))) 24 | OS <- match.arg(OS, c("MacOS", "Ubuntu" ,"Windows")) 25 | if (version %in% c("2018","2019") ){ 26 | url <- paste0('http://sp2000.org.cn/CoL/CoLChina',version, '.',"iso") 27 | } 28 | if (version == "2020" & OS == "MacOS"){ 29 | url <- paste0('http://sp2000.org.cn/CoL/CoLChina',version,"-v20.1.12_mac_64", '.',"iso") 30 | } 31 | if (version == "2020" & OS == "Ubuntu"){ 32 | url <- paste0('http://sp2000.org.cn/CoL/CoLChina',version,"-v20.1.12_linux_64", '.',"iso") 33 | } 34 | if (version == "2020" & OS == "Windows"){ 35 | url <- paste0('http://sp2000.org.cn/CoL/CoLChina',version,"-v20.1.12_win_x86_64", '.',"iso") 36 | } 37 | outfile <- sub(".*/", "", url) 38 | download.file(url, file.path(dir,outfile),mode, ...) 39 | cat(sprintf("Download path: %s",dir),sep = "\n") 40 | browseURL(url) 41 | } 42 | 43 | -------------------------------------------------------------------------------- /R/find_synonyms.R: -------------------------------------------------------------------------------- 1 | ##' @title Find synonyms via species name 2 | ##' @description Find synonyms via species name from Catalogue of Life Global. 3 | ##' @rdname find_synonyms 4 | ##' @param query \code{character} species name,The function is similar to \code{\link{get_col_global}}. 5 | ##' @param mc.cores The number of cores to use, i.e. at most how many child processes will be run simultaneously. The option is initialized from environment variable MC_CORES if set. Must be at least one, and parallelization requires at least two cores,see \code{\link{mclapply}} for details. 6 | ##' @importFrom jsonlite fromJSON 7 | ##' @importFrom rlist list.rbind 8 | ##' @importFrom pbmcapply pbmclapply 9 | ##' @return object 10 | ##' @author Liuyong Ding \email{ly_ding@126.com} 11 | ##' @details Visit the website \url{http://webservice.catalogueoflife.org/col/webservice} for more details. 12 | ##' @references \url{https://github.com/lutteropp/SpeciesSynonymFinder/blob/master/find_synonyms.r} 13 | ##' @examples 14 | ##' \dontrun{ 15 | ##' ##Get Catalogue of Life Global checklist via species name 16 | ##' x1 <- get_col_global(query = c("Anguilla marmorata","Anguilla japonica", 17 | ##' "Anguilla bicolor","Anguilla nebulosa", 18 | ##' "Anguilla luzonensis"), 19 | ##' option = "name") 20 | ##' str(x1) 21 | ##' 22 | ##' ##full queries 23 | ##' x2 <- get_col_global(query = "Anguilla", response = "full") 24 | ##' 25 | ##' 26 | ##' ##Find synonyms via species name 27 | ##' find_synonyms(query = c("Anguilla marmorata","Anguilla japonica", 28 | ##' "Anguilla bicolor","Anguilla nebulosa", 29 | ##' "Anguilla luzonensis")) 30 | ##' } 31 | ##' @export 32 | find_synonyms <- function(query, mc.cores = 2) { 33 | cat(sprintf("Download date: %s",Sys.Date()),sep = "\n") 34 | if (.Platform$OS.type == "windows") { 35 | mc.cores = 1 36 | } 37 | if(length(query) == 1){ 38 | x <- synonyms(query) 39 | cat(sprintf("Find %s results of synonyms for %s are as follows: ",length(x), query),sep = "\n") 40 | }else{ 41 | x <- pbmclapply(query,synonyms,mc.cores = mc.cores) 42 | names(x)<- query 43 | for (i in 1:length(x)) { 44 | cat(sprintf("Find %s results of synonyms for %s are as follows: ",length(x[[query[i]]]), query[i]),sep = "\n") 45 | } 46 | } 47 | return(x) 48 | } 49 | 50 | synonyms <- function(query) { 51 | synonyms = list() 52 | species_name_no_spaces = gsub(" ","+",query, fixed=TRUE) 53 | url = paste0(webservice(),"name=",species_name_no_spaces, "&format=json&response=full") 54 | dbentry = jsonlite::fromJSON(url, flatten=TRUE) 55 | if (nrow(dbentry$result) == 0) { 56 | print(paste("Unfortunately, no results were found for ", query, ". Please check your spelling."), sep="") 57 | } else { 58 | #cat(sprintf("Find the results of synonyms for %s are as follows: ", query),sep = "\n") 59 | for (i in 1:nrow(dbentry$result)) { 60 | name = paste(dbentry$result$name[i]) 61 | if (name == query) { 62 | status = paste(dbentry$result$name_status[i]) 63 | if (status == "synonym") { 64 | #print(paste("Adding", dbentry$results[i,]$accepted_name.name)) 65 | synonyms = c(synonyms,c(paste(dbentry$result$accepted_name.name[i]))) 66 | } else { #accepted name 67 | for (j in 1:length(dbentry[["result"]][["synonyms"]][[1]][["name"]])) { 68 | #print(paste("Adding", dbentry$results[i,]$synonyms[[1]]$name[j])) 69 | synonyms = c(synonyms,c(paste(dbentry[["result"]][["synonyms"]][[1]][["name"]][j]))) 70 | } 71 | } 72 | } 73 | } 74 | } 75 | #cat(sprintf("Find %s results of synonyms for %s are as follows: ",length(unique(rlist::list.rbind(synonyms)[,1])), query),sep = "\n") 76 | return(unique(rlist::list.rbind(synonyms)[,1])) 77 | } 78 | 79 | webservice <- function() "http://webservice.catalogueoflife.org/col/webservice?" 80 | 81 | -------------------------------------------------------------------------------- /R/get_col_global.R: -------------------------------------------------------------------------------- 1 | ##' @title Search Catalogue of Life Global checklist 2 | ##' @description Get Catalogue of Life Global checklist via species name and id. 3 | ##' @rdname get_col_global 4 | ##' @param query \code{string} The string to search for. 5 | ##' @param option \code{character} There is one required parameter, which is either name or id. Give eithera name or an ID. If an ID is given, the name parameter may not be used, and vice versa. option=c("id","name"),the default value is "name". Only exact matches found the name given will be returned, unless a wildcard (*) is appended. Wildcards are allowed only at the end of the string. This offers the option to e.g. search for genus* to retrieve the genus plus all its (infra)species. The name must be at least 3 characters long, not counting the wildcard character. The record ID of the specific record to return (only for scientific names of species or infraspecific taxa). 6 | ##' @param response \code{character} Type of response returned. Valid values are response=terse and response=full. if the response parameter is omitted, the results are returned in the default terse format. If format=terse then a minimum set of results are returned (this is faster and smaller, enough for name lookup), if format=full then all available information is returned, response=c("full","terse"),the default value is "terse". 7 | ##' @param start \code{integer} Record number to start at. If omitted, the results are returned from the first record (start=0). Use in combination with limit to page through results. Note that we do the paging internally for you, but you can manually set the start parameter. 8 | ##' @param limit \code{integer} Number of records to return. This is useful if the total number of results is larger than the maximum number of results returned by a single Web service query (currently the maximum number of results returned by a single query is 500 for terse queries and 50 for full queries,the default value is 500.Note that there is a hard maximum of 10,000, which is calculated as the limit+start, so start=99,00 and limit=2000 won't work. 9 | ##' @param mc.cores The number of cores to use, i.e. at most how many child processes will be run simultaneously. The option is initialized from environment variable MC_CORES if set. Must be at least one, and parallelization requires at least two cores,see \code{\link{mclapply}} for details. 10 | ##' @importFrom jsonlite fromJSON 11 | ##' @importFrom rlist list.rbind 12 | ##' @importFrom rlist list.filter 13 | ##' @importFrom tibble tibble 14 | ##' @importFrom pbmcapply pbmclapply 15 | ##' @return object 16 | ##' @author Liuyong Ding \email{ly_ding@126.com} 17 | ##' @details Visit the website \url{http://webservice.catalogueoflife.org/col/webservice} for more details. 18 | ##' @examples 19 | ##' \dontrun{ 20 | ##' ##Get Catalogue of Life Global checklist via species name 21 | ##' x1 <- get_col_global(query = c("Anguilla marmorata","Anguilla japonica", 22 | ##' "Anguilla bicolor","Anguilla nebulosa", 23 | ##' "Anguilla luzonensis"), 24 | ##' option = "name") 25 | ##' str(x1) 26 | ##' 27 | ##' ##full queries 28 | ##' x2 <- get_col_global(query = "Anguilla", response = "full") 29 | ##' 30 | ##' 31 | ##' ##Find synonyms via species name 32 | ##' find_synonyms(query = c("Anguilla marmorata","Anguilla japonica", 33 | ##' "Anguilla bicolor","Anguilla nebulosa", 34 | ##' "Anguilla luzonensis")) 35 | ##' } 36 | ##' @export 37 | get_col_global <- function(query, option = "name", response = "terse",start = 0, limit = 500, mc.cores = 2){ 38 | cat(sprintf("Download date: %s",Sys.Date()),sep = "\n") 39 | cat(sprintf("Research type: %s",option), sep = "\n") 40 | if (.Platform$OS.type == "windows") { 41 | mc.cores = 1 42 | } 43 | x <- pbmclapply(query,mc.cores = mc.cores,limits_col_global,option,response,start,limit) 44 | names(x)<- query 45 | #cat(sprintf("Records - Found: %s, Returned: %s",found3(query,x),returned3(query,x)), sep = "\n") 46 | return(x) 47 | } 48 | 49 | webservice <- function() "http://webservice.catalogueoflife.org/col/webservice?" 50 | 51 | 52 | col_global <- function(query, option = "name",response = "terse", start = 0){ 53 | option <- match.arg(option, c("id","name")) 54 | response <- match.arg(response, c("full","terse")) 55 | switch (option, 56 | name = { 57 | species_name_no_spaces = gsub(" ","+",query, fixed=TRUE) 58 | url = paste(webservice(), "name=", species_name_no_spaces, "&format=json&","response=",response,"&","start=",start,sep = "") 59 | dbentry = jsonlite::fromJSON(url, flatten=TRUE) 60 | }, 61 | id = { 62 | url = paste0(webservice(), "id=", query, "&format=json&","response=",response,"&","start=",start) 63 | dbentry = jsonlite::fromJSON(url, flatten=TRUE) 64 | } 65 | ) 66 | return(dbentry) 67 | } 68 | 69 | 70 | limits_col_global <- function(query, option = "name",response = "terse", start, limit){ 71 | number_of_results_returned <- "number_of_results_returned" 72 | switch(response, 73 | terse = { 74 | if(limit > 500){ 75 | #c(start,seq(500,limit,500)) 76 | x <- lapply(seq(start,limit,500),function(i){ 77 | col_global(query = query,option = option, response = response, start = i) 78 | }) 79 | x1 <- rlist::list.filter(x, number_of_results_returned > 0) 80 | x <- clean(x,response = response) 81 | }else { 82 | x <- col_global(query = query,option = option, response = response, start = start) 83 | x <- list(meta = list(id = x$id, 84 | name = x$name, 85 | total_number_of_results = x$total_number_of_results, 86 | number_of_results_returned = x$number_of_results_returned, 87 | start = x$start, 88 | error_mexage = x$error_mexage, 89 | version = x$version, 90 | rank = x$rank), 91 | data = x$results) 92 | x$data <- tibble::as_tibble(x$data) 93 | } 94 | }, 95 | full = { 96 | if (limit > 50){ 97 | x <- lapply(seq(start,limit,50),function(i){ 98 | col_global(query = query,option = option, response = response, start = i) 99 | }) 100 | x <- rlist::list.filter(x, number_of_results_returned > 0) 101 | x <- clean(x,response = response) 102 | 103 | }else{ 104 | x <- col_global(query = query,option = option, response = response, start = start) 105 | x <- list(meta = list(id = x$id, 106 | name = x$name, 107 | total_number_of_results = x$total_number_of_results, 108 | number_of_results_returned = x$number_of_results_returned, 109 | start = x$start, 110 | error_mexage = x$error_mexage, 111 | version = x$version, 112 | rank = x$rank), 113 | data = x$results) 114 | x$data <- tibble::as_tibble(x$data) 115 | 116 | } 117 | } 118 | ) 119 | return(x) 120 | } 121 | 122 | clean <- function(x,response){ 123 | switch (response, 124 | terse = { 125 | ss <- purrr::transpose(x) 126 | ss$results <- purrr::transpose(ss$results) 127 | for (i in 1:8) { 128 | ss[[names(ss)[i]]] <- rlist::list.ungroup(ss[[names(ss)[i]]]) 129 | } 130 | # for (j in names(ss$results)[c(1:11,12:19,20:26)]) { 131 | # ss[["results"]][[j]] <- rlist::list.ungroup(ss[["results"]][[j]]) 132 | # } 133 | # for (k in names(ss$results)[c(17,19)]) { 134 | # ss[["results"]][[k]] <- rlist::list.ungroup(purrr::transpose(ss[["results"]][[k]])) 135 | # } 136 | ss <- list(meta = list(id = ss$id, 137 | name = ss$name, 138 | total_number_of_results = ss$total_number_of_results, 139 | number_of_results_returned = ss$number_of_results_returned, 140 | start = ss$start, 141 | error_message = ss$error_message, 142 | version = ss$version, 143 | rank = ss$rank), 144 | data = ss$results) 145 | #ss$data <- tibble::as_tibble(ss$data) 146 | }, 147 | full = { 148 | ss <- purrr::transpose(x) 149 | ss$results <- purrr::transpose(ss$results) 150 | for (i in 1:8) { 151 | ss[[names(ss)[i]]] <- rlist::list.ungroup(ss[[names(ss)[i]]]) 152 | } 153 | # for (j in names(ss$results)[c(1:7,10:15,17:21,25:42,48)]) { 154 | # ss[["results"]][[j]] <- rlist::list.ungroup(ss[["results"]][[j]]) 155 | # } 156 | # for (k in names(ss$results)[c(8:9,16,22:24,43:47)]) { 157 | # ss[["results"]][[k]] <- rlist::list.ungroup(purrr::transpose(ss[["results"]][[k]])) 158 | # } 159 | ss <- list(meta = list(id = ss$id, 160 | name = ss$name, 161 | total_number_of_results = ss$total_number_of_results, 162 | number_of_results_returned = ss$number_of_results_returned, 163 | start = ss$start, 164 | error_message = ss$error_message, 165 | version = ss$version, 166 | rank = ss$rank), 167 | data = ss$results) 168 | #ss$data <- tibble::as_tibble(ss$data) 169 | } 170 | ) 171 | return(ss) 172 | } 173 | -------------------------------------------------------------------------------- /R/get_col_taiwan.R: -------------------------------------------------------------------------------- 1 | ##' @title Search Catalogue of Life Taiwan checklist 2 | ##' @description Get Catalogue of Life Taiwan checklist via advanced query. 3 | ##' @rdname get_col_taiwan 4 | ##' @param query \code{string} The string to search for. 5 | ##' @param level \code{character} Query by category level, level=c("kingdom","phylum","class","order","family","genus","species"),the default value is "species". 6 | ##' @param option \code{character} Query format, option=c("contain","equal","beginning"),the default value is "equal". 7 | ##' @param include_synonyms \code{logic} Whether the results contain a synonym or not. 8 | ##' @importFrom XML xmlToDataFrame 9 | ##' @importFrom xml2 download_xml 10 | ##' @importFrom tibble as_tibble 11 | ##' @return object 12 | ##' @author Liuyong Ding \email{ly_ding@126.com} 13 | ##' @details Visit the website \url{https://taibnet.sinica.edu.tw/eng/taibnet_species_query.php} for more details. 14 | ##' @examples 15 | ##' \dontrun{ 16 | ##' ##Search Catalogue of Life Taiwan checklist 17 | ##' get_col_taiwan(query="Anguilla",level="species",option = "contain") 18 | ##' 19 | ##' get_col_taiwan(query="Anguillidae",level="family") 20 | ##' } 21 | ##' @export 22 | 23 | get_col_taiwan <- function(query, level = "species", option = "equal",include_synonyms = TRUE){ 24 | cat(sprintf("Download date: %s",Sys.Date()),sep = "\n") 25 | query = gsub(" ","+",query, fixed=TRUE) 26 | level <- match.arg(level, c("kingdom","phylum","class","order","family","genus","species")) 27 | option <- match.arg(option, c("contain","equal","beginning")) 28 | if (level == "species"){ 29 | level = "name" 30 | } 31 | if (include_synonyms){ 32 | url <- paste0(web(),"R1=",level,"&D1=&D2=",level,"&D3=",option,"&T1=",query,"&T2=&id=y&sy=y") 33 | CoLTaiwan <- tibble::as_tibble(XML::xmlToDataFrame(download_xml(url,file = tempfile()))) 34 | }else{ 35 | url <- paste0(web(),"R1=",level,"&D1=&D2=",level,"&D3=",option,"&T1=",query,"&T2=&id=y&sy=") 36 | CoLTaiwan <- tibble::as_tibble(XML::xmlToDataFrame(download_xml(url,file = tempfile()))) 37 | } 38 | return(CoLTaiwan) 39 | } 40 | 41 | web <- function()"http://taibnet.sinica.edu.tw/eng/taibnet_xml.php?" 42 | 43 | -------------------------------------------------------------------------------- /R/get_province.R: -------------------------------------------------------------------------------- 1 | #' @title Statistics on Species or Infraspecies by Province from Catalogue of Life China checklist 2 | #' @description Download the statistics datasets on species/infraspecies by province at \url{http://sp2000.org.cn/statistics/statistics_map} for more details. 3 | #' @rdname get_province 4 | #' @name get_province 5 | #' @return Statistics on species or infraspecies by province. 6 | #' @details Visit the website \url{http://sp2000.org.cn/statistics/statistics_map} for more details. 7 | #' @importFrom jsonlite fromJSON 8 | #' @importFrom tibble tibble 9 | #' @author Liuyong Ding \email{ly_ding@126.com} 10 | #' @examples 11 | #' \dontrun{ 12 | #' get_province() 13 | #' 14 | #' } 15 | #' @export 16 | get_province <- function() { 17 | cat(sprintf("last Update: %s",Sys.Date()),sep = "\n") 18 | url <- 'http://sp2000.org.cn/statistics/show_in_map_all' 19 | map_all <- jsonlite::fromJSON(url) 20 | map_all <- map_all$data 21 | names(map_all) <- c("province","species_counts") 22 | map_all$date <- as.Date(Sys.time()) 23 | return(tibble(map_all)) 24 | } 25 | -------------------------------------------------------------------------------- /R/get_redlist_china.R: -------------------------------------------------------------------------------- 1 | #' @title Query Redlist of Chinese Biodiversity 2 | #' @description Query Redlist of China’s Biodiversity of Vertebrate, Higher Plants and Macrofungi. 3 | #' @rdname get_redlist_china 4 | #' @param query \code{string} The string to query for. 5 | #' @param option \code{character} There is one required parameter, which is either Chinese Names or Scientific Names. Give eithera Chinese Names or Scientific Names. If an Scientific Names is given, the Chinese Names parameter may not be used. Only exact matches found the name given will be returned. option=c("Chinese Names","Scientific Names"),,the default value is "Scientific Names". 6 | #' @param group \code{character} There is one required parameter, group=c("Amphibians","Birds","Inland Fishes","Mammals","Reptiles","Plants","Fungi"). 7 | #' @param viewDT \code{logic} TRUE or FALSE,the default value is FALSE. 8 | #' @importFrom utils download.file 9 | #' @importFrom DT datatable 10 | #' @importFrom DT formatStyle 11 | #' @importFrom DT styleEqual 12 | #' @importFrom DT %>% 13 | #' @importFrom tibble tibble 14 | #' @format assessment status: 15 | #' \describe{ 16 | #' \item{EX}{Extinct} 17 | #' \item{EW}{Extinct in the wild} 18 | #' \item{RE}{Regional Extinct} 19 | #' \item{CR}{Critically Endangered} 20 | #' \item{EN}{Endangered} 21 | #' \item{VU}{Vulnerable} 22 | #' \item{NT}{Near Threatened} 23 | #' \item{LC}{Least Concern} 24 | #' \item{DD}{Data Deficient} 25 | #' } 26 | #' @return object 27 | #' @details Visit the website \url{http://zoology.especies.cn/} for more details. 28 | #' @author Liuyong Ding \email{ly_ding@126.com} 29 | #' @author Ke Yang \email{ydyangke@163.com} 30 | #' @references \url{http://zoology.especies.cn/} 31 | #' @references \url{http://www.fungalinfo.net} 32 | #' @references \url{http://www.iplant.cn/rep/protlist} 33 | #' @references \url{http://www.mee.gov.cn} 34 | #' @examples 35 | #' \dontrun{ 36 | #' #query assessment status via Chinese Names or Scientific Names 37 | #' get_redlist_china(query = "Anguilla", option = "Scientific Names") 38 | #' get_redlist_china(query = "Anguilla nebulosa", option = "Scientific Names") 39 | #' 40 | #' #creates an HTML widget to display rectangular data 41 | #' get_redlist_china(group = "Inland Fishes", viewDT = TRUE) 42 | #' } 43 | #' @export 44 | get_redlist_china <- function(query = NULL,option = "Scientific Names",group = "Amphibians",viewDT = FALSE){ 45 | cat(sprintf("Download date: %s",Sys.Date()),sep = "\n") 46 | option <- match.arg(option, c("Chinese Names","Scientific Names")) 47 | group <- match.arg(group, c("Amphibians","Birds","Fungi","Inland Fishes","Mammals","Plants","Reptiles")) 48 | rds <- tempfile(pattern=".rds") 49 | download.file(update_dataset(),destfile = rds, quiet = TRUE) 50 | RedlistChina <- readRDS(rds) 51 | if (viewDT & group == group){ 52 | data = RedlistChina[which(RedlistChina$group == group),] 53 | print(table(data[,c(2,8,10)])) 54 | DT::datatable(data,filter = 'top',extensions = c("AutoFill",'Buttons',"ColReorder"),selection = "multiple", 55 | options = list( 56 | #language = list(url = '//cdn.datatables.net/plug-ins/1.10.11/i18n/Chinese.json'), 57 | searchHighlight = TRUE,scrollX = TRUE, 58 | autoFill = TRUE,pageLength = 5, autoWidth = TRUE,colReorder = TRUE, 59 | dom = 'Bfrtlip', 60 | buttons = c('copy', 'csv', 'excel') 61 | )) %>% formatStyle( 62 | 'status', 63 | color = styleEqual(c("EX","EW","RE","CR","EN","VU","NT","LC","DD"), rep("white",9)), 64 | backgroundColor = styleEqual(c("EX","EW","RE","CR","EN","VU","NT","LC","DD"), 65 | c("#010101","#525252","#919191","#D74D3B","#DE7F44","#FEF75E","#A3D2A5","#5B8D2A","#6CB4B7")) 66 | ) 67 | } else{ 68 | if (option == "Chinese Names"){ 69 | names(RedlistChina)[3] <- "species_c" 70 | i <- grep("Anguilla", RedlistChina$species_c) 71 | } 72 | if (option == "Scientific Names"){ 73 | names(RedlistChina)[4] <- "species" 74 | i <- grep(query, RedlistChina$species) 75 | } 76 | return(tibble::tibble(RedlistChina[i,])) 77 | } 78 | 79 | } 80 | 81 | update_dataset <- function() 'https://gitee.com/LiuyongDing/latest_literature/raw/master/RedlistChina_0.1.0.rds' 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /R/get_top20.R: -------------------------------------------------------------------------------- 1 | #' @title Download the top20 species for Catalogue of Life China checklist 2 | #' @description Download the most visited top20 species from \url{http://sp2000.org.cn}for more details. 3 | #' @rdname get_top20 4 | #' @name get_top20 5 | #' @return top20 species 6 | #' @author Liuyong Ding 7 | #' @details Visit the website \url{http://sp2000.org.cn} for more details. 8 | #' @importFrom jsonlite fromJSON 9 | #' @importFrom tibble tibble 10 | #' @examples 11 | #' \dontrun{ 12 | #' get_top20() 13 | #' } 14 | #' @export 15 | 16 | get_top20 <- function() { 17 | cat(sprintf("last Update: %s",Sys.Date()),sep = "\n") 18 | url <- 'http://sp2000.org.cn/record/speciesView/top20?_=1580870992724' 19 | top20 <- jsonlite::fromJSON(url) 20 | top20$url <- gsub("species/show_species_details/", "", top20$url) 21 | top20$target <- gsub("_top","top20",top20$target) 22 | names(top20) <- c("species","taxonIDs","rank") 23 | top20$date <- as.Date(Sys.time()) 24 | return(tibble(top20)) 25 | } 26 | -------------------------------------------------------------------------------- /R/list_df.R: -------------------------------------------------------------------------------- 1 | ##' @title Catalogue of Life list(s) convert data frame 2 | ##' @description Checklist lists convert data frame. 3 | ##' @rdname list_df 4 | ##' @name list_df 5 | ##' @param x \code{list} Results returned by the function \code{\link{search_checklist}} and \code{\link{get_col_global}}. 6 | ##' @param db \code{character} db = c("colchina","colglobal") 7 | ##' @importFrom tibble as_tibble 8 | ##' @importFrom rlist list.rbind 9 | ##' @importFrom purrr transpose 10 | ##' @format A data frame with 19 variables: 11 | ##' \describe{ 12 | ##' \item{ScientificName}{The scientific name (the accepted name) includes the name and the date of the name} 13 | ##' \item{Synonyms}{Synonyms name, Latin} 14 | ##' \item{ChineseName}{Chinese name} 15 | ##' \item{CommonNames}{Common name} 16 | ##' \item{Kingdom}{Kingdom at taxonTree} 17 | ##' \item{Phylum}{Phylum at taxonTree} 18 | ##' \item{Class}{Class at taxonTree} 19 | ##' \item{Order}{Order at taxonTree} 20 | ##' \item{Family}{Family at taxonTree} 21 | ##' \item{Genus}{Genus at taxonTree} 22 | ##' \item{Species}{Species at taxonTree} 23 | ##' \item{Infraspecies}{Infraspecies at taxonTree} 24 | ##' \item{Distribution}{Distribution of species or infraspecies} 25 | ##' \item{Name}{Full name of reviewer in English or Chinese} 26 | ##' \item{Email}{Organization of the reviewer in English or Chinese} 27 | ##' \item{Address}{Email address of the reviewer} 28 | ##' \item{Institution}{Address of the reviewer in English or Chinese} 29 | ##' \item{References}{References} 30 | ##' \item{Download}{Download date} 31 | ##' } 32 | ##' @author Liuyong Ding \email{ly_ding@126.com} 33 | ##' @source Visit the website \url{http://sp2000.org.cn/api/document} for more details 34 | ##' @examples 35 | ##' \dontrun{ 36 | ##' ##Set your key 37 | ##' set_search_key <- "your apiKey" 38 | ##' 39 | ##' ##Search family IDs via family name 40 | ##' familyid <- search_family_id(query = "Anguillidae") 41 | ##' 42 | ##' ##Search taxon IDs via familyID 43 | ##' taxonid <- search_taxon_id(query = familyid$Anguillidae$data$record_id, name = "familyID") 44 | ##' 45 | ##' #Download detailed lists via species or infraspecies ID 46 | ##' query <- taxonid[["3851c5311bed46c19529cb155d37aa9b"]][["data"]][["namecode"]] 47 | ##' x1 <- search_checklist(query = query) 48 | ##' str(x1) 49 | ##' x1 <- list_df(x1,db = "colchina") 50 | ##' 51 | ##' #Get Catalogue of Life Global checklist via species name 52 | ##' x2 <- get_col_global(query = c("Anguilla marmorata","Anguilla japonica", 53 | ##' "Anguilla bicolor","Anguilla nebulosa", 54 | ##' "Anguilla luzonensis"), 55 | ##' option = "name") 56 | ##' str(x2) 57 | ##' x2 <- list_df(x2,db = "colglobal") 58 | ##' } 59 | ##' @export 60 | 61 | list_df <- function(x,db = c("colchina","colglobal")){ 62 | db <- match.arg(db, c("colchina","colglobal")) 63 | switch( 64 | db, 65 | colchina = { 66 | data <- transpose(x) 67 | data$meta <- transpose(data$meta) 68 | } , 69 | colglobal = { 70 | data <- transpose(x) 71 | data$meta <- transpose(data$meta) 72 | } 73 | ) 74 | return(data) 75 | } 76 | 77 | 78 | -------------------------------------------------------------------------------- /R/open_url.R: -------------------------------------------------------------------------------- 1 | ##' @title Opening the Catalogue of Life China checklist web pages with query 2 | ##' @description Query with the accceptedName,scientificName,chineseName and commonName, returning the web pages that meets the criteria. 3 | ##' @rdname open_url 4 | ##' @name open_url 5 | ##' @param query \code{string} the accceptedName,scientificName,chineseName or commonName. 6 | ##' @param name \code{string} name = c("accceptedName","scientificName","chineseName","commonName"),the default value is "accceptedName". 7 | ##' @param language \code{string} currently only two languages are supported: Chinese and English,language=c("en","zh"), the default value is "en". 8 | ##' @author Liuyong Ding 9 | ##' @details Visit the website \url{http://sp2000.org.cn/pageservices/document} for more details. 10 | ##' @importFrom utils browseURL 11 | ##' @author Liuyong Ding \email{ly_ding@126.com} 12 | ##' @examples 13 | ##'\donttest{ 14 | ##' open_url(query = "Anguilla marmorata",name = "scientificName",language = 'en') 15 | ##' open_url(query = "Anguilla marmorata",name = "scientificName",language = 'zh') 16 | ##' } 17 | ##' @export 18 | open_url <- function(query = NULL,name = "accceptedName",language = 'en') { 19 | name <- match.arg(name, c("accceptedName","scientificName","chineseName","commonName")) 20 | language <- match.arg(language, c("en","zh")) 21 | url <- paste0('http://www.sp2000.org.cn/pageservices/species/', name,'/',query ,'/', language) 22 | browseURL(url) 23 | invisible(url) 24 | print(url) 25 | } 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /R/search_checklist.R: -------------------------------------------------------------------------------- 1 | ##' @title Search Catalogue of Life China checklist 2 | ##' @description Get checklist via species or infraspecies ID. 3 | ##' @rdname search_checklist 4 | ##' @name search_checklist 5 | ##' @param query \code{string} One or more queries, see \code{\link{search_family_id}} and \code{\link{search_taxon_id}} for more details. 6 | ##' @param mc.cores The number of cores to use, i.e. at most how many child processes will be run simultaneously. The option is initialized from environment variable MC_CORES if set. Must be at least one, and parallelization requires at least two cores,see \code{\link{mclapply}} for details. 7 | ##' @return Catalogue of Life China list(s) 8 | ##' @author Liuyong Ding \email{ly_ding@126.com} 9 | ##' @details Visit the website \url{http://sp2000.org.cn/api/document} for more details. 10 | ##' @importFrom pbmcapply pbmclapply 11 | ##' @importFrom jsonlite fromJSON 12 | ##' @importFrom rlist list.extract 13 | ##' @examples 14 | ##' \dontrun{ 15 | ##' ##Set your key 16 | ##' set_search_key("your apiKey",db = "sp2000") 17 | ##' 18 | ##' ##Search family IDs via family name 19 | ##' familyid <- search_family_id(query = "Anguillidae") 20 | ##' 21 | ##' ##Search taxon IDs via familyID 22 | ##' taxonid <- search_taxon_id(query = familyid$Anguillidae$data$record_id,name = "familyID") 23 | ##' 24 | ##' #Download detailed lists via species or infraspecies ID 25 | ##' query <- taxonid[["3851c5311bed46c19529cb155d37aa9b"]][["data"]][["namecode"]] 26 | ##' x <- search_checklist(query = query) 27 | ##' str(x) 28 | ##' } 29 | ##' @export 30 | 31 | search_checklist <- function(query = NULL, mc.cores = 2) { 32 | if (!is_search_key_set()){ 33 | cat("*******************************************************************************\n") 34 | cat("** You need to apply for the apiKey from http://sp2000.org.cn/api/document ** \n** to run all search_* functions, and then run set_search_key('your apiKey') **") 35 | cat("\n*******************************************************************************\n") 36 | }else{ 37 | x1 <- species(query[1]) 38 | switch(as.character(x1$code), 39 | "200" = { 40 | cat(sprintf("Request returned successfully!!!"), sep = "\n") 41 | cat(sprintf("Download date: %s", Sys.Date()), sep = "\n") 42 | }, 43 | "400" = {cat("Error request - the parameter query is not valid")}, 44 | "401" = {cat("Request return failed!!! \n The apikey is incorrect. Please reenter it!!! \n You need to apply for the apiKey from http://sp2000.org.cn/api/document \n Running set_search_key('your apiKey') to run all search_* functions" )}) 45 | if (.Platform$OS.type == "windows") { 46 | mc.cores = 1 47 | } 48 | if (as.character(x1$code) == 200){ 49 | data <- pbmclapply(query,mc.cores = mc.cores,function(queries){ 50 | x <- species(query = queries) 51 | x$data$download_date <- as.Date(Sys.time()) 52 | x$data$taxonTree <- as_tibble(x$data$taxonTree) 53 | x$data$Refs <- Refs(x$data$Refs) 54 | x <- list(meta = list(code=x$code,message=x$message), 55 | data = x$data) 56 | }) 57 | names(data) <- get_scientificName(query) 58 | cat(sprintf("Records - Found: %s",length(query)), sep = "\n") 59 | #cat(sprintf("Scientific name: %s", paste0(get_scientificName_count(query), collapse = ", ")),sep = "\n") 60 | return(data) 61 | } 62 | } 63 | } 64 | 65 | get_scientificName <- function(x){ 66 | sapply(1:length(x),function(i){ 67 | list.extract(transpose(lapply(x,species))[["data"]][[i]], "scientificName") 68 | }) 69 | } 70 | 71 | Refs <- function(x){ 72 | c(diag(as.matrix(x))) 73 | } 74 | 75 | species <- function(query = NULL) { 76 | if (is_search_key_set()){ 77 | url <- paste0('http://www.sp2000.org.cn/api/v2/getSpeciesByNameCode?apiKey=',Sys.getenv("sp2000_apiKey"),"&nameCode=",query) 78 | x <- fromJSON(url,flatten = TRUE) 79 | return(x) 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /R/search_family_id.R: -------------------------------------------------------------------------------- 1 | ##' @title Search family IDs 2 | ##' @description Search family IDs via family name, supports Latin and Chinese names. 3 | ##' @rdname search_family_id 4 | ##' @name search_family_id 5 | ##' @param query \code{character} One and more queries,support Family name, or part of family name, supports Latin and Chinese names. 6 | ##' @param start \code{integer} Record number to start at. If omitted, the results are returned from the first record (start=1). Use in combination with limit to page through results. Note that we do the paging internally for you, but you can manually set the start parameter. 7 | ##' @param limit \code{integer} Number of records to return, the default value is 20. 8 | ##' @param mc.cores The number of cores to use, i.e. at most how many child processes will be run simultaneously. The option is initialized from environment variable MC_CORES if set. Must be at least one, and parallelization requires at least two cores,see \code{\link{mclapply}} for details. 9 | ##' @return dataframe 10 | ##' @author Liuyong Ding \email{ly_ding@126.com} 11 | ##' @importFrom jsonlite fromJSON 12 | ##' @importFrom rlist list.rbind 13 | ##' @importFrom tibble as_tibble 14 | ##' @importFrom pbmcapply pbmclapply 15 | ##' @importFrom purrr transpose 16 | ##' @details Visit the website \url{http://sp2000.org.cn/api/document} for more details 17 | ##' @examples 18 | ##' \dontrun{ 19 | ##' ##Set your key 20 | ##' set_search_key("your apiKey",db = "sp2000") 21 | ##' 22 | ##' ##Search family IDs via family name 23 | ##' familyid <- search_family_id(query = "Anguillidae") 24 | ##' } 25 | ##' @export 26 | 27 | #********************API V2******************** 28 | search_family_id <- function(query = NULL, start = 1, limit = 20, mc.cores = 2) { 29 | if (!is_search_key_set()){ 30 | cat("*******************************************************************************\n") 31 | cat("** You need to apply for the apiKey from http://sp2000.org.cn/api/document ** \n** to run all search_* functions, and then run set_search_key('your apiKey') **") 32 | cat("\n*******************************************************************************\n") 33 | }else{ 34 | x1 <- familyID(query[1],page = start) 35 | switch(as.character(x1$code), 36 | "200" = { 37 | cat(sprintf("Request returned successfully!!!"), sep = "\n") 38 | cat(sprintf("Download date: %s", Sys.Date()), sep = "\n") 39 | }, 40 | "400" = {cat("Error request - the parameter query is not valid")}, 41 | "401" = {cat("Request return failed!!! \n The apikey is incorrect. Please reenter it!!! \n You need to apply for the apiKey from http://sp2000.org.cn/api/document \n Running set_search_key('your apiKey') to run all search_* functions" )}) 42 | if (.Platform$OS.type == "windows") { 43 | mc.cores = 1 44 | } 45 | if (as.character(x1$code) == 200){ 46 | data <- pbmclapply(query,mc.cores = mc.cores,function(queries){ 47 | x <- familyID(query = queries,page = start) 48 | x$data$familes$download_date <- as.Date(Sys.time()) 49 | x$data$familes <- as_tibble(x$data$familes) 50 | x <- list(meta = list(code=x$code,limit=x$data$limit,count=x$data$count,page=x$data$page,message=x$message), 51 | data = x$data$familes) 52 | }) 53 | names(data)<- query 54 | # cat(sprintf("Records - Found: %s, Returned: %s",found(data),returned(data)), sep = "\n") 55 | # cat(sprintf("Queries: %s", paste0(queries(query,data), collapse = ", ")),sep = "\n") 56 | return(data) 57 | } 58 | } 59 | 60 | } 61 | 62 | familyID <- function(query = NULL,page,...) { 63 | query <- as.character(query) 64 | if (is_search_key_set()){ 65 | url <- paste0("http://www.sp2000.org.cn/api/v2/getFamiliesByFamilyName?apiKey=",Sys.getenv('sp2000_apiKey'),"&familyName=", query,'&',"page=",page) 66 | x <- fromJSON(url,flatten = TRUE) 67 | } 68 | } 69 | 70 | # queries <- function(query,x){ 71 | # if (length(query) > 3){ 72 | # paste0(query[1:3],"(",sapply(1:3,function(i)dim(x[[query[3]]][["data"]])[1]),")") 73 | # }else{ 74 | # paste0(query,"(",sapply(1:length(query),function(i)dim(x[[query[i]]][["data"]])[1]),")") 75 | # } 76 | # } 77 | # 78 | # found <- function(x){ 79 | # sum(unlist(list.extract(transpose(transpose(x)[["meta"]]), "count"))) 80 | # } 81 | # 82 | # returned <- function(x){ 83 | # sum(unlist(list.extract(transpose(transpose(x)[["meta"]]), "page"))) 84 | # } 85 | 86 | -------------------------------------------------------------------------------- /R/search_taxon_id.R: -------------------------------------------------------------------------------- 1 | ##' @title Search taxon IDs 2 | ##' @description Search taxon IDs via familyID ,scientificName and commonName. 3 | ##' @rdname search_taxon_id 4 | ##' @name search_taxon_id 5 | ##' @param query \code{string} familyID ,scientificName or commonName. 6 | ##' @param name \code{character} name = c("familyID","scientificName","commonName"),the default value is "scientificName". 7 | ##' @param start \code{intenger} Record number to start at. If omitted, the results are returned from the first record (start=1). Use in combination with limit to page through results. Note that we do the paging internally for you, but you can manually set the start parameter. 8 | ##' @param limit \code{intenger} Number of records to return. This is passed across all sources,when you first query, set the limit to something smallish so that you can get a result quickly, then do more as needed. 9 | ##' @param mc.cores The number of cores to use, i.e. at most how many child processes will be run simultaneously. The option is initialized from environment variable MC_CORES if set. Must be at least one, and parallelization requires at least two cores,see \code{\link{mclapply}} for details. 10 | ##' @importFrom jsonlite fromJSON 11 | ##' @importFrom rlist list.rbind 12 | ##' @importFrom rlist list.filter 13 | ##' @importFrom tibble tibble 14 | ##' @importFrom utils data 15 | ##' @importFrom pbmcapply pbmclapply 16 | ##' @format query: 17 | ##' \describe{ 18 | ##' \item{taxonIDs}{an array of species' ids} 19 | ##' \item{familyID}{family ID, unique value} 20 | ##' \item{scientificName}{the scientific name, or part of the scientific name, supports Latin names and Chinese} 21 | ##' \item{commonName}{common name, or part of common name} 22 | ##' } 23 | ##' @return dataframe 24 | ##' @author Liuyong Ding \email{ly_ding@126.com} 25 | ##' @details Visit the website \url{http://sp2000.org.cn/api/document} for more details 26 | ##' @examples 27 | ##' \dontrun{ 28 | ##' ##Set your key 29 | ##' set_search_key("your apiKey",db = "sp2000") 30 | ##' 31 | ##' ##Search family IDs via family name 32 | ##' familyid <- search_family_id(query = "Anguillidae") 33 | ##' 34 | ##' ##Search taxon IDs via familyID 35 | ##' taxonid <- search_taxon_id(query = familyid$Anguillidae$data$record_id,name = "familyID") 36 | ##' 37 | ##' } 38 | ##' @export 39 | search_taxon_id <- function(query = NULL, name = "scientificName", start = 1, limit = 20, mc.cores = 2){ 40 | if (!is_search_key_set()){ 41 | cat("*******************************************************************************\n") 42 | cat("** You need to apply for the apiKey from http://sp2000.org.cn/api/document ** \n** to run all search_* functions, and then run set_search_key('your apiKey') **") 43 | cat("\n*******************************************************************************\n") 44 | }else{ 45 | x1 <- taxonID(query[1],name = name, page = start) 46 | switch(as.character(x1$code), 47 | "200" = { 48 | cat(sprintf("Request returned successfully!!!"), sep = "\n") 49 | cat(sprintf("Download date: %s", Sys.Date()), sep = "\n") 50 | }, 51 | "400" = {cat("Error request - the parameter query is not valid")}, 52 | "401" = {cat("Request return failed!!! \n The apikey is incorrect. Please reenter it!!! \n You need to apply for the apiKey from http://sp2000.org.cn/api/document \n Running set_search_key('your apiKey') to run all search_* functions" )}) 53 | if (.Platform$OS.type == "windows") {mc.cores = 1} 54 | if (as.character(x1$code) == 200){ 55 | #i <- 1:length(query) 56 | #limit(query=query,name=name)[[1]][["meta"]][["count"]] 57 | if (limit > 20){ 58 | x <- pbmclapply(query,mc.cores = mc.cores,function(queries){ 59 | x <- limits_taxonID(query = queries,name = name,limit = limit) 60 | }) 61 | query <- gsub("+"," ",query) 62 | names(x) <- query 63 | cat(sprintf("Research type: %s",name), sep = "\n") 64 | # cat(sprintf("Records - Found: %s, Returned: %s",found1(query,data),returned1(query,data)), sep = "\n") 65 | # cat(sprintf("Queries: %s", paste0(queries1(query,data), collapse = ", ")),sep = "\n") 66 | 67 | }else{ 68 | x <- pbmclapply(query,mc.cores = mc.cores,function(queries){ 69 | x <- taxonID(query = queries,name = name, page = start) 70 | x$data$species$download_date <- as.Date(Sys.time()) 71 | x <- list(meta = list(code=x$code,limit=x$data$limit,count=x$data$count,page=x$data$page,message=x$message), 72 | data = x$data$species) 73 | }) 74 | names(x) <- query 75 | cat(sprintf("Research type: %s",name), sep = "\n") 76 | # cat(sprintf("Records - Found: %s, Returned: %s",found1(query,data),returned1(query,data)), sep = "\n") 77 | # cat(sprintf("Queries: %s", paste0(queries1(query,data), collapse = ", ")),sep = "\n") 78 | } 79 | return(x) 80 | } 81 | } 82 | } 83 | 84 | taxonID <- function(query = NULL, name, page) { 85 | if (is_search_key_set()){ 86 | switch(name, 87 | familyID = { 88 | url <- paste0(web_v2(), "getSpeciesByFamilyId?apiKey=",Sys.getenv("sp2000_apiKey"),"&familyId=",query, "&page=", page) 89 | x <- fromJSON(url) 90 | }, 91 | scientificName = { 92 | query <- gsub(" ","+",query) 93 | url <- paste0(web_v2(), "getSpeciesByScientificName?apiKey=",Sys.getenv("sp2000_apiKey"),"&scientificName=",query, "&page=", page) 94 | x <- fromJSON(url) 95 | }, 96 | commonName = { 97 | url <- paste0(web_v2(), "getSpeciesByCommonName?apiKey=",Sys.getenv("sp2000_apiKey"),"&commonName=",query, "&page=", page) 98 | x <- fromJSON(url) 99 | } 100 | ) 101 | } 102 | } 103 | 104 | web_v2 <- function()"http://www.sp2000.org.cn/api/v2/" 105 | 106 | 107 | queries1 <- function(query,x){ 108 | if (length(query) > 3){ 109 | paste0(query[1:3],"(",sapply(1:3,function(i)dim(x[[query[i]]][["data"]][["accepted_name_info"]])[1]),")") 110 | }else{ 111 | paste0(query,"(",sapply(1:length(query),function(i)dim(x[[query[i]]][["data"]][["accepted_name_info"]])[1]),")") 112 | } 113 | } 114 | 115 | limits_taxonID <- function(query,name,limit){ 116 | #page <- ceiling(lapply(query,taxonID,name = name,page=1)[[1]][["data"]][["count"]]/20) 117 | page <- ceiling(limit/20) 118 | ss <- lapply(1:page,function(page){ 119 | x <- lapplytaxonID(query = query,name = name, page = page) 120 | }) 121 | ss <- rlist::list.filter(ss,dim(data)[1] > 0) 122 | ss <- purrr::transpose(ss) 123 | ss$meta <- rlist::list.stack(ss$meta) 124 | ss$data <- purrr::transpose(ss$data) 125 | ss$data$name_status <- rlist::list.ungroup(ss$data$name_status) 126 | ss$data$name_code <- rlist::list.ungroup(ss$data$name_code) 127 | ss$data$scientific_name <- rlist::list.ungroup(ss$data$scientific_name) 128 | ss$data$download_date <- Sys.Date() 129 | ss$data$accepted_name_info <- purrr::transpose(ss$data$accepted_name_info) 130 | ss$data$accepted_name_info$searchCodeStatus <- rlist::list.ungroup(ss$data$accepted_name_info$searchCodeStatus) 131 | ss[["data"]][["accepted_name_info"]][["namecode"]] <- rlist::list.ungroup(ss[["data"]][["accepted_name_info"]][["namecode"]]) 132 | ss[["data"]][["accepted_name_info"]][["scientificName"]] <- rlist::list.ungroup(ss[["data"]][["accepted_name_info"]][["scientificName"]]) 133 | ss[["data"]][["accepted_name_info"]][["author"]] <- rlist::list.ungroup(ss[["data"]][["accepted_name_info"]][["author"]]) 134 | ss[["data"]][["accepted_name_info"]][["Distribution"]] <- rlist::list.ungroup(ss[["data"]][["accepted_name_info"]][["Distribution"]]) 135 | ss[["data"]][["accepted_name_info"]][["chineseName"]] <- rlist::list.ungroup(ss[["data"]][["accepted_name_info"]][["chineseName"]]) 136 | ss[["data"]][["accepted_name_info"]][["searchCode"]] <- rlist::list.ungroup(ss[["data"]][["accepted_name_info"]][["searchCode"]]) 137 | ss$data$accepted_name_info$CommonNames <- rlist::list.ungroup(ss$data$accepted_name_info$CommonNames) 138 | ss$data$accepted_name_info$taxonTree <- purrr::transpose(ss$data$accepted_name_info$taxonTree) 139 | ss$data$accepted_name_info$taxonTree$phylum <- rlist::list.ungroup(ss$data$accepted_name_info$taxonTree$phylum) 140 | ss$data$accepted_name_info$taxonTree$genus <- rlist::list.ungroup(ss$data$accepted_name_info$taxonTree$genus) 141 | ss$data$accepted_name_info$taxonTree$species <- rlist::list.ungroup(ss$data$accepted_name_info$taxonTree$species) 142 | ss$data$accepted_name_info$taxonTree$infraspecies <- rlist::list.ungroup(ss$data$accepted_name_info$taxonTree$infraspecies) 143 | ss$data$accepted_name_info$taxonTree$family <- rlist::list.ungroup(ss$data$accepted_name_info$taxonTree$family) 144 | ss$data$accepted_name_info$taxonTree$kingdom <- rlist::list.ungroup(ss$data$accepted_name_info$taxonTree$kingdom) 145 | ss$data$accepted_name_info$taxonTree$class <- rlist::list.ungroup(ss$data$accepted_name_info$taxonTree$class) 146 | ss$data$accepted_name_info$taxonTree$order <- rlist::list.ungroup(ss$data$accepted_name_info$taxonTree$order) 147 | ss$data$accepted_name_info$taxonTree <- as_tibble(ss$data$accepted_name_info$taxonTree) 148 | ss$data$accepted_name_info$Refs <- rlist::list.ungroup(ss$data$accepted_name_info$Refs) 149 | ss$data$accepted_name_info$SpecialistInfo <- rlist::list.ungroup(ss$data$accepted_name_info$SpecialistInfo) 150 | ss$data$accepted_name_info$SpecialistInfo <- purrr::transpose(ss$data$accepted_name_info$SpecialistInfo) 151 | ss[["data"]][["accepted_name_info"]][["SpecialistInfo"]][["E-Mail"]] <- rlist::list.ungroup(ss[["data"]][["accepted_name_info"]][["SpecialistInfo"]][["E-Mail"]]) 152 | ss$data$accepted_name_info$SpecialistInfo$Address <- rlist::list.ungroup(ss$data$accepted_name_info$SpecialistInfo$Address) 153 | ss$data$accepted_name_info$SpecialistInfo$name <- rlist::list.ungroup(ss$data$accepted_name_info$SpecialistInfo$name) 154 | ss$data$accepted_name_info$SpecialistInfo$Institution <- rlist::list.ungroup(ss$data$accepted_name_info$SpecialistInfo$Institution) 155 | ss$data$accepted_name_info$SpecialistInfo <- as_tibble(ss$data$accepted_name_info$SpecialistInfo) 156 | ss$data$accepted_name_info$Synonyms <- rlist::list.ungroup(ss$data$accepted_name_info$Synonyms) 157 | ss$data$accepted_name_info <- as_tibble(ss$data$accepted_name_info) 158 | return(ss) 159 | } 160 | 161 | 162 | lapplytaxonID <- function(query = NULL, name, page){ 163 | x <- lapply(query,function(i){ 164 | taxonID(i,name, page) 165 | }) 166 | names(x) <- query 167 | x[[query]][["data"]][["species"]][["download_date"]] <- as.Date(Sys.time()) 168 | x <- list(meta = list(code=x[[query]][["code"]], 169 | limit=x[[query]][["data"]][["limit"]], 170 | count=x[[query]][["data"]][["count"]], 171 | page=x[[query]][["data"]][["page"]], 172 | message=x[[query]][["message"]]), 173 | data = x[[query]][["data"]][["species"]]) 174 | } 175 | -------------------------------------------------------------------------------- /R/zoology_dbase_name.R: -------------------------------------------------------------------------------- 1 | #' @title Query details of species in China Animal Scientific Database 2 | #' @description Query the database name and return a collection of names for all databases. 3 | #' @rdname zoology_dbase_name 4 | #' @importFrom jsonlite fromJSON 5 | #' @format China Animal Scientific Database 6 | #' \describe{ 7 | #' \item{1}{Chinese zoology database} 8 | #' \item{2}{China Animal Map Database} 9 | #' \item{3}{China Economic Animal Database} 10 | #' \item{4}{Chinese Bird Database} 11 | #' \item{5}{Chinese Mammal Database} 12 | #' \item{6}{China Butterfly Database} 13 | #' \item{7}{Chinese Bee Database} 14 | #' \item{8}{China Inland Water Fish Database} 15 | #' \item{9}{Chinese Amphibian Database} 16 | #' \item{10}{Chinese Reptile database} 17 | #' \item{...}{allow additional more databases to be used} 18 | #' } 19 | #' @return A collection of names for all China animal scientific databases 20 | #' @details Visit the website \url{http://zoology.especies.cn} for more details. 21 | #' @author Liuyong Ding \email{ly_ding@126.com} 22 | #' @author Ke Yang \email{ydyangke@163.com} 23 | #' @references \url{http://zoology.especies.cn} 24 | #' @examples 25 | #' \dontrun{ 26 | #' ##Set your key 27 | #' set_search_key("your apiKey",db = "zoology") 28 | #' 29 | #' #Query China Animal Scientific Database lists 30 | #' zoology_dbase_name() 31 | #' } 32 | #' @export 33 | zoology_dbase_name <- function() { 34 | if (!is_query_key_set()){ 35 | cat("*******************************************************************************\n") 36 | cat("** You need to apply for the apiKey from http://zoology.especies.cn/database/api ** \n** to run all zoology_* functions, and then run set_search_key('your apiKey', db = 'zoology') **") 37 | cat("\n*******************************************************************************\n") 38 | }else{ 39 | url <- paste0('http://zoology.especies.cn/api/v1/dbaseName?apiKey=',Sys.getenv('zoology_apiKey')) 40 | x <- jsonlite::fromJSON(url) 41 | switch(as.character(x$code), 42 | "200" = { 43 | cat(sprintf("Request returned successfully!!!"), sep = "\n") 44 | cat(sprintf("last Update: %s",Sys.Date()),sep = "\n") 45 | }, 46 | "1100" = {cat("Error request - No database information available")}, 47 | "402" = {cat("Please note that API key are allowed 2000 requests per 24 hour period!!! \n To request an increase in the daily API request limit, you can visit at http://zoology.especies.cn/user/info")}, 48 | "401" = {cat("Request return failed!!! \n The apikey is incorrect. Please reenter it!!! \n You need to apply for the apiKey from http://zoology.especies.cn/database/api \n Running set_search_key('your apiKey') to run all zoology_* functions" )}) 49 | if (as.character(x$code) == 200){ 50 | cat(sprintf("China Animal Scientific Database - Found: %s",x$data$sum), sep = "\n") 51 | cat(sprintf("%01d:%s",1:length(x$data$dbaseName),x$data$dbaseName), sep = "\n") 52 | #return(x[["data"]][["dbaseName"]]) 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /R/zoology_description.R: -------------------------------------------------------------------------------- 1 | #' @title Query details of species in China Animal Scientific Database 2 | #' @description Query the description information based on the species name, database name, and description type. 3 | #' @rdname zoology_description 4 | #' @param query \code{string} The string to query for scientific names. 5 | #' @param dbname \code{integer} There is one required parameter, a single numeric that indicates which China animal scientific database to use. Details in \code{\link{zoology_dbase_name}} for the list of available databases. 6 | #' @param destype \code{integer} There is one required parameter, a single numeric that indicates which description type information to use. Details in \code{\link{zoology_description}} for the list of available description type information based on the species name and database name. 7 | #' @return details of species in China Animal Scientific Database 8 | #' @author Liuyong Ding \email{ly_ding@126.com} 9 | #' @details Visit the website \url{http://zoology.especies.cn} for more details. 10 | #' @importFrom jsonlite fromJSON 11 | #' @importFrom urltools url_encode 12 | #' @examples 13 | #' \dontrun{ 14 | #' ##Set your key 15 | #' set_search_key("your apiKey",db = "zoology") 16 | #' 17 | #' ##Query details of species in Chinese Bird Database 18 | #' zoology_description(query = "Aix galericulata",dbname = 4,destype = 209) 19 | #' } 20 | #' @export 21 | 22 | zoology_description <- function(query, dbname, destype) { 23 | if (!is_query_key_set()){ 24 | cat("*******************************************************************************\n") 25 | cat("** You need to apply for the apiKey from http://zoology.especies.cn/database/api ** \n** to run all zoology_* functions, and then run set_search_key('your apiKey', db = 'zoology') **") 26 | cat("\n*******************************************************************************\n") 27 | }else{ 28 | query <- urltools::url_encode(query) 29 | dbase_name <- jsonlite::fromJSON(paste0('http://zoology.especies.cn/api/v1/dbaseName?apiKey=',Sys.getenv('zoology_apiKey'))) 30 | dbname <- dbase_name[["data"]][["dbaseName"]][dbname] 31 | if (!as.character(dbase_name$code) %in% "402"){ 32 | dbname <- urltools::url_encode(dbname) 33 | } 34 | url <- paste0('http://zoology.especies.cn/api/v1/description?scientificName=',query,'&dbaseName=',dbname,'&descriptionType=',destype, '&apiKey=',Sys.getenv('zoology_apiKey')) 35 | x <- jsonlite::fromJSON(url,flatten = TRUE) 36 | switch(as.character(x$code), 37 | "200" = { 38 | cat(sprintf("Request returned successfully!!!"), sep = "\n") 39 | cat(sprintf("last Update: %s",Sys.Date()),sep = "\n")}, 40 | "1500" = {cat("Error request - There is no such species")}, 41 | "1502" = {cat("Error request - No database information available")}, 42 | "402" = {cat("Please note that API key are allowed 2000 requests per 24 hour period!!! \n To request an increase in the daily API request limit, you can visit at http://zoology.especies.cn/user/info")}, 43 | "401" = {cat("Request return failed!!! \n The apikey is incorrect. Please reenter it!!! \n You need to apply for the apiKey from http://zoology.especies.cn/database/api \n Running set_search_key('your apiKey') to run all zoology_* functions" )}) 44 | if (as.character(x$code) == 200){ 45 | #cat(sprintf("China Animal Scientific Database - Found: %s",x$data$sum), sep = "\n") 46 | #cat(sprintf("[%s]%s",1:length(x$data$dbaseName),x$data$desType), sep = "\n") 47 | result <- x[["data"]] 48 | results <- list(meta = list(scientificName = result$scientificName), data = result$DescriptionInfo) 49 | results <- list(results) 50 | names(results) <- urltools::url_decode(query) 51 | return(results) 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /R/zoology_description_type.R: -------------------------------------------------------------------------------- 1 | #' @title Query details of species in China Animal Scientific Database 2 | #' @description Query the description type information based on the species name and database name. 3 | #' @rdname zoology_description 4 | #' @param query \code{string} The string to query for scientific names. 5 | #' @param dbname \code{integer} There is one required parameter, a single numeric that indicates which China animal scientific database to use. Details in \code{\link{zoology_dbase_name}} for the list of available databases. 6 | #' @return description type information 7 | #' @author Liuyong Ding \email{ly_ding@126.com} 8 | #' @details Visit the website \url{http://zoology.especies.cn} for more details. 9 | #' @importFrom jsonlite fromJSON 10 | #' @importFrom urltools url_encode 11 | #' @examples 12 | #' \dontrun{ 13 | #' ##Set your key 14 | #' set_search_key("your apiKey",db = "zoology") 15 | #' 16 | #' ##Query description type information of Chinese Bird Database 17 | #' zoology_description_type(query = "Aix galericulata",dbname = 4) 18 | #' } 19 | #' @export 20 | 21 | zoology_description_type <- function(query, dbname) { 22 | if (!is_query_key_set()){ 23 | cat("*******************************************************************************\n") 24 | cat("** You need to apply for the apiKey from http://zoology.especies.cn/database/api ** \n** to run all zoology_* functions, and then run set_search_key('your apiKey', db = 'zoology') **") 25 | cat("\n*******************************************************************************\n") 26 | }else{ 27 | query <- urltools::url_encode(query) 28 | dbase_name <- jsonlite::fromJSON(paste0('http://zoology.especies.cn/api/v1/dbaseName?apiKey=',Sys.getenv('zoology_apiKey'))) 29 | dbname <- dbase_name[["data"]][["dbaseName"]][dbname] 30 | dbname <- urltools::url_encode(dbname) 31 | url <- paste0('http://zoology.especies.cn/api/v1/descriptionType?scientificName=',query,'&dbaseName=',dbname, '&apiKey=',Sys.getenv('zoology_apiKey')) 32 | x <- jsonlite::fromJSON(url,flatten = TRUE) 33 | switch(as.character(x$code), 34 | "200" = { 35 | cat(sprintf("Request returned successfully!!!"), sep = "\n") 36 | cat(sprintf("last Update: %s",Sys.Date()),sep = "\n")}, 37 | "1100" = {cat("Error request - No database information available")}, 38 | "1500" = {cat("Error request - No result for this species your query")}, 39 | "402" = {cat("Please note that API key are allowed 2000 requests per 24 hour period!!! \n To request an increase in the daily API request limit, you can visit at http://zoology.especies.cn/user/info")}, 40 | "401" = {cat("Request return failed!!! \n The apikey is incorrect. Please reenter it!!! \n You need to apply for the apiKey from http://zoology.especies.cn/database/api \n Running set_search_key('your apiKey') to run all zoology_* functions" )}) 41 | if (as.character(x$code) == 200){ 42 | #cat(sprintf("China Animal Scientific Database - Found: %s",x$data$sum), sep = "\n") 43 | #cat(sprintf("[%s]%s",1:length(x$data$dbaseName),x$data$desType), sep = "\n") 44 | s <- x[["data"]][["desType"]] 45 | type <- data.frame(id = names(s), type = diag(as.matrix(s))) 46 | return(type) 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ## SP2000 5 | 6 | [![CRAN Version](http://www.r-pkg.org/badges/version/SP2000)](https://cran.r-project.org/package=SP2000) 7 | [![codecov](https://badge.fury.io/gh/Otoliths%2FSP2000.svg)](https://badge.fury.io/for/gh/Otoliths/SP2000) 8 | [![R-CMD-check](https://github.com/Otoliths/SP2000/workflows/R-CMD-check/badge.svg)](https://github.com/Otoliths/SP2000/actions?query=workflow%3AR-CMD-check) 9 | [![Rdoc](https://www.rdocumentation.org/badges/version/SP2000)](https://www.rdocumentation.org/packages/SP2000) 10 | 11 | 12 | [![](https://cranlogs.r-pkg.org/badges/grand-total/SP2000?color=orange)](https://cran.r-project.org/package=SP2000) 13 | [![](https://cranlogs.r-pkg.org/badges/SP2000?color=orange)](https://cranlogs.r-pkg.org/downloads/total/last-month/SP2000) 14 | [![](https://cranlogs.r-pkg.org/badges/last-week/SP2000?color=orange)](https://cranlogs.r-pkg.org/downloads/total/last-week/SP2000) 15 | 16 | 17 | This [**SP2000**](https://cran.r-project.org/package=SP2000) package programatically download catalogue of the Chinese known species of animals, plants, fungi and micro-organisms. There are __122280__ species & infraspecific taxa in [2020 Annual Checklist of Catalogue of Life China](http://sp2000.org.cn/2019), including __110231__ species and __12049__ infraspecific taxa.This package also supports access to catalogue of life global , China animal scientific database and catalogue of life Taiwan . 18 | 19 | 20 | ## Citation 21 | [![](https://img.shields.io/badge/DOI-10.17520/biods.2020235-blue.svg)](https://www.biodiversity-science.net/CN/10.17520/biods.2020235) 22 | 23 | Liuyong Ding, Hao Li, Juan Tao, Jinlong Zhang, Minrui Huang, Ke Yang, Jun Wang, Chengzhi Ding, Daming He. SP2000: An open-sourced R package for querying the Catalogue of Life [J]. Biodiv Sci, 2021, 29(1): 118-122. 24 | 25 | 26 | 27 | 28 | 29 | ## Overview 30 | 31 | [![](https://img.shields.io/badge/Contact%20us%20on-WeChat-blue.svg)](https://gitee.com/LiuyongDing/latest_literature/raw/master/bad.png) 32 | [![](https://img.shields.io/badge/Follow%20me%20on-WeChat-green.svg)](https://gitee.com/LiuyongDing/latest_literature/raw/master/img.png) 33 | 34 | [**Species 2000**](http://sp2000.org.cn) China node is a regional node of the international species 2000 project, proposed by the international species 2000 Secretariat in October 20, 2006, was officially launched in February 7, 2006. Chinese Academy of Sciences, biological diversity Committee (BC-CAS), together with its partners, to support and manage the construction of species 2000 China node. The main task of the species 2000 China node, according to the species 2000 standard data format, the classification information of the distribution in China of all species to finish and check, the establishment and maintenance of Chinese biological species list, to provide free services to users around the world. 35 | 36 | 37 | ### Libraries 38 | 39 | You might be able to avoid reading all this documentation if you instead use one of the several excellent libraries that have been written for the Catalogue of Life API. For example: 40 | 41 | - [SP2000](https://github.com/Otoliths/SP2000) (R, developed by Liuyong Ding) 42 | - [general](https://github.com/CatalogueOfLife/general) (R,developed by CoL Global Team) 43 | - [colpluz](https://github.com/ropensci/colpluz) (R,developed by ropensci) 44 | - [SP2000](https://github.com/ynulihao/SP2000) (Python,developed by Hao Li) 45 | - [coldpy](https://github.com/gdower/coldpy) (Python) 46 | - [coldp](https://github.com/CatalogueOfLife/coldp) (SQL) 47 | - [data](https://github.com/CatalogueOfLife/data) (SQL) 48 | - [backend](https://github.com/CatalogueOfLife/backend) (Java) 49 | - [clearinghouse-ui](https://github.com/CatalogueOfLife/clearinghouse-ui) (Java) 50 | - [portal](https://github.com/CatalogueOfLife/portal) (Java) 51 | - [taicol-db-docker](https://github.com/TaiBIF/taicol-db-docker) (Shell) 52 | - [zbank](https://github.com/ropensci/zbank) (R,developed by ropensci) 53 | 54 | 55 | ## Installation 56 | 57 | ### Current official release: 58 | ```r 59 | install.packages("SP2000") 60 | ``` 61 | 62 | ### Current beta / GitHub release: 63 | 64 | Installation using R package 65 | [**remotes**](https://cran.r-project.org/package=remotes): 66 | ```r 67 | if (!requireNamespace("remotes", quietly = TRUE)) 68 | install.packages("remotes") 69 | 70 | remotes::install_github("Otoliths/SP2000") 71 | 72 | #or 73 | remotes::install_git("git://github.com/Otoliths/SP2000.git") 74 | 75 | #or 76 | remotes::install_gitlab("Otoliths/SP2000") 77 | 78 | ``` 79 | 80 | ## Usage 81 | 82 | ##### Note: You need to apply for the [*apiKey*](http://sp2000.org.cn/api/document) to run search_* functions of this package. 83 | 84 | Load the **SP2000** package 85 | ```r 86 | library(SP2000) 87 | ``` 88 | ###### Search family IDs via family name 89 | ```r 90 | set_search_key("your apiKey",db = "sp2000") 91 | 92 | familyid <- search_family_id(query = "Anguillidae") 93 | str(familyid) 94 | ``` 95 | ```r 96 | List of 1 97 | $ Anguillidae:List of 2 98 | ..$ meta:List of 5 99 | .. ..$ code : int 200 100 | .. ..$ limit : int 20 101 | .. ..$ count : int 1 102 | .. ..$ page : int 1 103 | .. ..$ message: chr "success" 104 | ..$ data: tibble [1 × 14] (S3: tbl_df/tbl/data.frame) 105 | .. ..$ family_c : chr "鳗鲡科" 106 | .. ..$ phylum_c : chr "脊索动物门" 107 | .. ..$ superfamily : logi NA 108 | .. ..$ kingdom : chr "Animalia" 109 | .. ..$ record_id : chr "3851c5311bed46c19529cb155d37aa9b" 110 | .. ..$ phylum : chr "Chordata" 111 | .. ..$ kingdom_c : chr "动物界" 112 | .. ..$ family : chr "Anguillidae" 113 | .. ..$ class : chr "Actinopterygii" 114 | .. ..$ class_c : chr "辐鳍鱼纲" 115 | .. ..$ order_c : chr "鳗鲡目" 116 | .. ..$ order : chr "Anguilliformes" 117 | .. ..$ superfamily_c: logi NA 118 | .. ..$ download_date: Date[1:1], format: "2020-08-04" 119 | ``` 120 | ###### Search taxon IDs via familyID 121 | ```r 122 | taxonid1 <- search_taxon_id(query = familyid$Anguillidae$data$record_id,name = "familyID") 123 | str(taxonid1[["3851c5311bed46c19529cb155d37aa9b"]][["meta"]]) 124 | ``` 125 | ```r 126 | List of 5 127 | $ code : int 200 128 | $ limit : int 20 129 | $ count : int 5 130 | $ page : int 1 131 | $ message: chr "success" 132 | ``` 133 | ###### Search taxon IDs via scientificName 134 | ```r 135 | queries <- c("Anguilla marmorata","Anguilla japonica", 136 | "Anguilla bicolor","Anguilla nebulosa", 137 | "Anguilla luzonensis") 138 | taxonid2 <- search_taxon_id(query = queries,name = "scientificName") 139 | str(taxonid2[["Anguilla marmorata"]]) 140 | ``` 141 | ```r 142 | List of 2 143 | $ meta:List of 5 144 | ..$ code : int 200 145 | ..$ limit : int 20 146 | ..$ count : int 1 147 | ..$ page : int 1 148 | ..$ message: chr "success" 149 | $ data:'data.frame': 1 obs. of 5 variables: 150 | ..$ accepted_name_info:'data.frame': 1 obs. of 11 variables: 151 | .. ..$ searchCodeStatus: chr "accepted name" 152 | .. ..$ namecode : chr "e192fbc15df24049bcd0fd01d307affa" 153 | .. ..$ scientificName : chr "Anguilla marmorata" 154 | .. ..$ author : chr "Quoy et Gaimard,1824" 155 | .. ..$ Refs :List of 1 156 | .. .. ..$ :'data.frame': 2 obs. of 2 variables: 157 | .. .. .. ..$ [1]: chr [1:2] "" NA 158 | .. .. .. ..$ [2]: chr [1:2] NA "" 159 | .. ..$ Distribution : chr "Zhejiang(浙江)" 160 | .. ..$ taxonTree :'data.frame': 1 obs. of 8 variables: 161 | .. .. ..$ phylum : chr "Chordata" 162 | .. .. ..$ genus : chr "Anguilla" 163 | .. .. ..$ species : chr "marmorata" 164 | .. .. ..$ infraspecies: chr "" 165 | .. .. ..$ family : chr "Anguillidae" 166 | .. .. ..$ kingdom : chr "Animalia" 167 | .. .. ..$ class : chr "Actinopterygii" 168 | .. .. ..$ order : chr "Anguilliformes" 169 | .. ..$ chineseName : chr "花鳗鲡" 170 | .. ..$ searchCode : chr "e192fbc15df24049bcd0fd01d307affa" 171 | .. ..$ CommonNames :List of 1 172 | .. .. ..$ : list() 173 | .. ..$ SpecialistInfo :List of 1 174 | .. .. ..$ :'data.frame': 3 obs. of 4 variables: 175 | .. .. .. ..$ E-Mail : chr [1:3] "zhangcg@ioz.ac.cn" "zoskt@gate.sinica.edu.tw" "" 176 | .. .. .. ..$ Address : chr [1:3] "1 Beichen West Road, Chaoyang District, Beijing 100101, P.R.China(北京市朝阳区北辰西路1号院5号 中国科学院动物研究所)" "()" "No.999, Huchenghuan Rd , Nanhui New City, Shanghai, P.R. China(上海市浦东新区沪城环路999号)" 177 | .. .. .. ..$ name : chr [1:3] "Zhang Chunguang(张春光)" "Shao, Kwang-Tsao(邵广昭)" "Wu Hanlin(伍汉霖)" 178 | .. .. .. ..$ Institution: chr [1:3] "Institute of Zoology, Chinese Academy of Sciences(中国科学院动物研究所)" "(中央研究院生物多樣性研究中心)" "College of Life Science & Technology, Shanghai Ocean University(上海海洋大学生命科学与技术学院)" 179 | ..$ name_code : chr "e192fbc15df24049bcd0fd01d307affa" 180 | ..$ name_status : chr "accepted name" 181 | ..$ scientific_name : chr "Anguilla marmorata" 182 | ..$ download_date : Date[1:1], format: "2020-08-04" 183 | ``` 184 | ###### Download detailed lists via species or infraspecies ID 185 | ```r 186 | x1 <- search_checklist(query = taxonid1[["3851c5311bed46c19529cb155d37aa9b"]][["data"]][["namecode"]]) 187 | x2 <- search_checklist(query = taxonid2[["Anguilla marmorata"]][["data"]][["name_code"]]) 188 | 189 | ``` 190 | ```r 191 | str(x1[["Anguilla marmorata"]]) 192 | ``` 193 | 194 | ```r 195 | List of 2 196 | $ meta:List of 2 197 | ..$ code : int 200 198 | ..$ message: chr "success" 199 | $ data:List of 12 200 | ..$ searchCodeStatus: chr "accepted name" 201 | ..$ namecode : chr "e192fbc15df24049bcd0fd01d307affa" 202 | ..$ scientificName : chr "Anguilla marmorata" 203 | ..$ author : chr "Quoy et Gaimard,1824" 204 | ..$ Refs : chr [1:2] "" "" 205 | ..$ Distribution : chr "Zhejiang(浙江)" 206 | ..$ taxonTree : tibble [1 × 8] (S3: tbl_df/tbl/data.frame) 207 | .. ..$ phylum : chr "Chordata" 208 | .. ..$ genus : chr "Anguilla" 209 | .. ..$ species : chr "marmorata" 210 | .. ..$ infraspecies: chr "" 211 | .. ..$ family : chr "Anguillidae" 212 | .. ..$ kingdom : chr "Animalia" 213 | .. ..$ class : chr "Actinopterygii" 214 | .. ..$ order : chr "Anguilliformes" 215 | ..$ chineseName : chr "花鳗鲡" 216 | ..$ searchCode : chr "e192fbc15df24049bcd0fd01d307affa" 217 | ..$ CommonNames : list() 218 | ..$ SpecialistInfo :'data.frame': 3 obs. of 4 variables: 219 | .. ..$ E-Mail : chr [1:3] "zhangcg@ioz.ac.cn" "zoskt@gate.sinica.edu.tw" "" 220 | .. ..$ Address : chr [1:3] "1 Beichen West Road, Chaoyang District, Beijing 100101, P.R.China(北京市朝阳区北辰西路1号院5号 中国科学院动物研究所)" "()" "No.999, Huchenghuan Rd , Nanhui New City, Shanghai, P.R. China(上海市浦东新区沪城环路999号)" 221 | .. ..$ name : chr [1:3] "Zhang Chunguang(张春光)" "Shao, Kwang-Tsao(邵广昭)" "Wu Hanlin(伍汉霖)" 222 | .. ..$ Institution: chr [1:3] "Institute of Zoology, Chinese Academy of Sciences(中国科学院动物研究所)" "(中央研究院生物多樣性研究中心)" "College of Life Science & Technology, Shanghai Ocean University(上海海洋大学生命科学与技术学院)" 223 | ..$ download_date : Date[1:1], format: "2020-08-04" 224 | ``` 225 | 226 | ```r 227 | str(x2) 228 | ``` 229 | 230 | ```r 231 | List of 1 232 | $ Anguilla marmorata:List of 2 233 | ..$ meta:List of 2 234 | .. ..$ code : int 200 235 | .. ..$ message: chr "success" 236 | ..$ data:List of 12 237 | .. ..$ searchCodeStatus: chr "accepted name" 238 | .. ..$ namecode : chr "e192fbc15df24049bcd0fd01d307affa" 239 | .. ..$ scientificName : chr "Anguilla marmorata" 240 | .. ..$ author : chr "Quoy et Gaimard,1824" 241 | .. ..$ Refs : chr [1:2] "" "" 242 | .. ..$ Distribution : chr "Zhejiang(浙江)" 243 | .. ..$ taxonTree : tibble [1 × 8] (S3: tbl_df/tbl/data.frame) 244 | .. .. ..$ phylum : chr "Chordata" 245 | .. .. ..$ genus : chr "Anguilla" 246 | .. .. ..$ species : chr "marmorata" 247 | .. .. ..$ infraspecies: chr "" 248 | .. .. ..$ family : chr "Anguillidae" 249 | .. .. ..$ kingdom : chr "Animalia" 250 | .. .. ..$ class : chr "Actinopterygii" 251 | .. .. ..$ order : chr "Anguilliformes" 252 | .. ..$ chineseName : chr "花鳗鲡" 253 | .. ..$ searchCode : chr "e192fbc15df24049bcd0fd01d307affa" 254 | .. ..$ CommonNames : list() 255 | .. ..$ SpecialistInfo :'data.frame': 3 obs. of 4 variables: 256 | .. .. ..$ E-Mail : chr [1:3] "zhangcg@ioz.ac.cn" "zoskt@gate.sinica.edu.tw" "" 257 | .. .. ..$ Address : chr [1:3] "1 Beichen West Road, Chaoyang District, Beijing 100101, P.R.China(北京市朝阳区北辰西路1号院5号 中国科学院动物研究所)" "()" "No.999, Huchenghuan Rd , Nanhui New City, Shanghai, P.R. China(上海市浦东新区沪城环路999号)" 258 | .. .. ..$ name : chr [1:3] "Zhang Chunguang(张春光)" "Shao, Kwang-Tsao(邵广昭)" "Wu Hanlin(伍汉霖)" 259 | .. .. ..$ Institution: chr [1:3] "Institute of Zoology, Chinese Academy of Sciences(中国科学院动物研究所)" "(中央研究院生物多樣性研究中心)" "College of Life Science & Technology, Shanghai Ocean University(上海海洋大学生命科学与技术学院)" 260 | .. ..$ download_date : Date[1:1], format: "2020-08-04" 261 | ``` 262 | 263 | ###### Get Catalogue of Life Global checklist via species name and id 264 | ```r 265 | x3 <- get_col_global(query = queries, option = "name") 266 | head(x3[["Anguilla marmorata"]][["data"]]) 267 | ``` 268 | ```r 269 | # A tibble: 2 x 24 270 | id name rank name_status record_scrutiny… online_resource is_extinct source_database 271 | 272 | 1 433e… Angu… Spec… accepted n… "http://www.fi… false FishBase 273 | 2 1a44… Angu… Spec… misapplied… "" NA FishBase 274 | # … with 16 more variables: source_database_url , bibliographic_citation , name_html , 275 | # url , accepted_name.id , accepted_name.name , accepted_name.rank , 276 | # accepted_name.name_status , accepted_name.record_scrutiny_date , 277 | # accepted_name.online_resource , accepted_name.is_extinct , 278 | # accepted_name.source_database , accepted_name.source_database_url , 279 | # accepted_name.bibliographic_citation , accepted_name.name_html , 280 | # accepted_name.url 281 | ``` 282 | ```r 283 | str(list_df(x3,db = "colglobal")[["meta"]]) 284 | ``` 285 | ```r 286 | List of 8 287 | $ id :List of 5 288 | ..$ Anguilla marmorata : chr "" 289 | ..$ Anguilla japonica : chr "" 290 | ..$ Anguilla bicolor : chr "" 291 | ..$ Anguilla nebulosa : chr "" 292 | ..$ Anguilla luzonensis: chr "" 293 | $ name :List of 5 294 | ..$ Anguilla marmorata : chr "Anguilla marmorata" 295 | ..$ Anguilla japonica : chr "Anguilla japonica" 296 | ..$ Anguilla bicolor : chr "Anguilla bicolor" 297 | ..$ Anguilla nebulosa : chr "Anguilla nebulosa" 298 | ..$ Anguilla luzonensis: chr "Anguilla luzonensis" 299 | $ total_number_of_results :List of 5 300 | ..$ Anguilla marmorata : int 2 301 | ..$ Anguilla japonica : int 1 302 | ..$ Anguilla bicolor : int 3 303 | ..$ Anguilla nebulosa : int 4 304 | ..$ Anguilla luzonensis: int 1 305 | $ number_of_results_returned:List of 5 306 | ..$ Anguilla marmorata : int 2 307 | ..$ Anguilla japonica : int 1 308 | ..$ Anguilla bicolor : int 3 309 | ..$ Anguilla nebulosa : int 4 310 | ..$ Anguilla luzonensis: int 1 311 | $ start :List of 5 312 | ..$ Anguilla marmorata : int 0 313 | ..$ Anguilla japonica : int 0 314 | ..$ Anguilla bicolor : int 0 315 | ..$ Anguilla nebulosa : int 0 316 | ..$ Anguilla luzonensis: int 0 317 | $ error_mexage :List of 5 318 | ..$ Anguilla marmorata : NULL 319 | ..$ Anguilla japonica : NULL 320 | ..$ Anguilla bicolor : NULL 321 | ..$ Anguilla nebulosa : NULL 322 | ..$ Anguilla luzonensis: NULL 323 | $ version :List of 5 324 | ..$ Anguilla marmorata : chr "1.9 rev 2126ab0" 325 | ..$ Anguilla japonica : chr "1.9 rev 2126ab0" 326 | ..$ Anguilla bicolor : chr "1.9 rev 2126ab0" 327 | ..$ Anguilla nebulosa : chr "1.9 rev 2126ab0" 328 | ..$ Anguilla luzonensis: chr "1.9 rev 2126ab0" 329 | $ rank :List of 5 330 | ..$ Anguilla marmorata : chr "" 331 | ..$ Anguilla japonica : chr "" 332 | ..$ Anguilla bicolor : chr "" 333 | ..$ Anguilla nebulosa : chr "" 334 | ..$ Anguilla luzonensis: chr "" 335 | ``` 336 | 337 | ###### Find synonyms via species name from Catalogue of Life Global 338 | ```r 339 | find_synonyms(queries) 340 | ``` 341 | ```r 342 | # last Update: 2020-08-04 343 | # |=========================================================================================| 100%, Elapsed 00:05 344 | # Find 8 results of synonyms for Anguilla marmorata are as follows: 345 | # Find 6 results of synonyms for Anguilla japonica are as follows: 346 | # Find 23 results of synonyms for Anguilla bicolor are as follows: 347 | # Find 4 results of synonyms for Anguilla nebulosa are as follows: 348 | # Find 1 results of synonyms for Anguilla luzonensis are as follows: 349 | # $`Anguilla marmorata` 350 | # [1] "Anguilla fidjiensis" "Anguilla hildebrandti" "Anguilla johannae" "Anguilla labrosa" 351 | # [5] "Anguilla marmolata" "Anguilla mauritiana" "Muraena manillensis" "Muraena mossambica" 352 | # 353 | # $`Anguilla japonica` 354 | # [1] "Anguilla angustidens" "Anguilla breviceps" "Anguilla manabei" "Anguilla nigricans" 355 | # [5] "Anguilla remifera" "Muraena pekinensis" 356 | # 357 | # $`Anguilla bicolor` 358 | # [1] "Anguilla amblodon" "Anguilla australis" "Anguilla bicolor bicolor" 359 | # [4] "Anguilla bicolor pacifica" "Anguilla bicolour" "Anguilla bicolour bicolour" 360 | # [7] "Anguilla bleekeri" "Anguilla cantori" "Anguilla dussumieri" 361 | # [10] "Anguilla malabarica" "Anguilla malgumora" "Anguilla mauritiana" 362 | # [13] "Anguilla moa" "Anguilla mowa" "Anguilla pacifica" 363 | # [16] "Anguilla sidat" "Anguilla spengeli" "Anguilla virescens" 364 | # [19] "Muraena halmaherensis" "Muraena macrocephala" "Muraena moa" 365 | # [22] "Muraena mossambica" "Muraena virescens" 366 | # 367 | # $`Anguilla nebulosa` 368 | # [1] "Anguilla bengalensis" "Anguilla elphinstonei" "Anguilla nebulosa nebulosa" 369 | # [4] "Muraena maculata" 370 | # 371 | # $`Anguilla luzonensis` 372 | # [1] "Anguilla huangi" 373 | ``` 374 | 375 | ###### Search Catalogue of Life Taiwan checklist 376 | ```r 377 | get_col_taiwan(query = "Anguilla",level = "species",option = "contain") 378 | ``` 379 | ```r 380 | # last Update: 2020-08-04 381 | # # A tibble: 5 x 23 382 | # name_code kingdom kingdom_c phylum phylum_c class class_c order order_c family family_c genus genus_c species 383 | # 384 | # 1 380710 Animal… 動物界 Chord… 脊索動物門… Acti… 條鰭魚綱… Angu… 鰻形目 Angui… 鰻鱺科 Angu… 鰻鱺屬 bicolor 385 | # 2 395489 Animal… 動物界 Chord… 脊索動物門… Acti… 條鰭魚綱… Angu… 鰻形目 Angui… 鰻鱺科 Angu… 鰻鱺屬 celebe… 386 | # 3 380711 Animal… 動物界 Chord… 脊索動物門… Acti… 條鰭魚綱… Angu… 鰻形目 Angui… 鰻鱺科 Angu… 鰻鱺屬 japoni… 387 | # 4 395491 Animal… 動物界 Chord… 脊索動物門… Acti… 條鰭魚綱… Angu… 鰻形目 Angui… 鰻鱺科 Angu… 鰻鱺屬 luzone… 388 | # 5 380712 Animal… 動物界 Chord… 脊索動物門… Acti… 條鰭魚綱… Angu… 鰻形目 Angui… 鰻鱺科 Angu… 鰻鱺屬 marmor… 389 | # # … with 9 more variables: infraspecies_marker , infraspecies , infraspecies2_marker , 390 | # # infraspecies2 , author , author2 , common_name_c , endemic , dataprovider 391 | # 392 | 393 | ``` 394 | 395 | ###### Query Redlist of Chinese Biodiversity 396 | ```r 397 | get_redlist_china(query = "Anguilla", option = "Scientific Names") 398 | ``` 399 | ```r 400 | # last Update: 2020-08-04 401 | # # A tibble: 4 x 11 402 | # `Chinese Family… Family `Chinese Names` ScientificNames Status `Assessment Cri… Endemic Taxon `Chinese Taxon` 403 | # 404 | # 1 鳗鲡科 Angui… 日本鳗鲡 Anguilla japon… EN A2bcd NA Inla… 内陆鱼类 405 | # 2 鳗鲡科 Angui… 花鳗鲡 Anguilla marmo… EN A2bcd NA Inla… 内陆鱼类 406 | # 3 鳗鲡科 Angui… 双色鳗鲡 Anguilla bicol… NT NA NA Inla… 内陆鱼类 407 | # 4 鳗鲡科 Angui… 云纹鳗鲡 Anguilla nebul… NT NA NA Inla… 内陆鱼类 408 | # # … with 2 more variables: Group , `Chinese Group` 409 | ``` 410 | 411 | ##### Note: You need to apply for the [*apiKey*](http://zoology.especies.cn/database/api) to run zoology_* functions of this package. 412 | ###### Query details of species in China Animal Scientific Database 413 | 414 | ```r 415 | ##Set your key 416 | set_search_key("your apiKey",db = "zoology") 417 | 418 | ## Query China Animal Scientific Database lists 419 | zoology_dbase_name() 420 | ``` 421 | 422 | ```r 423 | Request returned successfully!!! 424 | last Update: 2020-10-26 425 | China Animal Scientific Database - Found: 13 426 | 1:中国动物志数据库 427 | 2:中国动物图谱数据库 428 | 3:中国经济动物数据库 429 | 4:中国鸟类数据库 430 | 5:中国哺乳动物数据库 431 | 6:中国蝴蝶数据库 432 | 7:中国蜜蜂数据库 433 | 8:中国内陆水体鱼类数据库 434 | 9:中国两栖动物 435 | 10:中国爬行动物数据库 436 | 11:中国直翅目与革翅目昆虫数据库 437 | 12:中国蜚蠊目数据库 438 | 13:中国双尾纲与原尾纲数据库 439 | ``` 440 | ```r 441 | ## Query description type information of Chinese Bird Database 442 | zoology_description_type(query = "Aix galericulata",dbname = 4) 443 | ``` 444 | 445 | ```r 446 | Request returned successfully!!! 447 | last Update: 2020-10-26 448 | id type 449 | 1 1 形态描述 450 | 2 152 生境信息 451 | 3 159 鸣声描述 452 | 4 205 地理区分布 453 | 5 208 国外分布 454 | 6 209 国内分布 455 | 7 301 保护信息 456 | ``` 457 | ```r 458 | ## Query details of species in Chinese Bird Database 459 | zoology_description(query = "Aix galericulata",dbname = 4,destype = 209) 460 | ``` 461 | ```r 462 | Request returned successfully!!! 463 | last Update: 2020-10-26 464 | $`Aix galericulata` 465 | $`Aix galericulata`$meta 466 | $`Aix galericulata`$meta$scientificName 467 | [1] "Aix galericulata" 468 | 469 | 470 | $`Aix galericulata`$data 471 | refs descontent 472 | 1 郑光美, 2011, 中国鸟类分类与分布名录. 北京:科学出版社. pp456 All except Xinjiang, Xizang, Qinghai 473 | 2 郑光美, 2011, 中国鸟类分类与分布名录. 北京:科学出版社. pp456 除新疆、西藏、青海外,见于各省 474 | destitle 475 | 1 Aix galericulata的国内分布 476 | 2 Aix galericulata的国内分布 477 | ``` 478 | 479 | ```r 480 | sessionInfo() 481 | ``` 482 | ```r 483 | # R version 4.0.0 (2020-04-24) 484 | # Platform: x86_64-apple-darwin17.0 (64-bit) 485 | # Running under: macOS Catalina 10.15.5 486 | # 487 | # Matrix products: default 488 | # BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 489 | # LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib 490 | # 491 | # locale: 492 | # [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 493 | # 494 | # attached base packages: 495 | # [1] stats graphics grDevices utils datasets methods base 496 | # 497 | # other attached packages: 498 | # [1] SP2000_0.1.0 499 | # 500 | # loaded via a namespace (and not attached): 501 | # [1] Rcpp_1.0.4.6 rstudioapi_0.11 magrittr_1.5 rlang_0.4.6 fansi_0.4.1 tools_4.0.0 502 | # [7] parallel_4.0.0 DT_0.13 data.table_1.12.8 utf8_1.1.4 cli_2.0.2 htmltools_0.4.0 503 | # [13] ellipsis_0.3.1 assertthat_0.2.1 digest_0.6.25 tibble_3.0.1 lifecycle_0.2.0 crayon_1.3.4 504 | # [19] pbmcapply_1.5.0 purrr_0.3.4 htmlwidgets_1.5.1 vctrs_0.3.0 curl_4.3 rlist_0.4.6.1 505 | # [25] glue_1.4.1 compiler_4.0.0 pillar_1.4.4 XML_3.99-0.3 jsonlite_1.6.1 pkgconfig_2.0.3 506 | ``` 507 | 508 | ## Contribution 509 | 510 | Contributions to this package are welcome. 511 | The preferred method of contribution is through a GitHub pull request. 512 | Feel also free to contact us by creating [**an issue**](https://github.com/Otoliths/sp2000/issues). 513 | 514 | ## Acknowledgment 515 | 516 | The development of this [**SP2000**](https://cran.r-project.org/package=SP2000) package were supported by the Biodiversity Survey and Assessment Project of the Ministry of Ecology and Environment, China ([**2019HJ2096001006**](http://www.mee.gov.cn/xxgk/zfcg/zbxx09/201906/t20190620_707171.shtml)),Yunnan University's "Double First Class" Project [**C176240405**]and the Yunnan University's Research Innovation Fund for Graduate Students[**2019227**]. 517 | 518 | ### How to cite this package 519 | ```r 520 | citation("SP2000") 521 | ``` 522 | ```r 523 | To cite package ‘SP2000’ in publications use: 524 | 525 | Liuyong Ding (2020). SP2000: Catalogue of Life Toolkit. R package version 0.1.0. 526 | https://github.com/Otoliths/SP2000 527 | 528 | A BibTeX entry for LaTeX users is 529 | 530 | @Manual{, 531 | title = {SP2000: Catalogue of Life Toolkit}, 532 | author = {Liuyong Ding}, 533 | year = {2020}, 534 | note = {R package version 0.1.0}, 535 | url = {https://github.com/Otoliths/SP2000}, 536 | } 537 | ``` 538 | ### [How to cite this work](http://sp2000.org.cn/info/info_how_to_cite) 539 | 540 | ```r 541 | Catalogue of Life China: 542 | The Biodiversity Committee of Chinese Academy of Sciences, 2020, Catalogue of Life China: 2020 Annual Checklist, Beijing, China 543 | 544 | How to cite individual databases included in this work, for example: 545 | 546 | Animal: 547 | JI Liqiang, et al, 2020, China Checklist of Animals, In the Biodiversity Committee of Chinese Academy of Sciences ed., Catalogue of Life China: 2020 Annual Checklist, Beijing, China 548 | 549 | Plant: 550 | QIN Haining, et al, 2020, China Checklist of Higher Plants, In the Biodiversity Committee of Chinese Academy of Sciences ed., Catalogue of Life China: 2020 Annual Checklist, Beijing, China 551 | 552 | Fungi: 553 | YAO Yijian, et al, 2020, China Checklist of Fungi, In the Biodiversity Committee of Chinese Academy of Sciences ed., Catalogue of Life China: 2020 Annual Checklist, Beijing, China 554 | 555 | How to cite taxon included in this work, for example: 556 | 557 | Aix galericulata: 558 | LEI Fumin, et al, 2020. Aix galericulata in Catalogue of Life China: 2020 Annual Checklist, Beijing, China. http://sp2000.org.cn/species/show_species_details/f3bc32a7-50ec-41cc-91ee-a990b9196838 559 | ``` 560 | 561 | ### Visitor Count 562 | ![Visitor Count](https://profile-counter.glitch.me/SP2000/count.svg) 563 | -------------------------------------------------------------------------------- /SP2000.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace 22 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /inst/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Otoliths/SP2000/bce8056d4c4788bc0b51b71e9ba81b771d312d73/inst/figures/logo.png -------------------------------------------------------------------------------- /inst/htmlwidgets/mywidget.js: -------------------------------------------------------------------------------- 1 | HTMLWidgets.widget({ 2 | 3 | name: 'mywidget', 4 | 5 | type: 'output', 6 | 7 | factory: function(el, width, height) { 8 | 9 | // TODO: define shared variables for this instance 10 | 11 | return { 12 | 13 | renderValue: function(x) { 14 | 15 | // TODO: code to render the widget, e.g. 16 | el.innerText = x.message; 17 | 18 | }, 19 | 20 | resize: function(width, height) { 21 | 22 | // TODO: code to re-render the widget with a new size 23 | 24 | } 25 | 26 | }; 27 | } 28 | }); -------------------------------------------------------------------------------- /inst/htmlwidgets/mywidget.yaml: -------------------------------------------------------------------------------- 1 | # (uncomment to add a dependency) 2 | # dependencies: 3 | # - name: 4 | # version: 5 | # src: 6 | # script: 7 | # stylesheet: 8 | -------------------------------------------------------------------------------- /man/SP2000-package.Rd: -------------------------------------------------------------------------------- 1 | \name{SP2000-package} 2 | \alias{SP2000-package} 3 | \alias{SP2000} 4 | \docType{package} 5 | \title{\packageTitle{SP2000}} 6 | \description{ 7 | This package is designed for mining the checklist of animals, plants, fungi and micro-organisms both in and outside China. 8 | } 9 | \details{ 10 | \packageDESCRIPTION{SP2000} 11 | \packageIndices{SP2000} 12 | } 13 | 14 | \author{Maintainer: \packageMaintainer{SP2000}} 15 | 16 | \examples{ 17 | \dontrun{ 18 | # Note: You need to apply for the apiKey 19 | to run search_* functions of this package. 20 | 21 | ## Load "SP2000" 22 | 23 | library('SP2000') 24 | 25 | ## Set your key 26 | 27 | set_search_key("your apiKey",db = "sp2000") 28 | 29 | ## Search family IDs via family name, supports Latin and Chinese names 30 | 31 | familyid <- search_family_id(query = "Anguillidae") 32 | 33 | ## Search taxon IDs via familyID ,scientificName and commonName 34 | 35 | query <- familyid$Anguillidae$data$record_id 36 | 37 | taxonid <- search_taxon_id(query = query,name = "familyID") 38 | 39 | queries = c("Anguilla marmorata","Anguilla japonica", 40 | "Anguilla bicolor","Anguilla nebulosa", 41 | "Anguilla luzonensis") 42 | 43 | search_taxon_id(query = queries,name = "scientificName") 44 | 45 | ## Download detailed lists via species or infraspecies ID 46 | 47 | query <- taxonid[["3851c5311bed46c19529cb155d37aa9b"]][["data"]][["namecode"]] 48 | 49 | checklist <- search_checklist(query = query) 50 | 51 | 52 | ## Get Catalogue of Life Global checklist via species name and id 53 | 54 | x <- get_col_global(query = "Anguilla", response = "full") 55 | 56 | str(x) 57 | 58 | x[["Anguilla"]][["meta"]][["total_number_of_results"]] [1] 59 | 60 | ## Find synonyms via species name from Catalogue of Life Global 61 | 62 | find_synonyms(query = queries) 63 | 64 | ## Search Catalogue of Life Taiwan checklist 65 | 66 | get_col_taiwan(query = "Anguillidae", level = "family") 67 | 68 | ## Query Redlist of Chinese Biodiversity 69 | 70 | get_redlist_china(query = "Anguilla", option = "Scientific Names") 71 | 72 | } 73 | } 74 | 75 | \references{ 76 | Ding LY, Li H, Tao J, Zhang JL, Huang MR, Yang K, Wang J, He DM, Ding CZ (2020) SP2000: An open-sourced R package for querying the Catalogue of Life. Biodiversity Science. 77 | 78 | https://cran.r-project.org/package=SP2000 79 | 80 | https://pypi.org/project/SP2000 81 | 82 | } 83 | 84 | 85 | \keyword{ package } 86 | -------------------------------------------------------------------------------- /man/api_key.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/api_key.R 3 | \name{set_search_key} 4 | \alias{set_search_key} 5 | \title{SP2000 API keys} 6 | \usage{ 7 | set_search_key(key, db = "sp2000") 8 | } 9 | \arguments{ 10 | \item{key}{\code{string} Value to set apiKey to (i.e. your API key).} 11 | 12 | \item{db}{\code{string} Set up the database API, db = c("sp2000","zoology").} 13 | } 14 | \value{ 15 | A logical of length one, TRUE is the value was set FALSE if not. 16 | value is returned inside invisible(), i.e. it is not printed to screen 17 | when the function is called. 18 | } 19 | \description{ 20 | Apply for the apiKey variable to be used by all search_* functions and zoology_* functions, 21 | register for \url{http://sp2000.org.cn/api/document} and use an API key. This function allows users to set this key. 22 | Note: The daily API visits of ordinary users are 2000, 23 | If you want to apply for increasing the daily API request limit, 24 | please fill in the application form \url{http://col.especies.cn/doc/API.docx} and send an email to \email{SP2000CN@ibcas.ac.cn} entitled "Application for increasing API Request Times". 25 | } 26 | \examples{ 27 | \dontrun{ 28 | #Set the apiKey variable to be used by all search_* functions 29 | set_search_key("your apiKey",db = "sp2000") 30 | 31 | #Set the apiKey variable to be used by all zoology_* functions 32 | set_search_key("your apiKey",db = "zoology") 33 | 34 | } 35 | } 36 | \author{ 37 | Liuyong Ding \email{ly_ding@126.com} 38 | } 39 | -------------------------------------------------------------------------------- /man/download_col_china.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/download_col_china.R 3 | \name{download_col_china} 4 | \alias{download_col_china} 5 | \title{Download 'Catalogue of Life China': Annual Checklist} 6 | \usage{ 7 | download_col_china(version = "2020", OS = "MacOS", dir = tempdir(), mode, ...) 8 | } 9 | \arguments{ 10 | \item{version}{\code{integer} Release version of annual checklist,the default value is 2020.} 11 | 12 | \item{OS}{\code{character} Supported operating system,c("MacOS", "Ubuntu" ,"Windows"),the default value is "MacOS".} 13 | 14 | \item{dir}{A non-empty character vector giving the directory name by user,the default value is dir = tempdir(),see \code{\link{tempdir}} for details.} 15 | 16 | \item{mode}{A character string specifying the mode with which to write the file. Useful values are "w", "wb" (binary), "a" (append) and "ab". see \code{\link{download.file}} for details.} 17 | 18 | \item{...}{Allow additional arguments to be passed, unused. see \code{\link{download.file}} for details.} 19 | } 20 | \value{ 21 | URL 22 | } 23 | \description{ 24 | Organized by the Biodiversity Committee of Chinese Academy of Sciences (BC-CAS), Catalogue of Life China Annual Checklist edition has been compiled by Species 2000 China Node. 25 | } 26 | \details{ 27 | Visit the website \url{http://sp2000.org.cn/download} for more details. 28 | } 29 | \examples{ 30 | \dontrun{ 31 | dir <- tempdir() 32 | download_col_china(version = "2020",OS = "MacOS", dir = dir) 33 | } 34 | } 35 | \author{ 36 | Liuyong Ding \email{ly_ding@126.com} 37 | } 38 | -------------------------------------------------------------------------------- /man/find_synonyms.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/find_synonyms.R 3 | \name{find_synonyms} 4 | \alias{find_synonyms} 5 | \title{Find synonyms via species name} 6 | \usage{ 7 | find_synonyms(query, mc.cores = 2) 8 | } 9 | \arguments{ 10 | \item{query}{\code{character} species name,The function is similar to \code{\link{get_col_global}}.} 11 | 12 | \item{mc.cores}{The number of cores to use, i.e. at most how many child processes will be run simultaneously. The option is initialized from environment variable MC_CORES if set. Must be at least one, and parallelization requires at least two cores,see \code{\link{mclapply}} for details.} 13 | } 14 | \value{ 15 | object 16 | } 17 | \description{ 18 | Find synonyms via species name from Catalogue of Life Global. 19 | } 20 | \details{ 21 | Visit the website \url{http://webservice.catalogueoflife.org/col/webservice} for more details. 22 | } 23 | \examples{ 24 | \dontrun{ 25 | ##Get Catalogue of Life Global checklist via species name 26 | x1 <- get_col_global(query = c("Anguilla marmorata","Anguilla japonica", 27 | "Anguilla bicolor","Anguilla nebulosa", 28 | "Anguilla luzonensis"), 29 | option = "name") 30 | str(x1) 31 | 32 | ##full queries 33 | x2 <- get_col_global(query = "Anguilla", response = "full") 34 | 35 | 36 | ##Find synonyms via species name 37 | find_synonyms(query = c("Anguilla marmorata","Anguilla japonica", 38 | "Anguilla bicolor","Anguilla nebulosa", 39 | "Anguilla luzonensis")) 40 | } 41 | } 42 | \references{ 43 | \url{https://github.com/lutteropp/SpeciesSynonymFinder/blob/master/find_synonyms.r} 44 | } 45 | \author{ 46 | Liuyong Ding \email{ly_ding@126.com} 47 | } 48 | -------------------------------------------------------------------------------- /man/get_col_global.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_col_global.R 3 | \name{get_col_global} 4 | \alias{get_col_global} 5 | \title{Search Catalogue of Life Global checklist} 6 | \usage{ 7 | get_col_global( 8 | query, 9 | option = "name", 10 | response = "terse", 11 | start = 0, 12 | limit = 500, 13 | mc.cores = 2 14 | ) 15 | } 16 | \arguments{ 17 | \item{query}{\code{string} The string to search for.} 18 | 19 | \item{option}{\code{character} There is one required parameter, which is either name or id. Give eithera name or an ID. If an ID is given, the name parameter may not be used, and vice versa. option=c("id","name"),the default value is "name". Only exact matches found the name given will be returned, unless a wildcard (*) is appended. Wildcards are allowed only at the end of the string. This offers the option to e.g. search for genus* to retrieve the genus plus all its (infra)species. The name must be at least 3 characters long, not counting the wildcard character. The record ID of the specific record to return (only for scientific names of species or infraspecific taxa).} 20 | 21 | \item{response}{\code{character} Type of response returned. Valid values are response=terse and response=full. if the response parameter is omitted, the results are returned in the default terse format. If format=terse then a minimum set of results are returned (this is faster and smaller, enough for name lookup), if format=full then all available information is returned, response=c("full","terse"),the default value is "terse".} 22 | 23 | \item{start}{\code{integer} Record number to start at. If omitted, the results are returned from the first record (start=0). Use in combination with limit to page through results. Note that we do the paging internally for you, but you can manually set the start parameter.} 24 | 25 | \item{limit}{\code{integer} Number of records to return. This is useful if the total number of results is larger than the maximum number of results returned by a single Web service query (currently the maximum number of results returned by a single query is 500 for terse queries and 50 for full queries,the default value is 500.Note that there is a hard maximum of 10,000, which is calculated as the limit+start, so start=99,00 and limit=2000 won't work.} 26 | 27 | \item{mc.cores}{The number of cores to use, i.e. at most how many child processes will be run simultaneously. The option is initialized from environment variable MC_CORES if set. Must be at least one, and parallelization requires at least two cores,see \code{\link{mclapply}} for details.} 28 | } 29 | \value{ 30 | object 31 | } 32 | \description{ 33 | Get Catalogue of Life Global checklist via species name and id. 34 | } 35 | \details{ 36 | Visit the website \url{http://webservice.catalogueoflife.org/col/webservice} for more details. 37 | } 38 | \examples{ 39 | \dontrun{ 40 | ##Get Catalogue of Life Global checklist via species name 41 | x1 <- get_col_global(query = c("Anguilla marmorata","Anguilla japonica", 42 | "Anguilla bicolor","Anguilla nebulosa", 43 | "Anguilla luzonensis"), 44 | option = "name") 45 | str(x1) 46 | 47 | ##full queries 48 | x2 <- get_col_global(query = "Anguilla", response = "full") 49 | 50 | 51 | ##Find synonyms via species name 52 | find_synonyms(query = c("Anguilla marmorata","Anguilla japonica", 53 | "Anguilla bicolor","Anguilla nebulosa", 54 | "Anguilla luzonensis")) 55 | } 56 | } 57 | \author{ 58 | Liuyong Ding \email{ly_ding@126.com} 59 | } 60 | -------------------------------------------------------------------------------- /man/get_col_taiwan.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_col_taiwan.R 3 | \name{get_col_taiwan} 4 | \alias{get_col_taiwan} 5 | \title{Search Catalogue of Life Taiwan checklist} 6 | \usage{ 7 | get_col_taiwan( 8 | query, 9 | level = "species", 10 | option = "equal", 11 | include_synonyms = TRUE 12 | ) 13 | } 14 | \arguments{ 15 | \item{query}{\code{string} The string to search for.} 16 | 17 | \item{level}{\code{character} Query by category level, level=c("kingdom","phylum","class","order","family","genus","species"),the default value is "species".} 18 | 19 | \item{option}{\code{character} Query format, option=c("contain","equal","beginning"),the default value is "equal".} 20 | 21 | \item{include_synonyms}{\code{logic} Whether the results contain a synonym or not.} 22 | } 23 | \value{ 24 | object 25 | } 26 | \description{ 27 | Get Catalogue of Life Taiwan checklist via advanced query. 28 | } 29 | \details{ 30 | Visit the website \url{https://taibnet.sinica.edu.tw/eng/taibnet_species_query.php} for more details. 31 | } 32 | \examples{ 33 | \dontrun{ 34 | ##Search Catalogue of Life Taiwan checklist 35 | get_col_taiwan(query="Anguilla",level="species",option = "contain") 36 | 37 | get_col_taiwan(query="Anguillidae",level="family") 38 | } 39 | } 40 | \author{ 41 | Liuyong Ding \email{ly_ding@126.com} 42 | } 43 | -------------------------------------------------------------------------------- /man/get_province.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_province.R 3 | \name{get_province} 4 | \alias{get_province} 5 | \title{Statistics on Species or Infraspecies by Province from Catalogue of Life China checklist} 6 | \usage{ 7 | get_province() 8 | } 9 | \value{ 10 | Statistics on species or infraspecies by province. 11 | } 12 | \description{ 13 | Download the statistics datasets on species/infraspecies by province at \url{http://sp2000.org.cn/statistics/statistics_map} for more details. 14 | } 15 | \details{ 16 | Visit the website \url{http://sp2000.org.cn/statistics/statistics_map} for more details. 17 | } 18 | \examples{ 19 | \dontrun{ 20 | get_province() 21 | 22 | } 23 | } 24 | \author{ 25 | Liuyong Ding \email{ly_ding@126.com} 26 | } 27 | -------------------------------------------------------------------------------- /man/get_redlist_china.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_redlist_china.R 3 | \name{get_redlist_china} 4 | \alias{get_redlist_china} 5 | \title{Query Redlist of Chinese Biodiversity} 6 | \format{ 7 | assessment status: 8 | \describe{ 9 | \item{EX}{Extinct} 10 | \item{EW}{Extinct in the wild} 11 | \item{RE}{Regional Extinct} 12 | \item{CR}{Critically Endangered} 13 | \item{EN}{Endangered} 14 | \item{VU}{Vulnerable} 15 | \item{NT}{Near Threatened} 16 | \item{LC}{Least Concern} 17 | \item{DD}{Data Deficient} 18 | } 19 | } 20 | \usage{ 21 | get_redlist_china( 22 | query = NULL, 23 | option = "Scientific Names", 24 | group = "Amphibians", 25 | viewDT = FALSE 26 | ) 27 | } 28 | \arguments{ 29 | \item{query}{\code{string} The string to query for.} 30 | 31 | \item{option}{\code{character} There is one required parameter, which is either Chinese Names or Scientific Names. Give eithera Chinese Names or Scientific Names. If an Scientific Names is given, the Chinese Names parameter may not be used. Only exact matches found the name given will be returned. option=c("Chinese Names","Scientific Names"),,the default value is "Scientific Names".} 32 | 33 | \item{group}{\code{character} There is one required parameter, group=c("Amphibians","Birds","Inland Fishes","Mammals","Reptiles","Plants","Fungi").} 34 | 35 | \item{viewDT}{\code{logic} TRUE or FALSE,the default value is FALSE.} 36 | } 37 | \value{ 38 | object 39 | } 40 | \description{ 41 | Query Redlist of China’s Biodiversity of Vertebrate, Higher Plants and Macrofungi. 42 | } 43 | \details{ 44 | Visit the website \url{http://zoology.especies.cn/} for more details. 45 | } 46 | \examples{ 47 | \dontrun{ 48 | #query assessment status via Chinese Names or Scientific Names 49 | get_redlist_china(query = "Anguilla", option = "Scientific Names") 50 | get_redlist_china(query = "Anguilla nebulosa", option = "Scientific Names") 51 | 52 | #creates an HTML widget to display rectangular data 53 | get_redlist_china(group = "Inland Fishes", viewDT = TRUE) 54 | } 55 | } 56 | \references{ 57 | \url{http://zoology.especies.cn/} 58 | 59 | \url{http://www.fungalinfo.net} 60 | 61 | \url{http://www.iplant.cn/rep/protlist} 62 | 63 | \url{http://www.mee.gov.cn} 64 | } 65 | \author{ 66 | Liuyong Ding \email{ly_ding@126.com} 67 | 68 | Ke Yang \email{ydyangke@163.com} 69 | } 70 | -------------------------------------------------------------------------------- /man/get_top20.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_top20.R 3 | \name{get_top20} 4 | \alias{get_top20} 5 | \title{Download the top20 species for Catalogue of Life China checklist} 6 | \usage{ 7 | get_top20() 8 | } 9 | \value{ 10 | top20 species 11 | } 12 | \description{ 13 | Download the most visited top20 species from \url{http://sp2000.org.cn}for more details. 14 | } 15 | \details{ 16 | Visit the website \url{http://sp2000.org.cn} for more details. 17 | } 18 | \examples{ 19 | \dontrun{ 20 | get_top20() 21 | } 22 | } 23 | \author{ 24 | Liuyong Ding 25 | } 26 | -------------------------------------------------------------------------------- /man/list_df.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/list_df.R 3 | \name{list_df} 4 | \alias{list_df} 5 | \title{Catalogue of Life list(s) convert data frame} 6 | \format{ 7 | A data frame with 19 variables: 8 | \describe{ 9 | \item{ScientificName}{The scientific name (the accepted name) includes the name and the date of the name} 10 | \item{Synonyms}{Synonyms name, Latin} 11 | \item{ChineseName}{Chinese name} 12 | \item{CommonNames}{Common name} 13 | \item{Kingdom}{Kingdom at taxonTree} 14 | \item{Phylum}{Phylum at taxonTree} 15 | \item{Class}{Class at taxonTree} 16 | \item{Order}{Order at taxonTree} 17 | \item{Family}{Family at taxonTree} 18 | \item{Genus}{Genus at taxonTree} 19 | \item{Species}{Species at taxonTree} 20 | \item{Infraspecies}{Infraspecies at taxonTree} 21 | \item{Distribution}{Distribution of species or infraspecies} 22 | \item{Name}{Full name of reviewer in English or Chinese} 23 | \item{Email}{Organization of the reviewer in English or Chinese} 24 | \item{Address}{Email address of the reviewer} 25 | \item{Institution}{Address of the reviewer in English or Chinese} 26 | \item{References}{References} 27 | \item{Download}{Download date} 28 | } 29 | } 30 | \source{ 31 | Visit the website \url{http://sp2000.org.cn/api/document} for more details 32 | } 33 | \usage{ 34 | list_df(x, db = c("colchina", "colglobal")) 35 | } 36 | \arguments{ 37 | \item{x}{\code{list} Results returned by the function \code{\link{search_checklist}} and \code{\link{get_col_global}}.} 38 | 39 | \item{db}{\code{character} db = c("colchina","colglobal")} 40 | } 41 | \description{ 42 | Checklist lists convert data frame. 43 | } 44 | \examples{ 45 | \dontrun{ 46 | ##Set your key 47 | set_search_key <- "your apiKey" 48 | 49 | ##Search family IDs via family name 50 | familyid <- search_family_id(query = "Anguillidae") 51 | 52 | ##Search taxon IDs via familyID 53 | taxonid <- search_taxon_id(query = familyid$Anguillidae$data$record_id, name = "familyID") 54 | 55 | #Download detailed lists via species or infraspecies ID 56 | query <- taxonid[["3851c5311bed46c19529cb155d37aa9b"]][["data"]][["namecode"]] 57 | x1 <- search_checklist(query = query) 58 | str(x1) 59 | x1 <- list_df(x1,db = "colchina") 60 | 61 | #Get Catalogue of Life Global checklist via species name 62 | x2 <- get_col_global(query = c("Anguilla marmorata","Anguilla japonica", 63 | "Anguilla bicolor","Anguilla nebulosa", 64 | "Anguilla luzonensis"), 65 | option = "name") 66 | str(x2) 67 | x2 <- list_df(x2,db = "colglobal") 68 | } 69 | } 70 | \author{ 71 | Liuyong Ding \email{ly_ding@126.com} 72 | } 73 | -------------------------------------------------------------------------------- /man/open_url.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/open_url.R 3 | \name{open_url} 4 | \alias{open_url} 5 | \title{Opening the Catalogue of Life China checklist web pages with query} 6 | \usage{ 7 | open_url(query = NULL, name = "accceptedName", language = "en") 8 | } 9 | \arguments{ 10 | \item{query}{\code{string} the accceptedName,scientificName,chineseName or commonName.} 11 | 12 | \item{name}{\code{string} name = c("accceptedName","scientificName","chineseName","commonName"),the default value is "accceptedName".} 13 | 14 | \item{language}{\code{string} currently only two languages are supported: Chinese and English,language=c("en","zh"), the default value is "en".} 15 | } 16 | \description{ 17 | Query with the accceptedName,scientificName,chineseName and commonName, returning the web pages that meets the criteria. 18 | } 19 | \details{ 20 | Visit the website \url{http://sp2000.org.cn/pageservices/document} for more details. 21 | } 22 | \examples{ 23 | \donttest{ 24 | open_url(query = "Anguilla marmorata",name = "scientificName",language = 'en') 25 | open_url(query = "Anguilla marmorata",name = "scientificName",language = 'zh') 26 | } 27 | } 28 | \author{ 29 | Liuyong Ding 30 | 31 | Liuyong Ding \email{ly_ding@126.com} 32 | } 33 | -------------------------------------------------------------------------------- /man/search_checklist.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/search_checklist.R 3 | \name{search_checklist} 4 | \alias{search_checklist} 5 | \title{Search Catalogue of Life China checklist} 6 | \usage{ 7 | search_checklist(query = NULL, mc.cores = 2) 8 | } 9 | \arguments{ 10 | \item{query}{\code{string} One or more queries, see \code{\link{search_family_id}} and \code{\link{search_taxon_id}} for more details.} 11 | 12 | \item{mc.cores}{The number of cores to use, i.e. at most how many child processes will be run simultaneously. The option is initialized from environment variable MC_CORES if set. Must be at least one, and parallelization requires at least two cores,see \code{\link{mclapply}} for details.} 13 | } 14 | \value{ 15 | Catalogue of Life China list(s) 16 | } 17 | \description{ 18 | Get checklist via species or infraspecies ID. 19 | } 20 | \details{ 21 | Visit the website \url{http://sp2000.org.cn/api/document} for more details. 22 | } 23 | \examples{ 24 | \dontrun{ 25 | ##Set your key 26 | set_search_key("your apiKey",db = "sp2000") 27 | 28 | ##Search family IDs via family name 29 | familyid <- search_family_id(query = "Anguillidae") 30 | 31 | ##Search taxon IDs via familyID 32 | taxonid <- search_taxon_id(query = familyid$Anguillidae$data$record_id,name = "familyID") 33 | 34 | #Download detailed lists via species or infraspecies ID 35 | query <- taxonid[["3851c5311bed46c19529cb155d37aa9b"]][["data"]][["namecode"]] 36 | x <- search_checklist(query = query) 37 | str(x) 38 | } 39 | } 40 | \author{ 41 | Liuyong Ding \email{ly_ding@126.com} 42 | } 43 | -------------------------------------------------------------------------------- /man/search_family_id.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/search_family_id.R 3 | \name{search_family_id} 4 | \alias{search_family_id} 5 | \title{Search family IDs} 6 | \usage{ 7 | search_family_id(query = NULL, start = 1, limit = 20, mc.cores = 2) 8 | } 9 | \arguments{ 10 | \item{query}{\code{character} One and more queries,support Family name, or part of family name, supports Latin and Chinese names.} 11 | 12 | \item{start}{\code{integer} Record number to start at. If omitted, the results are returned from the first record (start=1). Use in combination with limit to page through results. Note that we do the paging internally for you, but you can manually set the start parameter.} 13 | 14 | \item{limit}{\code{integer} Number of records to return, the default value is 20.} 15 | 16 | \item{mc.cores}{The number of cores to use, i.e. at most how many child processes will be run simultaneously. The option is initialized from environment variable MC_CORES if set. Must be at least one, and parallelization requires at least two cores,see \code{\link{mclapply}} for details.} 17 | } 18 | \value{ 19 | dataframe 20 | } 21 | \description{ 22 | Search family IDs via family name, supports Latin and Chinese names. 23 | } 24 | \details{ 25 | Visit the website \url{http://sp2000.org.cn/api/document} for more details 26 | } 27 | \examples{ 28 | \dontrun{ 29 | ##Set your key 30 | set_search_key("your apiKey",db = "sp2000") 31 | 32 | ##Search family IDs via family name 33 | familyid <- search_family_id(query = "Anguillidae") 34 | } 35 | } 36 | \author{ 37 | Liuyong Ding \email{ly_ding@126.com} 38 | } 39 | -------------------------------------------------------------------------------- /man/search_taxon_id.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/search_taxon_id.R 3 | \name{search_taxon_id} 4 | \alias{search_taxon_id} 5 | \title{Search taxon IDs} 6 | \format{ 7 | query: 8 | \describe{ 9 | \item{taxonIDs}{an array of species' ids} 10 | \item{familyID}{family ID, unique value} 11 | \item{scientificName}{the scientific name, or part of the scientific name, supports Latin names and Chinese} 12 | \item{commonName}{common name, or part of common name} 13 | } 14 | } 15 | \usage{ 16 | search_taxon_id( 17 | query = NULL, 18 | name = "scientificName", 19 | start = 1, 20 | limit = 20, 21 | mc.cores = 2 22 | ) 23 | } 24 | \arguments{ 25 | \item{query}{\code{string} familyID ,scientificName or commonName.} 26 | 27 | \item{name}{\code{character} name = c("familyID","scientificName","commonName"),the default value is "scientificName".} 28 | 29 | \item{start}{\code{intenger} Record number to start at. If omitted, the results are returned from the first record (start=1). Use in combination with limit to page through results. Note that we do the paging internally for you, but you can manually set the start parameter.} 30 | 31 | \item{limit}{\code{intenger} Number of records to return. This is passed across all sources,when you first query, set the limit to something smallish so that you can get a result quickly, then do more as needed.} 32 | 33 | \item{mc.cores}{The number of cores to use, i.e. at most how many child processes will be run simultaneously. The option is initialized from environment variable MC_CORES if set. Must be at least one, and parallelization requires at least two cores,see \code{\link{mclapply}} for details.} 34 | } 35 | \value{ 36 | dataframe 37 | } 38 | \description{ 39 | Search taxon IDs via familyID ,scientificName and commonName. 40 | } 41 | \details{ 42 | Visit the website \url{http://sp2000.org.cn/api/document} for more details 43 | } 44 | \examples{ 45 | \dontrun{ 46 | ##Set your key 47 | set_search_key("your apiKey",db = "sp2000") 48 | 49 | ##Search family IDs via family name 50 | familyid <- search_family_id(query = "Anguillidae") 51 | 52 | ##Search taxon IDs via familyID 53 | taxonid <- search_taxon_id(query = familyid$Anguillidae$data$record_id,name = "familyID") 54 | 55 | } 56 | } 57 | \author{ 58 | Liuyong Ding \email{ly_ding@126.com} 59 | } 60 | -------------------------------------------------------------------------------- /man/zoology_dbase_name.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/zoology_dbase_name.R 3 | \name{zoology_dbase_name} 4 | \alias{zoology_dbase_name} 5 | \title{Query details of species in China Animal Scientific Database} 6 | \format{ 7 | China Animal Scientific Database 8 | \describe{ 9 | \item{1}{Chinese zoology database} 10 | \item{2}{China Animal Map Database} 11 | \item{3}{China Economic Animal Database} 12 | \item{4}{Chinese Bird Database} 13 | \item{5}{Chinese Mammal Database} 14 | \item{6}{China Butterfly Database} 15 | \item{7}{Chinese Bee Database} 16 | \item{8}{China Inland Water Fish Database} 17 | \item{9}{Chinese Amphibian Database} 18 | \item{10}{Chinese Reptile database} 19 | \item{...}{allow additional more databases to be used} 20 | } 21 | } 22 | \usage{ 23 | zoology_dbase_name() 24 | } 25 | \value{ 26 | A collection of names for all China animal scientific databases 27 | } 28 | \description{ 29 | Query the database name and return a collection of names for all databases. 30 | } 31 | \details{ 32 | Visit the website \url{http://zoology.especies.cn} for more details. 33 | } 34 | \examples{ 35 | \dontrun{ 36 | ##Set your key 37 | set_search_key("your apiKey",db = "zoology") 38 | 39 | #Query China Animal Scientific Database lists 40 | zoology_dbase_name() 41 | } 42 | } 43 | \references{ 44 | \url{http://zoology.especies.cn} 45 | } 46 | \author{ 47 | Liuyong Ding \email{ly_ding@126.com} 48 | 49 | Ke Yang \email{ydyangke@163.com} 50 | } 51 | -------------------------------------------------------------------------------- /man/zoology_description.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/zoology_description.R, 3 | % R/zoology_description_type.R 4 | \name{zoology_description} 5 | \alias{zoology_description} 6 | \alias{zoology_description_type} 7 | \title{Query details of species in China Animal Scientific Database} 8 | \usage{ 9 | zoology_description(query, dbname, destype) 10 | 11 | zoology_description_type(query, dbname) 12 | } 13 | \arguments{ 14 | \item{query}{\code{string} The string to query for scientific names.} 15 | 16 | \item{dbname}{\code{integer} There is one required parameter, a single numeric that indicates which China animal scientific database to use. Details in \code{\link{zoology_dbase_name}} for the list of available databases.} 17 | 18 | \item{destype}{\code{integer} There is one required parameter, a single numeric that indicates which description type information to use. Details in \code{\link{zoology_description}} for the list of available description type information based on the species name and database name.} 19 | } 20 | \value{ 21 | details of species in China Animal Scientific Database 22 | 23 | description type information 24 | } 25 | \description{ 26 | Query the description information based on the species name, database name, and description type. 27 | 28 | Query the description type information based on the species name and database name. 29 | } 30 | \details{ 31 | Visit the website \url{http://zoology.especies.cn} for more details. 32 | 33 | Visit the website \url{http://zoology.especies.cn} for more details. 34 | } 35 | \examples{ 36 | \dontrun{ 37 | ##Set your key 38 | set_search_key("your apiKey",db = "zoology") 39 | 40 | ##Query details of species in Chinese Bird Database 41 | zoology_description(query = "Aix galericulata",dbname = 4,destype = 209) 42 | } 43 | \dontrun{ 44 | ##Set your key 45 | set_search_key("your apiKey",db = "zoology") 46 | 47 | ##Query description type information of Chinese Bird Database 48 | zoology_description_type(query = "Aix galericulata",dbname = 4) 49 | } 50 | } 51 | \author{ 52 | Liuyong Ding \email{ly_ding@126.com} 53 | 54 | Liuyong Ding \email{ly_ding@126.com} 55 | } 56 | --------------------------------------------------------------------------------