Skip to content

Commit

Permalink
ran through all egs, fixed any not working
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Jun 13, 2015
1 parent 54bc65d commit 8885e5c
Show file tree
Hide file tree
Showing 31 changed files with 50 additions and 271 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export(itis_name)
export(itis_native)
export(itis_ping)
export(itis_refs)
export(itis_searchcommon)
export(itis_taxrank)
export(itis_terms)
export(iucn_getname)
Expand Down
1 change: 1 addition & 0 deletions R/children.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#' children("Poa", db = 'col', rows=1)
#'
#' # use curl options
#' library("httr")
#' res <- children("Poa", db = 'col', rows=1, config=verbose())
#' res <- children("Salmo", db = 'itis', config=verbose())
#' res <- children("Salmo", db = 'ncbi', config=verbose())
Expand Down
20 changes: 0 additions & 20 deletions R/col_classification.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,6 @@
#' @export
#' @rdname col_classification-defunct
#' @keywords internal
#' @examples \dontrun{
#' # A basic example
#' col_classification(name="Apis")
#'
#' # An example where there is no classification
#' col_classification(id=11935941)
#'
#' # Use a specific year's checklist
#' col_classification(name="Apis", checklist="2012")
#' col_classification(name="Apis", checklist="2009")
#'
#' # Pass in many names or many id's
#' out <- col_classification(name=c("Buteo","Apis","Accipiter","asdf"),
#' checklist="2012")
#' out$Apis # get just the output you want
#' ldply(out) # or combine to one data.frame
#'
#' # Use get_colid to pass in ID directly
#' col_classification(id=get_colid(sciname='Puma concolor'))
#' }
col_classification <- function(name=NULL, id=NULL, format=NULL, start=NULL, checklist=NULL)
{
.Defunct(msg="This function is defunct. See classification().")
Expand Down
34 changes: 23 additions & 11 deletions R/col_search.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Search Catalogue of Life for taxonomic IDs
#'
#' @import RCurl XML plyr
#' @import XML plyr
#' @export
#' @param name The string to search for. Only exact matches found the name given
#' will be returned, unless one or wildcards are included in the search
Expand Down Expand Up @@ -77,11 +77,17 @@ parse_full <- function(x) {
taxize_ldfast(lapply(tmp, function(z) {
switch(xpathSApply(z, "name_status", xmlValue),
`accepted name` = {
h_vals <- xpathSApply(z, "classification//name", xmlValue)
h_nms <- xpathSApply(z, "classification//rank", xmlValue)
h <- setNames(rbind.data.frame(h_vals), h_nms)
rank <- xpathSApply(z, "rank", xmlValue)
id <- xpathSApply(z, "id", xmlValue)
if (xpathSApply(z, "classification", xmlValue) == "") {
h <- parse_terse(z)
rank <- xpathSApply(z, "rank", xmlValue)
id <- xpathSApply(z, "id", xmlValue)
} else {
h_vals <- xpathSApply(z, "classification//name", xmlValue)
h_nms <- xpathSApply(z, "classification//rank", xmlValue)
h <- setNames(rbind.data.frame(h_vals), h_nms)
rank <- xpathSApply(z, "rank", xmlValue)
id <- xpathSApply(z, "id", xmlValue)
}
},
`common name` = {
h_vals <- xpathSApply(z, "accepted_name//classification//name", xmlValue)
Expand All @@ -91,11 +97,17 @@ parse_full <- function(x) {
id <- xpathSApply(z, "accepted_name/id", xmlValue)
},
synonym = {
h_vals <- xpathSApply(z, "accepted_name//classification//name", xmlValue)
h_nms <- xpathSApply(z, "accepted_name//classification//rank", xmlValue)
h <- setNames(rbind.data.frame(h_vals), h_nms)
rank <- xpathSApply(z, "accepted_name/rank", xmlValue)
id <- xpathSApply(z, "accepted_name/id", xmlValue)
if (length(xpathSApply(z, "classification")) == 0) {
h <- parse_terse(z)
rank <- xpathSApply(z, "rank", xmlValue)
id <- xpathSApply(z, "id", xmlValue)
} else {
h_vals <- xpathSApply(z, "accepted_name//classification//name", xmlValue)
h_nms <- xpathSApply(z, "accepted_name//classification//rank", xmlValue)
h <- setNames(rbind.data.frame(h_vals), h_nms)
rank <- xpathSApply(z, "accepted_name/rank", xmlValue)
id <- xpathSApply(z, "accepted_name/id", xmlValue)
}
}
)
target <- setNames(rbind.data.frame(
Expand Down
4 changes: 0 additions & 4 deletions R/eol_hierarchy.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
#' @export
#' @rdname eol_hierarchy-defunct
#' @keywords internal
#' @examples \dontrun{
#' # Using get_eolid
#' eol_hierarchy(get_eolid(sciname='Poa annua'))
#' }
eol_hierarchy <- function(taxonid, common_names = NULL, synonyms = NULL,
key = NULL, callopts=list())
{
Expand Down
18 changes: 0 additions & 18 deletions R/eol_invasive.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,6 @@
#' @references See info for each data source at \url{http://eol.org/collections/55367/taxa}
#' @rdname eol_invasive-defunct
#' @keywords internal
#'
#' @examples \dontrun{
#' eol_invasive(name='Brassica oleracea', dataset='gisd')
#' eol_invasive(name=c('Lymantria dispar','Cygnus olor','Hydrilla verticillata','Pinus concolor'),
#' dataset='gisd')
#' eol_invasive(name='Sargassum', dataset='gisd')
#' eol_invasive(name='Ciona intestinalis', dataset='mineps')
#' eol_invasive(name=c('Lymantria dispar','Cygnus olor','Hydrilla verticillata','Pinus concolor'),
#' dataset='i3n')
#' eol_invasive(name=c('Branta canadensis','Gallus gallus','Myiopsitta monachus'),
#' dataset='daisie')
#' eol_invasive(name=c('Branta canadensis','Gallus gallus','Myiopsitta monachus'), dataset='isc')
#'
#' # Count
#' eol_invasive(name=c('Lymantria dispar','Cygnus olor','Hydrilla verticillata','Pinus concolor'),
#' dataset='gisd', count = TRUE)
#' }

eol_invasive <- function(name = NULL, dataset="all", searchby = grep, page=NULL,
per_page=NULL, key = NULL, verbose=TRUE, count=FALSE, ...) {

Expand Down
15 changes: 10 additions & 5 deletions R/get_ubioid.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,15 @@ get_ubioid <- function(searchterm, searchtype = "scientific", ask = TRUE, verbos
ubio_df <- switch(searchtype,
scientific = ubio_df[,c("namebankid","namestring","packagename","rankname")],
vernacular = ubio_df[,c("namebankid","namestring","packagename")])
ubio_df <- rename(ubio_df, c('packagename' = 'family', 'rankname' = 'rank',
'namebankid' = 'ubioid'))
ubio_df <- fix_ranks(ubio_df)
if (searchtype == "scientific") {
ubio_df <- rename(ubio_df, c('packagename' = 'family',
'rankname' = 'rank',
'namebankid' = 'ubioid'))
} else {
ubio_df <- rename(ubio_df, c('packagename' = 'family',
'namebankid' = 'ubioid'))
}
if (searchtype == "scientific") ubio_df <- fix_ranks(ubio_df)

direct <- NA
# should return NA if spec not found
Expand Down Expand Up @@ -176,10 +182,9 @@ get_ubioid <- function(searchterm, searchtype = "scientific", ask = TRUE, verbos

if (!is.null(family) || !is.null(rank)) {
ubio_df <- filt(ubio_df, "family", family)
ubio_df <- filt(ubio_df, "rank", rank)
if (searchtype == "scientific") ubio_df <- filt(ubio_df, "rank", rank)
ubioid <- id <- ubio_df$ubioid
if (length(id) == 1) {
rank_taken <- as.character(ubio_df$rank)
att <- "found"
}
}
Expand Down
8 changes: 0 additions & 8 deletions R/gisd_isinvasive.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@
#' @seealso \code{eol_invasive}
#' @rdname gisd_invasive-defunct
#' @keywords internal
#' @examples \dontrun{
#' sp <- c("Carpobrotus edulis", "Rosmarinus officinalis")
#' ## first species is invasive, second one is not.
#' gisd_isinvasive(sp)
#' gisd_isinvasive(sp, simplify = TRUE)
#' }
#'

gisd_isinvasive <- function(x, simplify = FALSE, verbose=TRUE)
{
.Defunct("g_invasive", "traits", msg = "This function is defunct. See traits::g_invasive()")
Expand Down
1 change: 1 addition & 0 deletions R/itis.R
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ searchbycommonname <- function(x, ...) {

#' Searches common name and acts as thin wrapper around \code{searchbycommonnamebeginswith} and \code{searchbycommonnameendswith}
#'
#' @export
#' @param x Search terms
#' @param from Default is to search from beginning. Use \code{end} to serch from end.
#' @param ... Curl options passed on to \code{\link[httr]{GET}}
Expand Down
2 changes: 1 addition & 1 deletion R/nbn_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#'
#' @examples \dontrun{
#' nbn_search(q = "blackbird")
#' nbn_search(q = "blackbird", start = TRUE)
#' nbn_search(q = "blackbird", start = 4)
#' nbn_search(q = "blackbird", all = TRUE)
#' nbn_search(q = "blackbird", taxonOutputGroupKey = "NHMSYS0000080039")
#'
Expand Down
7 changes: 0 additions & 7 deletions R/ncbi_getbyid.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
#' @author Scott Chamberlain \email{myrmecocystus@@gmail.com}
#' @rdname ncbi_getbyid-defunct
#' @keywords internal
#' @examples \dontrun{
#' # A single gene
#' ncbi_getbyid(ids="360040093", format="fasta")
#'
#' # Many genes (with different accession numbers)
#' ncbi_getbyid(ids=c("360040093","347448433"), format="fasta")
#' }
ncbi_getbyid <- function(ids, format="fasta", verbose=TRUE)
{
.Defunct("ncbi_byid", "traits", msg="This function is defunct. See traits::ncbi_byid()")
Expand Down
8 changes: 0 additions & 8 deletions R/ncbi_getbyname.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
#' @author Scott Chamberlain \email{myrmecocystus@@gmail.com}
#' @rdname ncbi_getbyname-defunct
#' @keywords internal
#' @examples \dontrun{
#' # A single species
#' ncbi_getbyname(taxa="Acipenser brevirostrum")
#'
#' # Many species
#' species <- c("Colletes similis","Halictus ligatus","Perdita trisignata")
#' ncbi_getbyname(taxa=species, gene = c("coi", "co1"), seqrange = "1:2000")
#' }
ncbi_getbyname <- function(taxa, gene="COI", seqrange="1:3000", getrelated=FALSE,
verbose=TRUE)
{
Expand Down
32 changes: 0 additions & 32 deletions R/ncbi_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,6 @@
#' \email{zacharyfoster1989@@gmail.com}
#' @rdname ncbi_search-defunct
#' @keywords internal
#' @examples \dontrun{
#' # A single species
#' out <- ncbi_search(taxa="Umbra limi", seqrange = "1:2000")
#' # Get the same species information using a taxonomy id
#' out <- ncbi_search(id = "75935", seqrange = "1:2000")
#' # If the taxon name is unique, using the taxon name and id are equivalent
#' all(ncbi_search(id = "75935") == ncbi_search(taxa="Umbra limi"))
#' # If the taxon name is not unique, use taxon id
#' # "266948" is the uid for the butterfly genus, but there is also a genus of orchids with the
#' # same name
#' nrow(ncbi_search(id = "266948")) == nrow(ncbi_search(taxa="Satyrium"))
#' # get list of genes available, removing non-unique
#' unique(out$gene_desc)
#' # does the string 'RAG1' exist in any of the gene names
#' out[grep("RAG1", out$gene_desc, ignore.case=TRUE),]
#'
#' # A single species without records in NCBI
#' out <- ncbi_search(taxa="Sequoia wellingtonia", seqrange="1:2000", getrelated=TRUE)
#'
#' # Many species, can run in parallel or not using plyr
#' species <- c("Salvelinus alpinus","Ictalurus nebulosus","Carassius auratus")
#' out2 <- ncbi_search(taxa=species, seqrange = "1:2000")
#' lapply(out2, head) # see heads of all
#' library("plyr")
#' out2df <- ldply(out2) # make data.frame of all
#' unique(out2df$gene_desc) # get list of genes available, removing non-unique
#' out2df[grep("60S ribosomal protein", out2df$gene_desc, ignore.case=TRUE),] # search across all
#'
#' # Using the getrelated and entrez_query options
#' ncbi_search(taxa = "Olpidiopsidales", limit = 5, getrelated = TRUE,
#' entrez_query = "18S[title] AND 28S[title]")
#' }
#' @export
ncbi_search <- function(taxa = NULL, id = NULL, seqrange="1:3000", getrelated=FALSE, limit = 500,
entrez_query = NULL, hypothetical = FALSE, verbose=TRUE)
Expand Down
4 changes: 3 additions & 1 deletion R/phylomatic_tree.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@
#' # names, so there's no per se rule), you will get an error when using \code{get='GET'},
#' # when that happens use \code{get='POST'}
#' spp <- names_list("species", 200)
#' (out <- phylomatic_tree(taxa = spp, get = "GET"))
#' # (out <- phylomatic_tree(taxa = spp, get = "GET"))
#' (out <- phylomatic_tree(taxa = spp, get = "POST"))
#' plot(out)
#'
#' # Pass in a tree from a URL on the web
#' spp <- c('Abies amabilis','Abies balsamea','Abies bracteata','Abies concolor','Abies fraseri',
#' 'Abies grandis','Abies lasiocarpa','Abies magnifica','Abies procera','Acacia berlandieri')
#' spp <- c('Pinus koraiensis', 'Pinus sibirica', 'Pinus albicaulis', 'Pinus lambertiana',
#' 'Pinus bungeana', 'Pinus strobus', 'Pinus_cembra')
#' url <- "http://datadryad.org/bitstream/handle/10255/dryad.8791/final_tree.tre?sequence=1"
#' phylomatic_tree(taxa=spp, treeuri=url)
#'
Expand Down
7 changes: 2 additions & 5 deletions R/tnrs.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@
#' @details If there is no match in the Taxosaurus database, nothing is
#' returned, so youwill not get anything back for non matches.
#' @examples \dontrun{
#' # Default, uses GET curl method, you can't specify any other parameters when
#' using GET
#' mynames <- c("Panthera tigris", "Neotamias minimus", "Magnifera indica")
#' tnrs(query = mynames)
#'
#' # Default, uses GET curl method, you can't specify any other
#' # parameters when using GET
#' # Specifying the source to match against
#' mynames <- c("Helianthus annuus", "Poa annua")
#' tnrs(query = mynames, source = "iPlant_TNRS")
Expand Down
5 changes: 0 additions & 5 deletions R/tp_classification.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
#' @export
#' @rdname tp_classification-defunct
#' @keywords internal
#' @examples \dontrun{
#' tp_classification(id = 25509881)
#' tp_classification(id = c(25509881,2700851))
#' tp_classification(id = c(25509881,2700851), callopts=verbose())
#' }
tp_classification <- function(id=NULL, key=NULL, callopts=list())
{
.Defunct(msg="This function is defunct. See classification().")
Expand Down
11 changes: 0 additions & 11 deletions R/tpl_search.r
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@
#' @param ... Further arguments passed on to the TPL or TPLck function of Taxonstand.
#' See \code{TPL} and \code{TPLck} for arguments.
#' @seealso \code{\link[taxize]{tpl_get}}, \code{\link[taxize]{tpl_families}}
#' @examples \dontrun{
#' # Regular non-parallel
#' splist <- c("Heliathus annuus","Abies procera","Poa annua",
#' "Platanus occidentalis","Carex abrupta","Arctostaphylos canescens",
#' "Ocimum basilicum","Vicia faba","Quercus kelloggii","Lactuca serriola")
#' tpl_search(taxon = splist)
#'
#' # Use more arguments within TPLck
#' tpl_search(taxon = "Microbryum curvicollum", corr = TRUE)
#' tpl_search(taxon = "Microbryum curvicollum", corr = TRUE, max.distance=5)
#' }
#' @export
#' @rdname tpl_search-defunct
tpl_search <- function(taxon, paral = FALSE, ...) {
Expand Down
1 change: 1 addition & 0 deletions man/children.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ children("Poa", db = 'col')
children("Poa", db = 'col', rows=1)
# use curl options
library("httr")
res <- children("Poa", db = 'col', rows=1, config=verbose())
res <- children("Salmo", db = 'itis', config=verbose())
res <- children("Salmo", db = 'ncbi', config=verbose())
Expand Down
22 changes: 0 additions & 22 deletions man/col_classification-defunct.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,5 @@ THIS FUNCTION IS DEFUNCT.
You must provide one of name or id. The other parameters (format
and start) are optional.
}
\examples{
\dontrun{
# A basic example
col_classification(name="Apis")

# An example where there is no classification
col_classification(id=11935941)

# Use a specific year's checklist
col_classification(name="Apis", checklist="2012")
col_classification(name="Apis", checklist="2009")

# Pass in many names or many id's
out <- col_classification(name=c("Buteo","Apis","Accipiter","asdf"),
checklist="2012")
out$Apis # get just the output you want
ldply(out) # or combine to one data.frame

# Use get_colid to pass in ID directly
col_classification(id=get_colid(sciname='Puma concolor'))
}
}
\keyword{internal}

6 changes: 0 additions & 6 deletions man/eol_hierarchy-defunct.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,5 @@ THIS FUNCTION IS DEFUNCT.
It's possible to return JSON or XML with the EOL API. However,
this function only returns JSON for now.
}
\examples{
\dontrun{
# Using get_eolid
eol_hierarchy(get_eolid(sciname='Poa annua'))
}
}
\keyword{internal}
18 changes: 0 additions & 18 deletions man/eol_invasive-defunct.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,6 @@ Datasets are not updated that often. Here's last updated dates for some of the d
\item mineps updated 1 yr ago
}
}
\examples{
\dontrun{
eol_invasive(name='Brassica oleracea', dataset='gisd')
eol_invasive(name=c('Lymantria dispar','Cygnus olor','Hydrilla verticillata','Pinus concolor'),
dataset='gisd')
eol_invasive(name='Sargassum', dataset='gisd')
eol_invasive(name='Ciona intestinalis', dataset='mineps')
eol_invasive(name=c('Lymantria dispar','Cygnus olor','Hydrilla verticillata','Pinus concolor'),
dataset='i3n')
eol_invasive(name=c('Branta canadensis','Gallus gallus','Myiopsitta monachus'),
dataset='daisie')
eol_invasive(name=c('Branta canadensis','Gallus gallus','Myiopsitta monachus'), dataset='isc')
# Count
eol_invasive(name=c('Lymantria dispar','Cygnus olor','Hydrilla verticillata','Pinus concolor'),
dataset='gisd', count = TRUE)
}
}
\references{
See info for each data source at \url{http://eol.org/collections/55367/taxa}
}
Expand Down
Loading

0 comments on commit 8885e5c

Please sign in to comment.