Skip to content

Commit

Permalink
increase code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bschilder committed Dec 22, 2023
1 parent 021d37f commit bc242c5
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 10 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Bump version for Bioc 3.19.
* Use GHCR instead of Dockerhub, update vignette accordingly.
* Increase code coverage.

## Bug fixes

Expand Down
2 changes: 1 addition & 1 deletion R/all_species.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
13 changes: 8 additions & 5 deletions R/earthworm2human_map.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand Down
2 changes: 1 addition & 1 deletion R/get_all_orgs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions R/get_orgdb_genomeinfodbdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) &
Expand All @@ -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)
}
10 changes: 10 additions & 0 deletions tests/testthat/test-all_species.R
Original file line number Diff line number Diff line change
@@ -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!
}
})
6 changes: 6 additions & 0 deletions tests/testthat/test-earthworm2human_map.R
Original file line number Diff line number Diff line change
@@ -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)))
})

0 comments on commit bc242c5

Please sign in to comment.