diff --git a/DESCRIPTION b/DESCRIPTION index ff48e21..008f01b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: fenr Title: Fast functional enrichment for interactive applications -Version: 1.1.7 +Version: 1.1.8 Authors@R: person( given = "Marek", family = "Gierlinski", diff --git a/NAMESPACE b/NAMESPACE index 21c63bd..5c08fea 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -15,6 +15,7 @@ export(functional_enrichment) export(get_feature_terms) export(get_term_features) export(prepare_for_enrichment) +export(remove_cache) importFrom(assertthat,assert_that) importFrom(assertthat,is.count) importFrom(assertthat,is.string) diff --git a/NEWS.md b/NEWS.md index 6b30d1f..ab06a57 100644 --- a/NEWS.md +++ b/NEWS.md @@ -150,4 +150,9 @@ ## Version 1.0.7 - Improved error handling with unresponsive servers - timeouts are now handled gracefully - + +## Version 1.0.8 + + - Further improving error handling, making sure `assert_url_path()` handles timeouts properly + - Introduced on_error = "ignore" for test purposes + diff --git a/R/bioplanet.R b/R/bioplanet.R index f95b29a..108fb9c 100644 --- a/R/bioplanet.R +++ b/R/bioplanet.R @@ -12,15 +12,14 @@ get_bioplanet_pathway_file <- function() { #' (NCBI gene ID, gene symbol and pathway ID) from BioPlanet. #' #' @param use_cache Logical, if TRUE, the remote file will be cached locally. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' @return A list with \code{terms} and \code{mapping} tibbles. #' @export #' @examples #' bioplanet_data <- fetch_bp(on_error = "warn") -fetch_bp <- function(use_cache = TRUE, on_error = c("stop", "warn")) { +fetch_bp <- function(use_cache = TRUE, on_error = c("stop", "warn", "ignore")) { on_error <- match.arg(on_error) # Binding variables from non-standard evaluation locally diff --git a/R/caching.R b/R/caching.R index b71deea..0921e03 100644 --- a/R/caching.R +++ b/R/caching.R @@ -82,11 +82,16 @@ cached_url_path <- function(rname, fpath, use_cache) { #' Remove all cache #' #' This function will remove all cached data used by `fenr`. The user will be -#' prompted for confirmation. Use with caution! +#' prompted for confirmation. Use only when you suspect the cache was corrupted. +#' Use with caution! #' #' @param ask Logical, whether to ask user for confirmation. #' @return TRUE if successfully removed. -#' @noRd +#' @export +#' @examples +#' \dontrun{ +#' remove_cache() +#' } remove_cache <- function(ask = TRUE) { cache <- cache_location() bfc <- BiocFileCache::BiocFileCache(cache, ask = FALSE) diff --git a/R/go.R b/R/go.R index b64b20a..3f415f0 100644 --- a/R/go.R +++ b/R/go.R @@ -112,14 +112,13 @@ extract_obo_terms <- function(parsed) { #' Download GO term descriptions #' #' @param use_cache Logical, if TRUE, the remote file will be cached locally. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `FALSE`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A tibble with term_id and term_name. #' @noRd -fetch_go_terms <- function(use_cache, on_error = "stop") { +fetch_go_terms <- function(use_cache, on_error) { obo_file <- get_go_obo_file() if(!assert_url_path(obo_file, on_error)) return(NULL) @@ -142,16 +141,15 @@ fetch_go_terms <- function(use_cache, on_error = "stop") { #' without extension (e.g. for a file \file{goa_chicken.gaf} the designation is #' \file{goa_chicken}). #' -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A tibble with columns \code{species} and \code{designation}. #' @export #' @examples #' go_species <- fetch_go_species(on_error = "warn") -fetch_go_species <- function(on_error = c("stop", "warn")) { +fetch_go_species <- function(on_error = c("stop", "warn", "ignore")) { on_error <- match.arg(on_error) # Binding variables from non-standard evaluation locally species <- designation <- `Species/Database` <- File <- NULL @@ -184,14 +182,13 @@ fetch_go_species <- function(on_error = c("stop", "warn")) { #' \url{http://current.geneontology.org/annotations}. Examples are #' \file{goa_human} for human, \file{mgi} for mouse or \file{sgd} for yeast. #' @param use_cache Logical, if TRUE, the remote file will be cached locally. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A tibble with columns \code{gene_symbol}, \code{uniprot_id} and \code{term_id}. #' @noRd -fetch_go_genes_go <- function(species, use_cache, on_error = "stop") { +fetch_go_genes_go <- function(species, use_cache, on_error) { # Binding variables from non-standard evaluation locally gene_id <- db_object_synonym <- symbol <- NULL db_id <- go_term <- NULL @@ -228,15 +225,14 @@ fetch_go_genes_go <- function(species, use_cache, on_error = "stop") { #' species can be obtained using \code{fetch_go_species} - column #' \code{designation}. #' @param use_cache Logical, if TRUE, the remote file will be cached locally. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A list with \code{terms} and \code{mapping} tibbles. #' @importFrom assertthat assert_that #' @noRd -fetch_go_from_go <- function(species, use_cache, on_error = "stop") { +fetch_go_from_go <- function(species, use_cache, on_error) { assert_that(!missing(species), msg = "Argument 'species' is missing.") assert_species(species, "fetch_go_species", on_error) @@ -244,7 +240,9 @@ fetch_go_from_go <- function(species, use_cache, on_error = "stop") { if(is.null(mapping)) return(NULL) - terms <- fetch_go_terms(use_cache = use_cache) + terms <- fetch_go_terms(use_cache = use_cache, on_error = on_error) + if(is.null(terms)) + return(NULL) list( terms = terms, @@ -261,15 +259,14 @@ fetch_go_from_go <- function(species, use_cache, on_error = "stop") { #' biomaRt::useEnsembl(biomart = "ensembl"), followed by #' biomaRt::listDatasets(mart). #' @param use_cache Logical, if TRUE, the remote data will be cached locally. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A tibble with columns \code{gene_id}, \code{gene_symbol} and #' \code{term_id}. #' @noRd -fetch_go_genes_bm <- function(dataset, use_cache = TRUE, on_error = c("stop", "warn")) { +fetch_go_genes_bm <- function(dataset, use_cache, on_error) { xml <- get_biomart_xml(dataset) |> stringr::str_replace_all("\\s", "%20") req <- paste0(get_biomart_url(), "/biomart/martservice?query=", xml) @@ -298,15 +295,14 @@ fetch_go_genes_bm <- function(dataset, use_cache = TRUE, on_error = c("stop", "w #' biomaRt::useEnsembl(biomart = "ensembl"), followed by #' biomaRt::listDatasets(mart). #' @param use_cache Logical, if TRUE, the remote file will be cached locally. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @importFrom assertthat assert_that is.string #' @return A list with \code{terms} and \code{mapping} tibbles. #' @noRd -fetch_go_from_bm <- function(dataset, use_cache = TRUE, on_error = c("stop", "warn")) { +fetch_go_from_bm <- function(dataset, use_cache, on_error) { assert_that(!missing(dataset), msg = "Argument 'dataset' is missing.") assert_that(is.string(dataset)) @@ -353,10 +349,9 @@ fetch_go_from_bm <- function(dataset, use_cache = TRUE, on_error = c("stop", "wa #' biomaRt::useEnsembl(biomart = "ensembl"), followed by #' biomaRt::listDatasets(mart). #' @param use_cache Logical, if TRUE, the remote data will be cached locally. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A list with \code{terms} and \code{mapping} tibbles. #' @export @@ -366,7 +361,8 @@ fetch_go_from_bm <- function(dataset, use_cache = TRUE, on_error = c("stop", "wa #' go_data_ensembl <- fetch_go(dataset = "scerevisiae_gene_ensembl", on_error = "warn") #' # Fetch GO data from Gene Ontology #' go_data_go <- fetch_go(species = "sgd", on_error = "warn") -fetch_go <- function(species = NULL, dataset = NULL, use_cache = TRUE, on_error = c("stop", "warn")) { +fetch_go <- function(species = NULL, dataset = NULL, use_cache = TRUE, + on_error = c("stop", "warn", "ignore")) { on_error <- match.arg(on_error) assert_that(!(is.null(species) & is.null(dataset)), diff --git a/R/interactive_example.R b/R/interactive_example.R index bd122b7..f7d64de 100644 --- a/R/interactive_example.R +++ b/R/interactive_example.R @@ -6,8 +6,10 @@ #' @return A list of objects containing functional terms for GO and Reactome. #' @export #' @examples +#' \dontrun{ #' data(yeast_de) #' term_data <- fetch_terms_for_example(yeast_de) +#' } fetch_terms_for_example <- function(de) { # All gene background all_genes <- de$gene_id @@ -19,7 +21,7 @@ fetch_terms_for_example <- function(de) { # load Reactome pathways message("Fetching Reactome data\n") - re <- fetch_reactome("Saccharomyces cerevisiae", on_error = "warn") + re <- fetch_reactome("Saccharomyces cerevisiae") re_data <- prepare_for_enrichment(re$terms, re$mapping, all_genes, feature_name = "gene_id") # Put all functional term data in one structure; Shiny app will access @@ -173,9 +175,9 @@ main_plot <- function(de, input) { #' @importFrom assertthat assert_that #' @export #' @examples +#' \dontrun{ #' data(yeast_de) #' term_data <- fetch_terms_for_example(yeast_de) -#' if(interactive()) { #' enrichment_interactive(yeast_de, term_data) #' } enrichment_interactive <- function(de, term_data) { diff --git a/R/kegg.R b/R/kegg.R index f49dfaf..9d6e00f 100644 --- a/R/kegg.R +++ b/R/kegg.R @@ -9,17 +9,16 @@ get_kegg_url <- function() { #' Find all species available from KEGG #' -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A tibble, in which column \code{designation} contains species #' designations used in function \code{fetch_kegg}. #' @export #' @examples #' spe <- fetch_kegg_species(on_error = "warn") -fetch_kegg_species <- function(on_error = c("stop", "warn")) { +fetch_kegg_species <- function(on_error = c("stop", "warn", "ignore")) { on_error <- match.arg(on_error) resp <- http_request(get_kegg_url(), "list/organism") @@ -34,10 +33,9 @@ fetch_kegg_species <- function(on_error = c("stop", "warn")) { #' Download pathway data from KEGG #' #' @param species A valid species designation used by KEGG. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A tibble with columns \code{gene_id} and \code{term_id}. #' @noRd @@ -118,14 +116,13 @@ parse_kegg_genes <- function(s) { #' @param pathways A character vector with KEGG pathways #' @param batch_size Number of pathways sent to KEGG database in one query. The #' maximum allowed is 10. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' @importFrom assertthat assert_that #' @return A tibble with columns \code{gene_id} and \code{term_id} #' @noRd -fetch_kegg_mapping <- function(pathways, batch_size, on_error = "stop") { +fetch_kegg_mapping <- function(pathways, batch_size, on_error) { assert_that(is.character(pathways)) batches <- split(pathways, ceiling(seq_along(pathways) / batch_size)) @@ -167,17 +164,16 @@ fetch_kegg_mapping <- function(pathways, batch_size, on_error = "stop") { #' full list of available KEGG species can be found by using \code{fetch_kegg_species}. #' @param batch_size Number of pathways sent to KEGG database in one query. The #' maximum allowed is 10. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A list with \code{terms} and \code{mapping} tibbles. #' @importFrom assertthat assert_that is.count #' @export #' @examples #' kegg_data <- fetch_kegg("mge", on_error = "warn") -fetch_kegg <- function(species, batch_size = 10, on_error = c("stop", "warn")) { +fetch_kegg <- function(species, batch_size = 10, on_error = c("stop", "warn", "ignore")) { on_error <- match.arg(on_error) assert_that(!missing(species), msg = "Argument 'species' is missing.") diff --git a/R/reactome.R b/R/reactome.R index 038c245..7667faa 100644 --- a/R/reactome.R +++ b/R/reactome.R @@ -24,15 +24,15 @@ get_reactome_gaf_file <- function() { #' List of available Reactome species #' -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". +#' #' @return A tibble with species names used by Reactome. #' @export #' @examples #' re <- fetch_reactome_species(on_error = "warn") -fetch_reactome_species <- function(on_error = c("stop", "warn")) { +fetch_reactome_species <- function(on_error = c("stop", "warn", "ignore")) { on_error <- match.arg(on_error) # Binding variables from non-standard evaluation locally @@ -53,14 +53,13 @@ fetch_reactome_species <- function(on_error = c("stop", "warn")) { #' Download pathway data from Reactome #' #' @param tax_id Taxonomy ID of the species, a string -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A tibble with columns \code{term_id} and \code{term_name} #' @noRd -fetch_reactome_pathways <- function(tax_id, on_error = "stop") { +fetch_reactome_pathways <- function(tax_id, on_error) { # Binding variables from non-standard evaluation locally stId <- displayName <- NULL @@ -91,14 +90,13 @@ fetch_reactome_pathways <- function(tax_id, on_error = "stop") { #' #' @param spec Reactome species. #' @param use_cache Logical, if TRUE, the remote file will be cached locally. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A tibble with columns \code{gene_id} and \code{term_id} #' @noRd -fetch_reactome_ensembl_genes <- function(spec, use_cache = TRUE, on_error = "stop") { +fetch_reactome_ensembl_genes <- function(spec, use_cache, on_error) { # Binding variables from non-standard evaluation locally species <- gene_id <- gene_name <- gene_symbol <- term_id <- NULL @@ -121,14 +119,13 @@ fetch_reactome_ensembl_genes <- function(spec, use_cache = TRUE, on_error = "sto #' #' @param tax_id Taxon ID #' @param use_cache Logical, if TRUE, the remote file will be cached locally. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A tibble with columns \code{accession_number}, \code{gene_symbol} and \code{term_id} #' @noRd -fetch_reactome_gene_association <- function(tax_id, use_cache = TRUE, on_error = "stop") { +fetch_reactome_gene_association <- function(tax_id, use_cache, on_error) { # Binding variables from non-standard evaluation locally symbol <- taxon <- db_ref <- db_id <- NULL @@ -159,10 +156,9 @@ fetch_reactome_gene_association <- function(tax_id, use_cache = TRUE, on_error = #' #' @param pathways A character vector with Reactome patway IDs to get #' corresponding genes from. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A tibble with columns\code{term_id}, \code{accession_number} and #' \code{gene_symbol}. @@ -229,10 +225,9 @@ fetch_reactome_api_genes <- function(pathways, on_error) { #' 'gene_association', one mapping file provided by Reactome will be #' downloaded, if 'api', then Reactome API will be used. See details. #' @param use_cache Logical, if TRUE, the remote file will be cached locally. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A list with \code{terms} and \code{mapping} tibbles #' @importFrom assertthat assert_that @@ -240,7 +235,7 @@ fetch_reactome_api_genes <- function(pathways, on_error) { #' @examples #' reactome_data <- fetch_reactome("Saccharomyces cerevisiae", on_error = "warn") fetch_reactome <- function(species, source = c("ensembl", "api", "gene_association"), - use_cache = TRUE, on_error = c("stop", "warn")) { + use_cache = TRUE, on_error = c("stop", "warn", "ignore")) { source <- match.arg(source) on_error <- match.arg(on_error) assert_that(!missing(species), msg = "Argument 'species' is missing.") @@ -252,11 +247,11 @@ fetch_reactome <- function(species, source = c("ensembl", "api", "gene_associati terms <- fetch_reactome_pathways(tax_id, on_error) if (source == "ensembl") { - mapping <- fetch_reactome_ensembl_genes(spec = species, use_cache = use_cache) + mapping <- fetch_reactome_ensembl_genes(spec = species, use_cache = use_cache, on_error = on_error) } else if (source == "gene_association") { - mapping <- fetch_reactome_gene_association(tax_id = tax_id, use_cache = use_cache) + mapping <- fetch_reactome_gene_association(tax_id = tax_id, use_cache = use_cache, on_error = on_error) } else { - mapping <- fetch_reactome_api_genes(terms$term_id, on_error) + mapping <- fetch_reactome_api_genes(terms$term_id, on_error = on_error) } list( diff --git a/R/util.R b/R/util.R index 5c72c0f..c69a6e5 100644 --- a/R/util.R +++ b/R/util.R @@ -29,28 +29,22 @@ GAF_TYPES <- rep("c", length(GAF_COLUMNS)) |> #' responding. #' #' @param url_path Full URL with a path, e.g. `https://reactome.org/download/current/ReactomePathways.txt`. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `FALSE`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". +#' @param timeout Timeout limit in seconds. #' #' @importFrom assertthat assert_that is.string #' @return TRUE if assertion passed #' @noRd -assert_url_path <- function(url_path, on_error = "stop") { +assert_url_path <- function(url_path, on_error = c("stop", "warn", "ignore"), timeout = 15) { + on_error <- match.arg(on_error) assert_that(is.string(url_path)) - resp <- httr2::request(url_path) |> - httr2::req_method("HEAD") |> - httr2::req_error(is_error = ~FALSE) |> - httr2::req_perform() + resp <- http_request(url_path, "", timeout = timeout) - if(httr2::resp_is_error(resp)) { - rsp <- list( - status = httr2::resp_status(resp), - description = httr2::resp_status_desc(resp) - ) - catch_error(stringr::str_glue("{url_path}"), rsp, on_error) + if(resp$is_error) { + catch_error(stringr::str_glue("{url_path}"), resp, on_error) return(FALSE) } return(TRUE) @@ -63,10 +57,9 @@ assert_url_path <- function(url_path, on_error = "stop") { #' @param species A string, species designation for a given database #' @param fetch_fun A string, name of the function to retrieve available #' species, must return a tibble with a column \code{designation}. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @importFrom assertthat assert_that is.string #' @return A tibble with valid species - a response from \code{fetch_fun} @@ -94,10 +87,9 @@ assert_species <- function(species, fetch_fun, on_error) { #' species, must return a tibble with a column \code{designation}. #' @param col_name Column name in the tibble returned by \code{fetch_fun} to #' extract, e.g. \code{tax_id} -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A value extracted from column \code{col_name} at row where #' \code{designation} = \code{species}. @@ -227,15 +219,14 @@ test_mapping <- function(returned, expected, feature_id) { #' @param server Name of the server. #' @param resp Response from \code{http_request()}. A list with "status" and #' "desc" strings. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' -#' @return In case of `"warn"`, the function returns `NULL`. If `"stop"` is -#' chosen, the function halts with an error and does not return a value. +#' @return No return value if `on_error` is "stop". If `on_error` is "warn" or +#' "ignore", the function returns `NULL` after issuing a warning. #' @noRd -catch_error <- function(server, resp, on_error = c("stop", "warn")) { +catch_error <- function(server, resp, on_error = c("stop", "warn", "ignore")) { on_error <- match.arg(on_error) st <- stringr::str_glue("Cannot access {server}. {resp$status}: {resp$description}.") @@ -245,26 +236,28 @@ catch_error <- function(server, resp, on_error = c("stop", "warn")) { #' Error Response Handler #' -#' This function handles errors by either stopping execution or issuing a warning -#' based on the specified action. It is designed to provide a standardized way to -#' handle error messages within functions. +#' This function handles errors by either stopping execution or issuing a +#' warning based on the specified action. It is designed to provide a +#' standardized way to handle error messages within functions. #' #' @param msg A character string specifying the error message to be displayed. #' @param on_error A character string indicating the error handling strategy: -#' either "stop" to halt execution, or "warn" to issue a warning and return `NULL`. -#' Defaults to "stop". +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' -#' @return No return value if `on_error` is "stop". If `on_error` is "warn", -#' the function returns `NULL` after issuing a warning. +#' @return No return value if `on_error` is "stop". If `on_error` is "warn" or +#' "ignore", the function returns `NULL` after issuing a warning. #' @noRd -error_response <- function(msg, on_error = c("stop", "warn")) { +error_response <- function(msg, on_error = c("stop", "warn", "ignore")) { on_error <- match.arg(on_error) if(on_error == "stop") { stop(msg) - } else { + } else if (on_error == "warn") { warning(msg, "\nNULL returned.", call. = FALSE) return(NULL) + } else { + return(NULL) } } diff --git a/R/wiki.R b/R/wiki.R index 1019edd..70df58d 100644 --- a/R/wiki.R +++ b/R/wiki.R @@ -8,16 +8,15 @@ get_wiki_url <- function() { #' List of available WikiPathways species #' -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A character vector with species names used by WikiPathways. #' @export #' @examples #' spec <- fetch_wiki_species(on_error = "warn") -fetch_wiki_species <- function(on_error = c("stop", "warn")) { +fetch_wiki_species <- function(on_error = c("stop", "warn", "ignore")) { on_error <- match.arg(on_error) resp <- http_request(get_wiki_url(), "listOrganisms", parameters = list(format = "json")) @@ -31,13 +30,13 @@ fetch_wiki_species <- function(on_error = c("stop", "warn")) { #' Download pathway data from WikiPathways #' #' @param species Species name recognised by WikiPathways (see \code{fetch_wiki_species()}) -#' @param on_error A string selecting how to react to server errors. If "stop", -#' an R error will be produced, if "warn", only a warning will be printed and -#' the function will return NULL. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A tibble with columns \code{gene_id} and \code{term_id} #' @noRd -fetch_wiki_pathways <- function(species, on_error = "stop") { +fetch_wiki_pathways <- function(species, on_error) { id <- name <- NULL resp <- http_request(get_wiki_url(), "listPathways", @@ -91,13 +90,13 @@ parse_wiki_gpml <- function(gpml, keys = c("TextLabel", "Type", "Database", "ID" #' @param pathways A character vector with pathway names. #' @param databases Names of databases to use #' @param types Names of types to use -#' @param on_error A string selecting how to react to server errors. If "stop", -#' an R error will be produced, if "warn", only a warning will be printed and -#' the function will return NULL. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A tibble with \code{term_id} and \code{gene_symbol} #' @noRd -fetch_wiki_pathway_genes_api <- function(pathways, databases = NULL, types = NULL, on_error = "stop") { +fetch_wiki_pathway_genes_api <- function(pathways, databases = NULL, types = NULL, on_error) { term_id <- TextLabel <-ID <- Type <- Database <- database <- type <- NULL raise_error <- FALSE @@ -159,10 +158,9 @@ fetch_wiki_pathway_genes_api <- function(pathways, databases = NULL, types = NUL #' data. See details. Full result will be returned if NULL. #' @param types A character vector with types of entities to pre-filter mapping #' data. See details. Full result will be returned if NULL. -#' @param on_error A character vector specifying the error handling method. It -#' can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -#' will halt the function execution and throw an error, while `"warn"` will -#' issue a warning and return `NULL`. +#' @param on_error A character string indicating the error handling strategy: +#' either "stop" to halt execution, "warn" to issue a warning and return +#' `NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop". #' #' @return A list with \code{terms} and \code{mapping} tibbles. #' @export @@ -173,7 +171,7 @@ fetch_wiki <- function( species, databases = c("Ensembl", "Entrez Gene", "HGNC", "HGNC Accession number", "Uniprot-TrEMBL"), types = c("GeneProduct", "Protein", "Rna", "RNA"), - on_error = c("stop", "warn") + on_error = c("stop", "warn", "ignore") ) { on_error <- match.arg(on_error) assert_that(!missing(species), msg = "Argument 'species' is missing.") diff --git a/man/enrichment_interactive.Rd b/man/enrichment_interactive.Rd index 5234968..6a2d75a 100644 --- a/man/enrichment_interactive.Rd +++ b/man/enrichment_interactive.Rd @@ -21,9 +21,9 @@ An interactive Shiny app Small Shiny app serving as example for fast enrichment } \examples{ +\dontrun{ data(yeast_de) term_data <- fetch_terms_for_example(yeast_de) -if(interactive()) { enrichment_interactive(yeast_de, term_data) } } diff --git a/man/fetch_bp.Rd b/man/fetch_bp.Rd index 9ae392f..bb54555 100644 --- a/man/fetch_bp.Rd +++ b/man/fetch_bp.Rd @@ -4,15 +4,14 @@ \alias{fetch_bp} \title{Get functional term data from BioPlanet} \usage{ -fetch_bp(use_cache = TRUE, on_error = c("stop", "warn")) +fetch_bp(use_cache = TRUE, on_error = c("stop", "warn", "ignore")) } \arguments{ \item{use_cache}{Logical, if TRUE, the remote file will be cached locally.} -\item{on_error}{A character vector specifying the error handling method. It -can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -will halt the function execution and throw an error, while `"warn"` will -issue a warning and return `NULL`.} +\item{on_error}{A character string indicating the error handling strategy: +either "stop" to halt execution, "warn" to issue a warning and return +`NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop".} } \value{ A list with \code{terms} and \code{mapping} tibbles. diff --git a/man/fetch_go.Rd b/man/fetch_go.Rd index e83aa4f..4cd28bf 100644 --- a/man/fetch_go.Rd +++ b/man/fetch_go.Rd @@ -8,7 +8,7 @@ fetch_go( species = NULL, dataset = NULL, use_cache = TRUE, - on_error = c("stop", "warn") + on_error = c("stop", "warn", "ignore") ) } \arguments{ @@ -26,10 +26,9 @@ biomaRt::listDatasets(mart).} \item{use_cache}{Logical, if TRUE, the remote data will be cached locally.} -\item{on_error}{A character vector specifying the error handling method. It -can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -will halt the function execution and throw an error, while `"warn"` will -issue a warning and return `NULL`.} +\item{on_error}{A character string indicating the error handling strategy: +either "stop" to halt execution, "warn" to issue a warning and return +`NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop".} } \value{ A list with \code{terms} and \code{mapping} tibbles. diff --git a/man/fetch_go_species.Rd b/man/fetch_go_species.Rd index 3f0a4b6..0f6e431 100644 --- a/man/fetch_go_species.Rd +++ b/man/fetch_go_species.Rd @@ -4,13 +4,12 @@ \alias{fetch_go_species} \title{Find all species available from geneontology.org} \usage{ -fetch_go_species(on_error = c("stop", "warn")) +fetch_go_species(on_error = c("stop", "warn", "ignore")) } \arguments{ -\item{on_error}{A character vector specifying the error handling method. It -can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -will halt the function execution and throw an error, while `"warn"` will -issue a warning and return `NULL`.} +\item{on_error}{A character string indicating the error handling strategy: +either "stop" to halt execution, "warn" to issue a warning and return +`NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop".} } \value{ A tibble with columns \code{species} and \code{designation}. diff --git a/man/fetch_kegg.Rd b/man/fetch_kegg.Rd index d8f79cb..74b2466 100644 --- a/man/fetch_kegg.Rd +++ b/man/fetch_kegg.Rd @@ -4,7 +4,7 @@ \alias{fetch_kegg} \title{Get functional term data from KEGG} \usage{ -fetch_kegg(species, batch_size = 10, on_error = c("stop", "warn")) +fetch_kegg(species, batch_size = 10, on_error = c("stop", "warn", "ignore")) } \arguments{ \item{species}{KEGG species code, for example "hsa" for human. The @@ -13,10 +13,9 @@ full list of available KEGG species can be found by using \code{fetch_kegg_speci \item{batch_size}{Number of pathways sent to KEGG database in one query. The maximum allowed is 10.} -\item{on_error}{A character vector specifying the error handling method. It -can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -will halt the function execution and throw an error, while `"warn"` will -issue a warning and return `NULL`.} +\item{on_error}{A character string indicating the error handling strategy: +either "stop" to halt execution, "warn" to issue a warning and return +`NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop".} } \value{ A list with \code{terms} and \code{mapping} tibbles. diff --git a/man/fetch_kegg_species.Rd b/man/fetch_kegg_species.Rd index fec8e3f..5a67bd6 100644 --- a/man/fetch_kegg_species.Rd +++ b/man/fetch_kegg_species.Rd @@ -4,13 +4,12 @@ \alias{fetch_kegg_species} \title{Find all species available from KEGG} \usage{ -fetch_kegg_species(on_error = c("stop", "warn")) +fetch_kegg_species(on_error = c("stop", "warn", "ignore")) } \arguments{ -\item{on_error}{A character vector specifying the error handling method. It -can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -will halt the function execution and throw an error, while `"warn"` will -issue a warning and return `NULL`.} +\item{on_error}{A character string indicating the error handling strategy: +either "stop" to halt execution, "warn" to issue a warning and return +`NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop".} } \value{ A tibble, in which column \code{designation} contains species diff --git a/man/fetch_reactome.Rd b/man/fetch_reactome.Rd index 1975b7b..25d4705 100644 --- a/man/fetch_reactome.Rd +++ b/man/fetch_reactome.Rd @@ -8,7 +8,7 @@ fetch_reactome( species, source = c("ensembl", "api", "gene_association"), use_cache = TRUE, - on_error = c("stop", "warn") + on_error = c("stop", "warn", "ignore") ) } \arguments{ @@ -22,10 +22,9 @@ downloaded, if 'api', then Reactome API will be used. See details.} \item{use_cache}{Logical, if TRUE, the remote file will be cached locally.} -\item{on_error}{A character vector specifying the error handling method. It -can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -will halt the function execution and throw an error, while `"warn"` will -issue a warning and return `NULL`.} +\item{on_error}{A character string indicating the error handling strategy: +either "stop" to halt execution, "warn" to issue a warning and return +`NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop".} } \value{ A list with \code{terms} and \code{mapping} tibbles diff --git a/man/fetch_reactome_species.Rd b/man/fetch_reactome_species.Rd index 7bd04cf..a335f65 100644 --- a/man/fetch_reactome_species.Rd +++ b/man/fetch_reactome_species.Rd @@ -4,13 +4,12 @@ \alias{fetch_reactome_species} \title{List of available Reactome species} \usage{ -fetch_reactome_species(on_error = c("stop", "warn")) +fetch_reactome_species(on_error = c("stop", "warn", "ignore")) } \arguments{ -\item{on_error}{A character vector specifying the error handling method. It -can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -will halt the function execution and throw an error, while `"warn"` will -issue a warning and return `NULL`.} +\item{on_error}{A character string indicating the error handling strategy: +either "stop" to halt execution, "warn" to issue a warning and return +`NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop".} } \value{ A tibble with species names used by Reactome. diff --git a/man/fetch_terms_for_example.Rd b/man/fetch_terms_for_example.Rd index 5cf1d24..16d8894 100644 --- a/man/fetch_terms_for_example.Rd +++ b/man/fetch_terms_for_example.Rd @@ -17,6 +17,8 @@ A list of objects containing functional terms for GO and Reactome. Create term data for interactive example } \examples{ +\dontrun{ data(yeast_de) term_data <- fetch_terms_for_example(yeast_de) } +} diff --git a/man/fetch_wiki.Rd b/man/fetch_wiki.Rd index 0c2bd6f..3c7d9de 100644 --- a/man/fetch_wiki.Rd +++ b/man/fetch_wiki.Rd @@ -9,7 +9,7 @@ fetch_wiki( databases = c("Ensembl", "Entrez Gene", "HGNC", "HGNC Accession number", "Uniprot-TrEMBL"), types = c("GeneProduct", "Protein", "Rna", "RNA"), - on_error = c("stop", "warn") + on_error = c("stop", "warn", "ignore") ) } \arguments{ @@ -23,10 +23,9 @@ data. See details. Full result will be returned if NULL.} \item{types}{A character vector with types of entities to pre-filter mapping data. See details. Full result will be returned if NULL.} -\item{on_error}{A character vector specifying the error handling method. It -can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -will halt the function execution and throw an error, while `"warn"` will -issue a warning and return `NULL`.} +\item{on_error}{A character string indicating the error handling strategy: +either "stop" to halt execution, "warn" to issue a warning and return +`NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop".} } \value{ A list with \code{terms} and \code{mapping} tibbles. diff --git a/man/fetch_wiki_species.Rd b/man/fetch_wiki_species.Rd index 559fab6..5f2501c 100644 --- a/man/fetch_wiki_species.Rd +++ b/man/fetch_wiki_species.Rd @@ -4,13 +4,12 @@ \alias{fetch_wiki_species} \title{List of available WikiPathways species} \usage{ -fetch_wiki_species(on_error = c("stop", "warn")) +fetch_wiki_species(on_error = c("stop", "warn", "ignore")) } \arguments{ -\item{on_error}{A character vector specifying the error handling method. It -can take values `"stop"` or `"warn"`. The default is `"stop"`. `"stop"` -will halt the function execution and throw an error, while `"warn"` will -issue a warning and return `NULL`.} +\item{on_error}{A character string indicating the error handling strategy: +either "stop" to halt execution, "warn" to issue a warning and return +`NULL` or "ignore" to return `NULL` without warnings. Defaults to "stop".} } \value{ A character vector with species names used by WikiPathways. diff --git a/man/remove_cache.Rd b/man/remove_cache.Rd new file mode 100644 index 0000000..fcdaf99 --- /dev/null +++ b/man/remove_cache.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/caching.R +\name{remove_cache} +\alias{remove_cache} +\title{Remove all cache} +\usage{ +remove_cache(ask = TRUE) +} +\arguments{ +\item{ask}{Logical, whether to ask user for confirmation.} +} +\value{ +TRUE if successfully removed. +} +\description{ +This function will remove all cached data used by `fenr`. The user will be +prompted for confirmation. Use only when you suspect the cache was corrupted. +Use with caution! +} +\examples{ +\dontrun{ +remove_cache() +} +} diff --git a/tests/testthat/test_bp.R b/tests/testthat/test_bp.R index 3d92d77..765d79c 100644 --- a/tests/testthat/test_bp.R +++ b/tests/testthat/test_bp.R @@ -7,7 +7,7 @@ expected_mapping <- tibble::tribble( ) test_that("Bioplanet mapping makes sense", { - bp <- fetch_bp(on_error = "warn") + bp <- fetch_bp(on_error = "ignore") if(!is.null(bp)) { expect_is(bp, "list") expect_setequal(names(bp), c("terms", "mapping")) diff --git a/tests/testthat/test_go.R b/tests/testthat/test_go.R index 4c7ab60..3db4288 100644 --- a/tests/testthat/test_go.R +++ b/tests/testthat/test_go.R @@ -52,7 +52,7 @@ test_that("Expected behaviour from a non-responsive server", { test_that("Expected return from fetch_go_species", { expected_selection <- c("goa_human", "mgi", "rgd", "sgd", "fb", "wb") - spec <- fetch_go_species(on_error = "warn") + spec <- fetch_go_species(on_error = "ignore") if(!is.null(spec)) { expect_is(spec, "tbl") expect_true(all(expected_selection %in% spec$designation)) @@ -79,7 +79,7 @@ test_that("GO yeast from GO is correct", { "GO:0004365", "TDH3" ) - re <- fetch_go(species = species, on_error = "warn") + re <- fetch_go(species = species, on_error = "ignore") if(!is.null(re)) { test_fetched_structure(re) test_terms(re$terms, expected_terms) @@ -107,7 +107,7 @@ test_that("GO yeast from Ensembl is correct", { "GO:0004365", "YGR192C" ) - re <- fetch_go(dataset = dataset, on_error = "warn") + re <- fetch_go(dataset = dataset, on_error = "ignore") if(!is.null(re)) { test_fetched_structure(re) diff --git a/tests/testthat/test_http_request.R b/tests/testthat/test_http_request.R index cda3d17..c1b068c 100644 --- a/tests/testthat/test_http_request.R +++ b/tests/testthat/test_http_request.R @@ -1,9 +1,15 @@ timeout_url <- "http://www.google.com:81" -test_that("Correct reaction to a time-out", { +test_that("Correct reaction to a time-out in http_resuest()", { resp <- http_request(timeout_url, "", timeout = 1) expect_is(resp, "list") expect_equal(resp$is_error, TRUE) expect_equal(resp$status, "unknown") }) + +test_that("Correct reaction to a time-out in assert_url_path()", { + expect_warning({assert_url_path(timeout_url, on_error = "warn", timeout = 1)}) + resp <- assert_url_path(timeout_url, on_error = "ignore", timeout = 1) + expect_equal(resp, FALSE) +}) diff --git a/tests/testthat/test_kegg.R b/tests/testthat/test_kegg.R index bb9f7af..a58a83e 100644 --- a/tests/testthat/test_kegg.R +++ b/tests/testthat/test_kegg.R @@ -36,7 +36,7 @@ test_that("Expected behaviour from a non-responsive server", { test_that("Expected return from fetch_kegg_species", { expected_selection <- c("hsa", "mmu", "rno", "sce", "dme", "cel") - spec <- fetch_kegg_species(on_error = "warn") + spec <- fetch_kegg_species(on_error = "ignore") if(!is.null(spec)) { expect_is(spec, "tbl") expect_true(all(expected_selection %in% spec$designation)) @@ -63,7 +63,7 @@ test_that("Correct response from fetch_kegg", { "mge03030", "polC" ) - re <- fetch_kegg(species, on_error = "warn") + re <- fetch_kegg(species, on_error = "ignore") if(!is.null(re)) { test_fetched_structure(re) test_terms(re$terms, expected_terms) diff --git a/tests/testthat/test_reactome.R b/tests/testthat/test_reactome.R index 4cfcb1a..c1da0cc 100644 --- a/tests/testthat/test_reactome.R +++ b/tests/testthat/test_reactome.R @@ -50,7 +50,7 @@ test_that("Expected behaviour from a non-responsive server", { test_that("Expected return from fetch_reactome_species", { expected_selection <- c("Homo sapiens", "Mus musculus", "Rattus norvegicus", "Saccharomyces cerevisiae", "Drosophila melanogaster", "Caenorhabditis elegans") - spec <- fetch_reactome_species(on_error = "warn") + spec <- fetch_reactome_species(on_error = "ignore") if(!is.null(spec)) { expect_is(spec, "tbl") expect_true(all(expected_selection %in% spec$designation)) @@ -59,7 +59,7 @@ test_that("Expected return from fetch_reactome_species", { test_that("Correct Reactome Ensembl from yeast", { - re <- fetch_reactome(species, source = "ensembl", use_cache = TRUE, on_error = "warn") + re <- fetch_reactome(species, source = "ensembl", use_cache = TRUE, on_error = "ignore") if(!is.null(re)) { expect_is(re, "list") expect_length(re, 2) @@ -89,7 +89,7 @@ test_that("Correct Reactome Ensembl from yeast", { test_that("Correct Reactome gene association from yeast", { - re <- fetch_reactome(species, source = "gene_association", use_cache = TRUE, on_error = "warn") + re <- fetch_reactome(species, source = "gene_association", use_cache = TRUE, on_error = "ignore") if(!is.null(re)) { expect_is(re, "list") expect_length(re, 2) @@ -118,7 +118,7 @@ expected_api <- tibble::tribble( ) test_that("Correct Reactome API from M. tuberculosis", { - re <- fetch_reactome(species = small_species, source = "api", on_error = "warn") + re <- fetch_reactome(species = small_species, source = "api", on_error = "ignore") mapping <- re$mapping if(!is.null(mapping)) { expect_is(mapping, "tbl") diff --git a/tests/testthat/test_wiki.R b/tests/testthat/test_wiki.R index 1ba3011..335e886 100644 --- a/tests/testthat/test_wiki.R +++ b/tests/testthat/test_wiki.R @@ -42,7 +42,7 @@ test_that("Expected behaviour from a non-responsive server", { test_that("Expected return from fetch_wiki_species", { expected_selection <- c("Homo sapiens", "Mus musculus", "Rattus norvegicus", "Saccharomyces cerevisiae", "Drosophila melanogaster", "Caenorhabditis elegans") - spec <- fetch_wiki_species(on_error = "warn") + spec <- fetch_wiki_species(on_error = "ignore") if(!is.null(spec)) { expect_is(spec, "tbl") expect_true(all(expected_selection %in% spec$designation)) @@ -70,7 +70,7 @@ test_that("WikiPathways correct response", { "WP1527", "sinI" ) - re <- fetch_wiki(species, databases = databases, types = types, on_error = "warn") + re <- fetch_wiki(species, databases = databases, types = types, on_error = "ignore") if(!is.null(re)) { test_fetched_structure(re) test_terms(re$terms, expected_terms)