diff --git a/NEWS.md b/NEWS.md index 3c101a6..dc0f518 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,7 @@ * Bump version for Bioc 3.19. * Use GHCR instead of Dockerhub, update vignette accordingly. +* Increase code coverage. ## Bug fixes diff --git a/R/all_species.R b/R/all_species.R index 36b0ea6..4910e98 100644 --- a/R/all_species.R +++ b/R/all_species.R @@ -17,7 +17,7 @@ #' @examples #' species_dt <- all_species() all_species <- function(method = NULL, - verbose = TRUE) { + verbose = TRUE) { if(is.null(method)){ method <- eval(formals(map_species)$method) } diff --git a/R/earthworm2human_map.R b/R/earthworm2human_map.R index 9750feb..697f760 100644 --- a/R/earthworm2human_map.R +++ b/R/earthworm2human_map.R @@ -30,12 +30,15 @@ earthworm2human_map <- function(evalue_threshold = NULL, requireNamespace("piggyback") file <- "ea_to_hu.csv.gz" - dir.create(save_dir,showWarnings = FALSE, recursive = TRUE) tmp <- file.path(save_dir,file) - piggyback::pb_download(file = file, - repo = "neurogenomics/orthogene", - dest = save_dir) - get_data_check(tmp = tmp) + if(!file.exists(tmp)){ + dir.create(save_dir,showWarnings = FALSE, recursive = TRUE) + piggyback::pb_download(file = file, + repo = "neurogenomics/orthogene", + dest = save_dir, + tag = "v1.1.1") + get_data_check(tmp = tmp) + } gene_map <- data.table::fread(tmp) #### Filter evalue #### if(!is.null(evalue_threshold)){ diff --git a/R/get_all_orgs.R b/R/get_all_orgs.R index 42dca42..e7b40a6 100644 --- a/R/get_all_orgs.R +++ b/R/get_all_orgs.R @@ -43,7 +43,7 @@ get_all_orgs <- function(method = c( #### method: genomeinfodb #### } else if (tolower(method) == "genomeinfodb") { #### Load a really big organism reference #### - orgs <- rbind(orgs, get_orgdb_genomeinfodbdata(verbose = verbose)) + orgs <- get_orgdb_genomeinfodbdata(verbose = verbose) orgs$source <- "genomeinfodb" #### Error #### } else { diff --git a/R/get_orgdb_genomeinfodbdata.R b/R/get_orgdb_genomeinfodbdata.R index 7a83915..dccfa0e 100644 --- a/R/get_orgdb_genomeinfodbdata.R +++ b/R/get_orgdb_genomeinfodbdata.R @@ -15,11 +15,12 @@ get_orgdb_genomeinfodbdata <- function(verbose = TRUE) { # Avoid confusing biocheck scientific_name <- display_name <- genus <- NULL - species <- id <- version <- ..keep_cols <- NULL + species <- id <- version <- NULL messager("Preparing organisms reference from: GenomeInfoDb", v = verbose) requireNamespace("GenomeInfoDbData") - utils::data("specData") + utils::data("specData",package = "GenomeInfoDbData") + specData <- data.table::as.data.table(get("specData")) #### Remove NAs #### no_no_list <- c("environmental", "unclassified", NA) specData <- specData[(!genus %in% no_no_list) & @@ -38,6 +39,6 @@ get_orgdb_genomeinfodbdata <- function(verbose = TRUE) { "display_name", "id", "scientific_name", "taxonomy_id", "version" ) - specData <- unique(specData[, ..keep_cols]) + specData <- unique(specData[, keep_cols, with=FALSE]) return(specData) } diff --git a/tests/testthat/test-all_species.R b/tests/testthat/test-all_species.R new file mode 100644 index 0000000..c09ea3f --- /dev/null +++ b/tests/testthat/test-all_species.R @@ -0,0 +1,10 @@ +test_that("all_species works", { + + species_dt <- all_species() + testthat::expect_gte(nrow(species_dt), 700) + + if(rworkflows::is_gha()){ + species_dt <- all_species(method="genomeinfodb") + testthat::expect_gte(nrow(species_dt), 2e6) # over 2.5 million species! + } +}) diff --git a/tests/testthat/test-earthworm2human_map.R b/tests/testthat/test-earthworm2human_map.R new file mode 100644 index 0000000..24ec57e --- /dev/null +++ b/tests/testthat/test-earthworm2human_map.R @@ -0,0 +1,6 @@ +test_that("earthworm2human_map works", { + + map <- orthogene:::earthworm2human_map() + testthat::expect_gte(nrow(map), 4.6e5) + testthat::expect_true(all(grepl("^evm",map$qseqid))) +})