ropensci / bold
Showing 11 of 85 files from the diff.
Other files ignored by Codecov
LICENSE has changed.
Makefile has changed.
R/bold-package.R has changed.
man/bold_stats.Rd has changed.
revdep/check.R has changed.
.gitignore has changed.
.Rbuildignore has changed.
revdep/README.md has changed.
codemeta.json has changed.
man/bold_seq.Rd has changed.
inst/vign/bold.md was deleted.
man/bold_trace.Rd has changed.
LICENSE.md is new.
man/sequences.Rd has changed.
README.Rmd has changed.
README.md has changed.
appveyor.yml was deleted.
DESCRIPTION has changed.
NEWS.md has changed.
cran-comments.md has changed.
.travis.yml was deleted.

@@ -4,11 +4,11 @@
Loading
4 4
#' @inheritParams bold_specimens
5 5
#' @param dataType (character) one of "overview" or "drill_down" (default).
6 6
#' "drill_down": a detailed summary of information which provides record 
7 -
#' counts by [BINs, Country, Storing Institution, Species]. "overview": 
8 -
#' the total counts of [BINs, Countries, Storing Institutions, Orders, 
9 -
#' Families, Genus, Species]
7 +
#' counts by (BINs, Country, Storing Institution, Species). "overview": 
8 +
#' the total counts of (BINs, Countries, Storing Institutions, Orders, 
9 +
#' Families, Genus, Species)
10 10
#' @references 
11 -
#' \url{http://v4.boldsystems.org/index.php/resources/api?type=webservices}
11 +
#' http://v4.boldsystems.org/index.php/resources/api?type=webservices
12 12
#'
13 13
#' @examples \dontrun{
14 14
#' x <- bold_stats(taxon='Osmia')

@@ -1,14 +1,13 @@
Loading
1 -
bbase <- function() 'http://v4.boldsystems.org/index.php/'
1 +
bbase <- function() 'https://v4.boldsystems.org/index.php/'
2 2
3 3
bc <- function(x) Filter(Negate(is.null), x)
4 4
5 5
split_fasta <- function(x){
6 -
  temp <- paste(">", x, sep = "")
7 -
  seq <- str_replace_all(str_split(str_replace(temp[[1]], "\n", "<<<"), 
8 -
                                   "<<<")[[1]][[2]], "\n", "")
9 -
  seq <- gsub("\\\r|\\\n", "", seq)
10 -
  stuff <- str_split(x, "\\|")[[1]][c(1:3)]
11 -
  list(id = stuff[1], name = stuff[2], gene = stuff[1], sequence = seq)
6 +
  tmp = as.data.frame(stringr::str_split_fixed(x, "\\\r\\\n", n = 3))
7 +
  df = cbind(as.data.frame(stringr::str_split_fixed(tmp[,1], "\\|", n = 4)), tmp[,2])
8 +
  colnames(df) = c("processid", "identification", "marker", "accession", "sequence")
9 +
  df[df==""] = NA
10 +
  return(df)
12 11
}
13 12
14 13
pipeornull <- function(x){

@@ -2,57 +2,57 @@
Loading
2 2
#'
3 3
#' @export
4 4
#' @param x (data.frame/list) list of data.frames - the output from a call to
5 -
#' \code{\link{bold_identify}}. or a single data.frame from the output from
6 -
#' same. required.
5 +
#' [bold_identify()]. or a single data.frame from the output from same.
6 +
#' required.
7 7
#' @param wide (logical) output in long or wide format. See Details.
8 -
#' Default: \code{FALSE}
8 +
#' Default: `FALSE`
9 9
#' @param taxid  (character) A taxid name. Optional. See `Filtering` below.
10 10
#' @param taxon (character) A taxon name. Optional. See `Filtering` below.
11 -
#' @param tax_rank (character) A tax_rank name. Optional. See `Filtering` 
11 +
#' @param tax_rank (character) A tax_rank name. Optional. See `Filtering`
12 12
#' below.
13 -
#' @param tax_division (character) A tax_division name. Optional. See 
13 +
#' @param tax_division (character) A tax_division name. Optional. See
14 14
#' `Filtering` below.
15 -
#' @param parentid (character) A parentid name. Optional. See `Filtering` 
15 +
#' @param parentid (character) A parentid name. Optional. See `Filtering`
16 16
#' below.
17 -
#' @param parentname (character) A parentname name. Optional. See `Filtering` 
17 +
#' @param parentname (character) A parentname name. Optional. See `Filtering`
18 18
#' below.
19 -
#' @param taxonrep (character) A taxonrep name. Optional. See `Filtering` 
19 +
#' @param taxonrep (character) A taxonrep name. Optional. See `Filtering`
20 20
#' below.
21 -
#' @param specimenrecords (character) A specimenrecords name. Optional. 
21 +
#' @param specimenrecords (character) A specimenrecords name. Optional.
22 22
#' See `Filtering` below.
23 -
#' @param ... Further args passed on to \code{\link[crul]{verb-GET}}, main 
23 +
#' @param ... Further args passed on to [crul::verb-GET], main
24 24
#' purpose being curl debugging
25 -
#' 
25 +
#'
26 26
#' @details This function gets unique set of taxonomic names from the input
27 -
#' data.frame, then queries \code{\link{bold_tax_name}} to get the
28 -
#' taxonomic ID, passing it to \code{\link{bold_tax_id}} to get the parent
27 +
#' data.frame, then queries [bold_tax_name()] to get the
28 +
#' taxonomic ID, passing it to [bold_tax_id()] to get the parent
29 29
#' names, then attaches those to the input data.
30 30
#'
31 31
#' Records in the input data that do not have matches for parent names
32 32
#' simply get NA values in the added columns.
33 33
#'
34 34
#' @section Filtering:
35 -
#' The parameters `taxid`, `taxon`, `tax_rank`, `tax_division`, 
36 -
#' `parentid`, `parentname`,`taxonrep`, and `specimenrecords` are not used 
37 -
#' in the search sent to BOLD, but are used in filtering the data down 
38 -
#' to a subset that is closer to the target you want. For all these 
39 -
#' parameters, you can use regex strings since we use [grep()] internally 
40 -
#' to match. Filtering narrows down to the set that matches your query, 
41 -
#' and removes the rest. The data.frame that we filter on with these 
35 +
#' The parameters `taxid`, `taxon`, `tax_rank`, `tax_division`,
36 +
#' `parentid`, `parentname`,`taxonrep`, and `specimenrecords` are not used
37 +
#' in the search sent to BOLD, but are used in filtering the data down
38 +
#' to a subset that is closer to the target you want. For all these
39 +
#' parameters, you can use regex strings since we use [grep()] internally
40 +
#' to match. Filtering narrows down to the set that matches your query,
41 +
#' and removes the rest. The data.frame that we filter on with these
42 42
#' parameters internally is the result of a call to the [bold_tax_name()]
43 -
#' function. 
44 -
#' 
43 +
#' function.
44 +
#'
45 45
#' @section wide vs long format:
46 -
#' When \code{wide = FALSE} you get many rows for each record. Essentially,
47 -
#' we \code{cbind} the taxonomic classification onto the one row from the
48 -
#' result of \code{\link{bold_identify}}, giving as many rows as there are
46 +
#' When `wide = FALSE` you get many rows for each record. Essentially,
47 +
#' we `cbind` the taxonomic classification onto the one row from the
48 +
#' result of [bold_identify()], giving as many rows as there are
49 49
#' taxa in the taxonomic classification.
50 50
#'
51 -
#' When \code{wide = TRUE} you get one row for each record - thus the
51 +
#' When `wide = TRUE` you get one row for each record - thus the
52 52
#' dimensions of the input data stay the same. For this option, we take just
53 53
#' the rows for taxonomic ID and name for each taxon in the taxonomic
54 54
#' classification, and name the columns by the taxon rank, so you get
55 -
#' \code{phylum} and \code{phylum_id}, and so on.
55 +
#' `phylum` and `phylum_id`, and so on.
56 56
#'
57 57
#' @return a list of the same length as the input
58 58
#'
@@ -68,40 +68,40 @@
Loading
68 68
#' out <- bold_identify_parents(df, wide = TRUE)
69 69
#' str(out)
70 70
#' head(out[[1]])
71 -
#' 
71 +
#'
72 72
#' x <- bold_seq(taxon = "Satyrium")
73 73
#' out <- bold_identify(c(x[[1]]$sequence, x[[13]]$sequence))
74 74
#' res <- bold_identify_parents(out)
75 75
#' res
76 -
#' 
76 +
#'
77 77
#' x <- bold_seq(taxon = 'Diplura')
78 78
#' out <- bold_identify(vapply(x, "[[", "", "sequence")[1:20])
79 79
#' res <- bold_identify_parents(out)
80 80
#' }
81 -
bold_identify_parents <- function(x, wide = FALSE, taxid = NULL, 
82 -
  taxon = NULL, tax_rank = NULL, tax_division = NULL, parentid = NULL, 
81 +
bold_identify_parents <- function(x, wide = FALSE, taxid = NULL,
82 +
  taxon = NULL, tax_rank = NULL, tax_division = NULL, parentid = NULL,
83 83
  parentname = NULL, taxonrep = NULL, specimenrecords = NULL, ...) {
84 84
  UseMethod("bold_identify_parents")
85 85
}
86 86
87 87
#' @export
88 -
bold_identify_parents.default <- function(x, wide = FALSE, taxid = NULL, 
89 -
  taxon = NULL, tax_rank = NULL, tax_division = NULL, parentid = NULL, 
88 +
bold_identify_parents.default <- function(x, wide = FALSE, taxid = NULL,
89 +
  taxon = NULL, tax_rank = NULL, tax_division = NULL, parentid = NULL,
90 90
  parentname = NULL, taxonrep = NULL, specimenrecords = NULL, ...) {
91 91
  stop("no 'bold_identify_parents' method for ", class(x)[1L], call. = FALSE)
92 92
}
93 93
94 94
#' @export
95 -
bold_identify_parents.data.frame <- function(x, wide = FALSE, taxid = NULL, 
96 -
  taxon = NULL, tax_rank = NULL, tax_division = NULL, parentid = NULL, 
95 +
bold_identify_parents.data.frame <- function(x, wide = FALSE, taxid = NULL,
96 +
  taxon = NULL, tax_rank = NULL, tax_division = NULL, parentid = NULL,
97 97
  parentname = NULL, taxonrep = NULL, specimenrecords = NULL, ...) {
98 -
  bold_identify_parents(list(x), wide, taxid, taxon, tax_rank, 
98 +
  bold_identify_parents(list(x), wide, taxid, taxon, tax_rank,
99 99
    tax_division, parentid, parentname, taxonrep, specimenrecords)
100 100
}
101 101
102 102
#' @export
103 -
bold_identify_parents.list <- function(x, wide = FALSE, taxid = NULL, 
104 -
  taxon = NULL, tax_rank = NULL, tax_division = NULL, parentid = NULL, 
103 +
bold_identify_parents.list <- function(x, wide = FALSE, taxid = NULL,
104 +
  taxon = NULL, tax_rank = NULL, tax_division = NULL, parentid = NULL,
105 105
  parentname = NULL, taxonrep = NULL, specimenrecords = NULL, ...) {
106 106
107 107
  assert(wide, "logical")

@@ -10,46 +10,45 @@
Loading
10 10
#' @param response (logical) Note that response is the object that returns
11 11
#' from the Curl call, useful for debugging, and getting detailed info on
12 12
#' the API call.
13 -
#' @param ... Further args passed on to \code{\link[crul]{HttpClient}}, main
13 +
#' @param ... Further args passed on to [crul::verb-GET], main
14 14
#' purpose being curl debugging
15 15
#'
16 -
#' BOLD only allows one sequence per query. We internally \code{lapply}
17 -
#' over the input values given to the \code{sequences} parameter to search
16 +
#' BOLD only allows one sequence per query. We internally `lapply`
17 +
#' over the input values given to the sequences` parameter to search
18 18
#' with one sequence per query. Remember this if you have a lot of sequences -
19 19
#' you are doing a separate query for each one, so it can take a long time -
20 20
#' if you run into errors let us know.
21 21
#'
22 22
#' @section db parmeter options:
23 -
#' \itemize{
24 -
#'  \item COX1 Every COI barcode record on BOLD with a minimum sequence
23 +
#'
24 +
#' - COX1 Every COI barcode record on BOLD with a minimum sequence
25 25
#'  length of 500bp (warning: unvalidated library and includes records without
26 26
#'  species level identification). This includes many species represented by
27 27
#'  only one or two specimens as well as all species with interim taxonomy. This
28 28
#'  search only returns a list of the nearest matches and does not provide a
29 29
#'  probability of placement to a taxon.
30 -
#'  \item COX1_SPECIES Every COI barcode record with a species level
30 +
#' - COX1_SPECIES Every COI barcode record with a species level
31 31
#'  identification and a minimum sequence length of 500bp. This includes
32 32
#'  many species represented by only one or two specimens as well as  all
33 33
#'  species with interim taxonomy.
34 -
#'  \item COX1_SPECIES_PUBLIC All published COI records from BOLD and GenBank
34 +
#' - COX1_SPECIES_PUBLIC All published COI records from BOLD and GenBank
35 35
#'  with a minimum sequence length of 500bp. This library is a collection of
36 36
#'  records from the published projects section of BOLD.
37 -
#'  \item OR COX1_L604bp Subset of the Species library with a minimum sequence
37 +
#' - OR COX1_L604bp Subset of the Species library with a minimum sequence
38 38
#'  length of 640bp and containing both public and private records. This library
39 39
#'  is intended for short sequence identification as it provides maximum overlap
40 40
#'  with short reads from the barcode region of COI.
41 -
#' }
42 41
#'
43 42
#' @section Named outputs:
44 43
#' To maintain names on the output list of data make sure to pass in a
45 -
#' named list to the \code{sequences} parameter. You can for example,
46 -
#' take a list of sequences, and use \code{\link{setNames}} to set names.
44 +
#' named list to the `sequences` parameter. You can for example,
45 +
#' take a list of sequences, and use [stats::setNames()] to set names.
47 46
#'
48 47
#' @return A data.frame with details for each specimen matched. if a
49 -
#' failed request, returns \code{NULL}
48 +
#' failed request, returns `NULL`
50 49
#' @references
51 -
#' \url{http://v4.boldsystems.org/index.php/resources/api?type=idengine}
52 -
#' @seealso \code{\link{bold_identify_parents}}
50 +
#' http://v4.boldsystems.org/index.php/resources/api?type=idengine
51 +
#' @seealso [bold_identify_parents()]
53 52
#' @examples \dontrun{
54 53
#' seq <- sequences$seq1
55 54
#' res <- bold_identify(sequences=seq)

@@ -2,14 +2,14 @@
Loading
2 2
#'
3 3
#' @export
4 4
#' @param name (character) One or more scientific names. required.
5 -
#' @param fuzzy (logical) Whether to use fuzzy search or not (default: FALSE).
5 +
#' @param fuzzy (logical) Whether to use fuzzy search or not (default: `FALSE`)
6 6
#' @template otherargs
7 7
#' @references 
8 -
#' \url{http://v4.boldsystems.org/index.php/resources/api?type=taxonomy}
9 -
#' @details The \code{dataTypes} parameter is not supported in this function. 
8 +
#' http://v4.boldsystems.org/index.php/resources/api?type=taxonomy
9 +
#' @details The `dataTypes` parameter is not supported in this function. 
10 10
#' If you want to use that parameter, get an ID from this function and pass 
11 -
#' it into \code{bold_tax_id}, and then use the \code{dataTypes} parameter.
12 -
#' @seealso \code{\link{bold_tax_id}}
11 +
#' it into `bold_tax_id`, and then use the `dataTypes` parameter.
12 +
#' @seealso [bold_tax_id()]
13 13
#' @examples \dontrun{
14 14
#' bold_tax_name(name='Diplura')
15 15
#' bold_tax_name(name='Osmia')

@@ -3,25 +3,19 @@
Loading
3 3
#' Get sequences for a taxonomic name, id, bin, container, institution, 
4 4
#' researcher, geographic, place, or gene.
5 5
#'
6 -
#' @importFrom stringr str_replace_all str_replace str_split
7 6
#' @export
8 7
#' @template args
9 8
#' @template otherargs
9 +
#' @template large-requests
10 +
#' @template marker
10 11
#' @references 
11 -
#' \url{http://v4.boldsystems.org/index.php/resources/api?type=webservices}
12 +
#' http://v4.boldsystems.org/index.php/resources/api?type=webservices
12 13
#'
13 14
#' @param marker (character) Returns all records containing matching 
14 15
#' marker codes.
15 16
#'
16 -
#' @return A list with each element of length 4 with slots for id, name, 
17 -
#' gene, and sequence.
18 -
#' 
19 -
#' @section If a request times out:
20 -
#' This is likely because you're request was for a large number of 
21 -
#' sequences and the BOLD service timed out. You still should get 
22 -
#' some output, those sequences that were retrieved before the time 
23 -
#' out happened. See the README (https://github.com/ropensci/bold/#bold)
24 -
#' for an example of dealing with large data problems with this function.
17 +
#' @return A data frame with each element as row and 5 columns for processid, identification, 
18 +
#' marker, accession, and sequence.
25 19
#' 
26 20
#' @examples \dontrun{
27 21
#' res <- bold_seq(taxon='Coelioxys')
@@ -51,22 +45,21 @@
Loading
51 45
bold_seq <- function(taxon = NULL, ids = NULL, bin = NULL, container = NULL, 
52 46
  institutions = NULL, researchers = NULL, geo = NULL, marker = NULL, 
53 47
  response=FALSE, ...) {
54 -
  
55 -
  args <- bc(
56 -
    list(
57 -
      taxon = pipeornull(taxon), geo = pipeornull(geo), 
58 -
      ids = pipeornull(ids), bin = pipeornull(bin), 
59 -
      container = pipeornull(container), 
60 -
      institutions = pipeornull(institutions),
61 -
      researchers = pipeornull(researchers), marker = pipeornull(marker)
62 -
    )
63 -
  )
64 -
  check_args_given_nonempty(
65 -
    args, 
66 -
    c('taxon','ids','bin','container','institutions','researchers',
67 -
      'geo','marker')
68 -
  )
69 -
  out <- b_GET(paste0(bbase(), 'API_Public/sequence'), args, ...)
48 +
  params <- list(taxon = taxon,
49 +
                  ids = ids,
50 +
                  bin = bin,
51 +
                  container = container,
52 +
                  institutions = institutions,
53 +
                  researchers = researchers,
54 +
                  geo = geo,
55 +
                  marker = marker)
56 +
  paramsNames = names(params)
57 +
  params = params[vapply(params, function(x){is.character(x)&&x!=""}, F)]
58 +
  if(length(params)==0){
59 +
    stop(paste0("You must provide a non-empty value to at least one of\n  ", paste(paramsNames, collapse = "\n  ")))
60 +
  }
61 +
  params <- vapply(params, paste, collapse = "|", "")
62 +
  out <- b_GET(paste0(bbase(), 'API_Public/sequence'), params, ...)
70 63
  if (response) { 
71 64
    out 
72 65
  } else {
@@ -77,6 +70,6 @@
Loading
77 70
      tt <- strdrop(str = tt, pattern = "Fatal+")[[1]]
78 71
    }
79 72
    res <- strsplit(tt, ">")[[1]][-1]
80 -
    lapply(res, split_fasta)
73 +
    split_fasta(res)
81 74
  }
82 75
}

@@ -3,7 +3,7 @@
Loading
3 3
#' @export
4 4
#' @template args
5 5
#' @references
6 -
#' \url{http://v4.boldsystems.org/index.php/resources/api?type=webservices}
6 +
#' http://v4.boldsystems.org/index.php/resources/api?type=webservices
7 7
#'
8 8
#' @param marker (character) Returns all records containing matching
9 9
#' marker codes.
@@ -11,7 +11,7 @@
Loading
11 11
#' @param overwrite (logical) Overwrite existing directory and file?
12 12
#' @param progress (logical) Print progress or not. NOT AVAILABLE FOR NOW.
13 13
#' HOPEFULLY WILL RETURN SOON.
14 -
#' @param ... Further args passed on to \code{\link[crul]{HttpClient}}
14 +
#' @param ... Further args passed on to [crul::verb-GET]
15 15
#' @param x Object to print or read.
16 16
#'
17 17
#' @examples \dontrun{

@@ -1,21 +1,21 @@
Loading
1 1
#' Filter BOLD specimen + sequence data (output of bold_seqspec)
2 -
#' 
2 +
#'
3 3
#' Picks either shortest or longest sequences, for a given grouping variable
4 4
#' (e.g., species name)
5 5
#'
6 6
#' @export
7 7
#' @param x (data.frame) a data.frame, as returned from
8 -
#' \code{\link{bold_seqspec}}. Note that some combinations of parameters
9 -
#' in \code{\link{bold_seqspec}} don't return a data.frame. Stops with
8 +
#' [bold_seqspec()]. Note that some combinations of parameters
9 +
#' in [bold_seqspec()] don't return a data.frame. Stops with
10 10
#' error message if this is not a data.frame. Required.
11 11
#' @param by (character) the column by which to group. For example,
12 12
#' if you want the longest sequence for each unique species name, then
13 -
#' pass \strong{species_name}. If the column doesn't exist, error
13 +
#' pass **species_name**. If the column doesn't exist, error
14 14
#' with message saying so. Required.
15 15
#' @param how (character) one of "max" or "min", which get used as
16 -
#' \code{which.max} or \code{which.min} to get the longest or shortest
16 +
#' `which.max` or `which.min` to get the longest or shortest
17 17
#' sequence, respectively. Note that we remove gap/alignment characters
18 -
#' (\code{-})
18 +
#' (`-`)
19 19
#' @return a tibble/data.frame
20 20
#' @examples \dontrun{
21 21
#' res <- bold_seqspec(taxon='Osmia')

@@ -2,15 +2,15 @@
Loading
2 2
#'
3 3
#' @export
4 4
#' @param id (integer) One or more BOLD taxonomic identifiers. required.
5 -
#' @param dataTypes (character) Specifies the datatypes that will be 
6 -
#' returned. 'all' returns all data. 'basic' returns basic taxon information. 
5 +
#' @param dataTypes (character) Specifies the datatypes that will be
6 +
#' returned. 'all' returns all data. 'basic' returns basic taxon information.
7 7
#' 'images' returns specimen images.
8 -
#' @param includeTree (logical) If TRUE (default: FALSE), returns a list 
8 +
#' @param includeTree (logical) If `TRUE` (default: `FALSE`), returns a list
9 9
#' containing information for parent taxa as well as the specified taxon.
10 10
#' @template otherargs
11 -
#' @references 
12 -
#' \url{http://v4.boldsystems.org/index.php/resources/api?type=taxonomy}
13 -
#' @seealso \code{bold_tax_name}
11 +
#' @references
12 +
#' http://v4.boldsystems.org/index.php/resources/api?type=taxonomy
13 +
#' @seealso [bold_tax_name()]
14 14
#' @examples \dontrun{
15 15
#' bold_tax_id(id=88899)
16 16
#' bold_tax_id(id=88899, includeTree=TRUE)
@@ -39,25 +39,25 @@
Loading
39 39
#' bold_tax_id(id=88899, verbose = TRUE)
40 40
#' }
41 41
42 -
bold_tax_id <- function(id, dataTypes = 'basic', includeTree = FALSE, 
42 +
bold_tax_id <- function(id, dataTypes = 'basic', includeTree = FALSE,
43 43
                        response = FALSE, ...) {
44 -
  
44 +
45 45
  tmp <- lapply(id, function(x)
46 46
    get_response(args = bc(list(
47 -
      taxId = x, dataTypes = dataTypes, 
47 +
      taxId = x, dataTypes = dataTypes,
48 48
      includeTree = if (includeTree) 'true' else NULL)),
49 49
      url = paste0(bbase(), "API_Tax/TaxonData"), ...)
50 50
  )
51 -
  if (response) { 
52 -
    tmp 
51 +
  if (response) {
52 +
    tmp
53 53
  } else {
54 -
    res <- do.call(rbind.fill, Map(process_response, x = tmp, y = id, 
54 +
    res <- do.call(rbind.fill, Map(process_response, x = tmp, y = id,
55 55
                                   z = includeTree, w = dataTypes))
56 -
    if (NCOL(res) == 1) { 
56 +
    if (NCOL(res) == 1) {
57 57
      res$noresults <- NA
58 58
      return(res)
59 -
    } else { 
60 -
      res 
59 +
    } else {
60 +
      res
61 61
    }
62 62
  }
63 63
}

@@ -4,10 +4,10 @@
Loading
4 4
#' @template args
5 5
#' @template otherargs
6 6
#' @references 
7 -
#' \url{http://v4.boldsystems.org/index.php/resources/api?type=webservices}
7 +
#' http://v4.boldsystems.org/index.php/resources/api?type=webservices
8 8
#'
9 9
#' @param format (character) One of xml, json, tsv (default). tsv format gives 
10 -
#' back a data.frame object. xml gives back parsed XML as \code{xml_document}
10 +
#' back a data.frame object. xml gives back parsed XML as `xml_document`
11 11
#' object. 'json' (JavaScript Object Notation) and 'dwc' (Darwin Core Archive)
12 12
#' are supported in theory, but the JSON can be malformed, so we don't support
13 13
#' that here, and the DWC option actually returns TSV.

@@ -3,29 +3,22 @@
Loading
3 3
#' @export
4 4
#' @template args
5 5
#' @template otherargs
6 +
#' @template large-requests
7 +
#' @template marker
6 8
#' @references
7 -
#' \url{http://v4.boldsystems.org/index.php/resources/api?type=webservices}
9 +
#' http://v4.boldsystems.org/index.php/resources/api?type=webservices
8 10
#'
9 11
#' @param marker (character) Returns all records containing matching marker
10 12
#' codes. See Details.
11 13
#' @param format (character) One of xml or tsv (default). tsv format gives
12 14
#' back a data.frame object. xml gives back parsed xml as a
13 -
#' @param sepfasta (logical) If \code{TRUE}, the fasta data is separated into
15 +
#' @param sepfasta (logical) If `TRUE`, the fasta data is separated into
14 16
#' a list with names matching the processid's from the data frame.
15 -
#' Default: \code{FALSE}
17 +
#' Default: `FALSE`
16 18
#'
17 19
#' @return Either a data.frame, parsed xml, a http response object, or a list
18 20
#' with length two (a data.frame w/o nucleotide data, and a list with
19 21
#' nucleotide data)
20 -
#' 
21 -
#' @section Marker:
22 -
#' Notes from BOLD on the \code{marker} param:
23 -
#' "All markers for a specimen matching the search string will be returned. 
24 -
#' ie. A record with COI-5P and ITS will return sequence data for both 
25 -
#' markers even if only COI-5P was specified."
26 -
#' 
27 -
#' You will likely end up with data with markers that you did not request -
28 -
#' just be sure to filter those out as needed.
29 22
#'
30 23
#' @examples \dontrun{
31 24
#' bold_seqspec(taxon='Osmia')
@@ -69,11 +62,16 @@
Loading
69 62
  } else {
70 63
    tt <- paste0(rawToChar(out$content, multiple = TRUE), collapse = "")
71 64
    if (tt == "") return(NA)
65 +
    tt <- enc2utf8(tt)
66 +
    if (grepl("Fatal error", tt)) {
67 +
      stop("BOLD servers returned an error - we're not sure what happened\n ",
68 +
        "try a smaller query - or open an issue and we'll try to help")
69 +
    }
72 70
    temp <- switch(
73 71
      format,
74 72
      xml = xml2::read_xml(tt),
75 73
      tsv = utils::read.delim(text = tt, header = TRUE, sep = "\t",
76 -
                       stringsAsFactors = FALSE)
74 +
                       stringsAsFactors = FALSE, quote = "")
77 75
    )
78 76
    if (!sepfasta) {
79 77
      temp
Files Coverage
R 71.15%
Project Totals (11 files) 71.15%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading