Skip to content

Commit

Permalink
Catching errors and notes
Browse files Browse the repository at this point in the history
  • Loading branch information
MarekGierlinski committed Jun 14, 2024
1 parent 4cfaf71 commit 835e657
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
9 changes: 5 additions & 4 deletions R/go.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,17 @@ parse_obo_file <- function(obo) {
#' @noRd
extract_obo_terms <- function(parsed) {
# Binding variables from non-standard evaluation locally
key <- term_id <- value <- term_name <- NULL
key <- term_id <- value <- name <- term_name <- namespace <- NULL

terms <- parsed |>
dplyr::filter(key == "name") |>
dplyr::select(term_id, term_name = value)
dplyr::filter(key %in% c("name", "namespace")) |>
tidyr::pivot_wider(id_cols = term_id, names_from = key, values_from = value) |>
dplyr::rename(term_name = name)

alt_terms <- parsed |>
dplyr::filter(key == "alt_id") |>
dplyr::left_join(terms, by = "term_id") |>
dplyr::select(term_id = value, term_name)
dplyr::select(term_id = value, term_name, namespace)

dplyr::bind_rows(
terms,
Expand Down
9 changes: 1 addition & 8 deletions tests/testthat/test_go.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,9 @@ test_that("Incorrect species in fetch_go", {
expect_error(fetch_go(species = "not a species"))
})


test_that("Incorrect mart in fetch_go", {
expect_error(fetch_go(mart = 1))
expect_error(fetch_go(mart = "mart"))
})


test_that("Incorrect dataset triggers error", {
expect_error(fetch_go(dataset = "not a dataset"))
expect_error(fetch_go_from_bm(dataset = "not a dataset"))
expect_error(fetch_go_from_bm(dataset = "not a dataset", use_cache = FALSE, on_error = "stop"))
})

test_that("Processing OBO file", {
Expand Down

0 comments on commit 835e657

Please sign in to comment.