% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get_boldid.R
\name{get_boldid}
\alias{get_boldid}
\alias{as.boldid}
\alias{as.boldid.boldid}
\alias{as.boldid.character}
\alias{as.boldid.list}
\alias{as.boldid.numeric}
\alias{as.boldid.data.frame}
\alias{as.data.frame.boldid}
\alias{get_boldid_}
\title{Get the BOLD (Barcode of Life) code for a search term.}
\usage{
get_boldid(
  searchterm,
  fuzzy = FALSE,
  dataTypes = "basic",
  includeTree = FALSE,
  ask = TRUE,
  messages = TRUE,
  rows = NA,
  rank = NULL,
  division = NULL,
  parent = NULL,
  ...
)

as.boldid(x, check = TRUE)

\method{as.boldid}{boldid}(x, check = TRUE)

\method{as.boldid}{character}(x, check = TRUE)

\method{as.boldid}{list}(x, check = TRUE)

\method{as.boldid}{numeric}(x, check = TRUE)

\method{as.boldid}{data.frame}(x, check = TRUE)

\method{as.data.frame}{boldid}(x, ...)

get_boldid_(
  searchterm,
  messages = TRUE,
  fuzzy = FALSE,
  dataTypes = "basic",
  includeTree = FALSE,
  rows = NA,
  ...
)
}
\arguments{
\item{searchterm}{character; A vector of scientific names. Or,
a \code{taxon_state} object (see \link{taxon-state})}

\item{fuzzy}{(logical) Whether to use fuzzy search or not (default: FALSE).}

\item{dataTypes}{(character) Specifies the datatypes that will be returned.
See \code{\link[=bold_search]{bold_search()}} for options.}

\item{includeTree}{(logical) If TRUE (default: FALSE), returns a list
containing information for parent taxa as well as the specified taxon.}

\item{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.}

\item{messages}{logical; should progress be printed?}

\item{rows}{numeric; Any number from 1 to infinity. 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 \code{\link[=get_boldid_]{get_boldid_()}} to get back all, or a subset,
of the raw data that you are presented during the ask process.}

\item{rank}{(character) A taxonomic rank name. See \code{\link[=rank_ref]{rank_ref()}} for possible
options. Though note that some data sources use atypical ranks, so inspect the
data itself for options. Optional. See \code{Filtering} below.}

\item{division}{(character) A division (aka phylum) name. Optional. See \code{Filtering}
below.}

\item{parent}{(character) A parent name (i.e., the parent of the target search
taxon). Optional. See \code{Filtering} below.}

\item{...}{Curl options passed on to \code{\link[crul:verb-GET]{crul::verb-GET}}}

\item{x}{Input to \code{\link[=as.boldid]{as.boldid()}}}

\item{check}{logical; Check if ID matches any existing on the DB, only used in
\code{\link[=as.boldid]{as.boldid()}}}
}
\value{
A vector of taxonomic identifiers as an S3 class.
If a taxon is not found an \code{NA} is given. If more than one identifier
is found the function asks for user input if \code{ask = TRUE}, otherwise
returns \code{NA}. If \code{ask=FALSE} and \code{rows} does not equal
\code{NA}, then a data.frame is given back, but not of the uid class, which
you can't pass on to other functions as you normally can.

See \code{\link{get_id_details}} for further details including
attributes and exceptions
}
\description{
Get the BOLD (Barcode of Life) code for a search term.
}
\section{Filtering}{

The parameters \code{division}, \code{parent}, and \code{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 \code{\link[=grep]{grep()}} internally to match. Filtering narrows
down to the set that matches your query, and removes the rest.
}

\examples{
\dontrun{
get_boldid(searchterm = "Agapostemon")
get_boldid(searchterm = "Chironomus riparius")
get_boldid(c("Chironomus riparius","Quercus douglasii"))
splist <- names_list('species')
get_boldid(splist, messages=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)

# found
get_boldid('Epicordulia princeps')
get_boldid('Arigomphus furcifer')

# When not found
get_boldid("howdy")
get_boldid(c("Chironomus riparius", "howdy"))
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 = "Plantae")
get_boldid("Satyrium", division = "Animalia")

## 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)
}
}
\seealso{
\code{\link[=classification]{classification()}}

Other taxonomic-ids: 
\code{\link{get_eolid}()},
\code{\link{get_gbifid}()},
\code{\link{get_ids}()},
\code{\link{get_iucn}()},
\code{\link{get_natservid}()},
\code{\link{get_nbnid}()},
\code{\link{get_pow}()},
\code{\link{get_tolid}()},
\code{\link{get_tpsid}()},
\code{\link{get_tsn}()},
\code{\link{get_uid}()},
\code{\link{get_wiki}()},
\code{\link{get_wormsid}()}
}
\concept{taxonomic-ids}
