Learn R Programming

taxize (version 0.6.0)

get_boldid: Get the BOLD (Barcode of Life) code for a search term.

Description

Get the BOLD (Barcode of Life) code for a search term.

Usage

get_boldid(searchterm, fuzzy = FALSE, dataTypes = "basic",
  includeTree = FALSE, ask = TRUE, verbose = TRUE, rows = NA,
  rank = NULL, division = NULL, parent = NULL, ...)

as.boldid(x, check = TRUE)

## S3 method for class 'boldid': as.boldid(x, check = TRUE)

## S3 method for class 'character': as.boldid(x, check = TRUE)

## S3 method for class 'list': as.boldid(x, check = TRUE)

## S3 method for class 'numeric': as.boldid(x, check = TRUE)

## S3 method for class 'data.frame': as.boldid(x, check = TRUE)

## S3 method for class 'boldid': as.data.frame(x, ...)

get_boldid_(searchterm, verbose = TRUE, fuzzy = FALSE, dataTypes = "basic", includeTree = FALSE, rows = NA, ...)

Arguments

searchterm
character; A vector of common or scientific names.
fuzzy
(logical) Whether to use fuzzy search or not (default: FALSE).
dataTypes
(character) Specifies the datatypes that will be returned. See Details for options.
includeTree
(logical) If TRUE (default: FALSE), returns a list containing information for parent taxa as well as the specified taxon.
ask
logical; should get_tsn be run in interactive mode? If TRUE and more than one TSN is found for teh species, the user is asked for input. If FALSE NA is returned for multiple matches.
verbose
logical; should progress be printed?
rows
numeric; Any number from 1 to inifity. If the default NA, all rows are considered. Note that this function still only gives back a boldid class object with one to many identifiers. See get_boldid_
rank
(character) A taxonomic rank name. See rank_ref for possible options. Though note that some data sources use atypical ranks, so inspect the data itself for options. Optional. See Filtering bel
division
(character) A division (aka phylum) name. Optional. See Filtering below.
parent
(character) A parent name (i.e., the parent of the target search taxon). Optional. See Filtering below.
...
Curl options passed on to GET
x
Input to as.boldid
check
logical; Check if ID matches any existing on the DB, only used in as.boldid

Value

  • A vector of BOLD ids. If a taxon is not found NA. If more than one BOLD ID is found the function asks for user input (if ask = TRUE), otherwise returns NA. Comes with an attribute match to investigate the reason for NA (either 'not found', 'found' or if ask = FALSE 'multi match')

Filtering

The parameters division, parent, and rank are not used in the search to the data provider, but are used in filtering the data down to a subset that is closer to the target you want. For all these parameters, you can use regex strings since we use grep internally to match.

See Also

get_uid, classification

Examples

Run this code
get_boldid(searchterm = "Agapostemon")
get_boldid(searchterm = "Chironomus riparius")
get_boldid(c("Chironomus riparius","Quercus douglasii"))
splist <- names_list('species')
get_boldid(splist, verbose=FALSE)

# Fuzzy searching
get_boldid(searchterm="Osmi", fuzzy=TRUE)

# Get back a subset
get_boldid(searchterm="Osmi", fuzzy=TRUE, rows = 1)
get_boldid(searchterm="Osmi", fuzzy=TRUE, rows = 1:10)
get_boldid(searchterm=c("Osmi","Aga"), fuzzy=TRUE, rows = 1)
get_boldid(searchterm=c("Osmi","Aga"), fuzzy=TRUE, rows = 1:3)

# When not found
get_boldid("howdy")
get_boldid(c("Chironomus riparius", "howdy"))
get_boldid('Epicordulia princeps')
get_boldid('Arigomphus furcifer')
get_boldid("Cordulegaster erronea")
get_boldid("Nasiaeshna pentacantha")

# Narrow down results to a division or rank, or both
## Satyrium example
### Results w/o narrowing
get_boldid("Satyrium")
### w/ phylum
get_boldid("Satyrium", division = "Plants")
get_boldid("Satyrium", division = "Animals")

## Rank example
get_boldid("Osmia", fuzzy = TRUE)
get_boldid("Osmia", fuzzy = TRUE, rank = "genus")

# Fuzzy filter on any filtering fields
## uses grep on the inside
get_boldid("Satyrium", division = "anim")
get_boldid("Aga", fuzzy = TRUE, parent = "*idae")

# Convert a boldid without class information to a boldid class
as.boldid(get_boldid("Agapostemon")) # already a boldid, returns the same
as.boldid(get_boldid(c("Agapostemon","Quercus douglasii"))) # same
as.boldid(1973) # numeric
as.boldid(c(1973,101009,98597)) # numeric vector, length > 1
as.boldid("1973") # character
as.boldid(c("1973","101009","98597")) # character vector, length > 1
as.boldid(list("1973","101009","98597")) # list, either numeric or character
## dont check, much faster
as.boldid("1973", check=FALSE)
as.boldid(1973, check=FALSE)
as.boldid(c("1973","101009","98597"), check=FALSE)
as.boldid(list("1973","101009","98597"), check=FALSE)

(out <- as.boldid(c(1973,101009,98597)))
data.frame(out)
as.boldid( data.frame(out) )

# Get all data back
get_boldid_("Osmia", fuzzy=TRUE, rows=1:5)
get_boldid_("Osmia", fuzzy=TRUE, rows=1)
get_boldid_(c("Osmi","Aga"), fuzzy=TRUE, rows = 1:3)

# Curl options
library("httr")
get_boldid(searchterm = "Agapostemon", config=verbose())
get_boldid(searchterm = "Agapostemon", config=progress())

# use curl options
library("httr")
get_boldid("Agapostemon", config=verbose())
bb <- get_boldid("Agapostemon", config=progress())

Run the code above in your browser using DataLab