diff --git a/R/interpretive_rules.R b/R/interpretive_rules.R index 3dbdab677..8a3338864 100755 --- a/R/interpretive_rules.R +++ b/R/interpretive_rules.R @@ -200,6 +200,12 @@ interpretive_rules <- function(x, add_MO_lookup_to_AMR_env() + if (guideline %like% "EUCAST") { + guideline <- "EUCAST" + } else if (guideline %like% "CLSI") { + guideline <- "CLSI" + } + if ("custom" %in% rules && is.null(custom_rules)) { warning_("in {.help [{.fun interpretive_rules}](AMR::interpretive_rules)}: no custom rules were set with the {.arg custom_rules} argument", immediate = TRUE @@ -619,18 +625,9 @@ interpretive_rules <- function(x, } else if (!is.null(list(...)$eucast_rules_df)) { # deprecated parameter name kept for backward compatibility interpretive_rules_df_total <- list(...)$eucast_rules_df - } else if (exists("INTERPRETIVE_RULES_DF", envir = asNamespace("AMR"), inherits = FALSE)) { + } else { # internal data file, created in data-raw/_pre_commit_checks.R interpretive_rules_df_total <- INTERPRETIVE_RULES_DF - } else { - # transitional fallback: sysdata.rda predates the rename from EUCAST_RULES_DF - # re-run data-raw/_pre_commit_checks.R to regenerate sysdata.rda - interpretive_rules_df_total <- EUCAST_RULES_DF - interpretive_rules_df_total$rule.provider <- "EUCAST" - interpretive_rules_df_total <- interpretive_rules_df_total[ - , c("rule.provider", setdiff(colnames(interpretive_rules_df_total), "rule.provider")), - drop = FALSE - ] } ## filter on guideline provider and user-set guideline versions ---- diff --git a/tests/testthat/test-_deprecated.R b/tests/testthat/test-_deprecated.R index bf08e57f7..656f9f8ef 100644 --- a/tests/testthat/test-_deprecated.R +++ b/tests/testthat/test-_deprecated.R @@ -32,4 +32,11 @@ test_that("test-_deprecated.R", { expect_warning(example_isolates[, ab_class("mycobact")]) expect_warning(example_isolates[, ab_selector(name %like% "trim")]) + + # deprecated custom_interpretive_rules() still works and emits a warning + expect_warning( + x_old <- custom_eucast_rules(AMC == "R" ~ aminopenicillins == "R"), + regexp = "custom_eucast_rules" + ) + expect_inherits(x_old, "custom_interpretive_rules") }) diff --git a/tests/testthat/test-data.R b/tests/testthat/test-data.R index daa7070e6..7d4afb8f0 100644 --- a/tests/testthat/test-data.R +++ b/tests/testthat/test-data.R @@ -53,12 +53,12 @@ test_that("test-data.R", { expect_false(anyNA(microorganisms.codes$mo)) expect_true(all(dosage$ab %in% AMR::antimicrobials$ab)) expect_true(all(dosage$name %in% AMR::antimicrobials$name)) - eucast_abx <- AMR:::EUCAST_RULES_DF$and_these_antibiotics - eucast_abx <- unique(unlist(strsplit(eucast_abx[!is.na(eucast_abx)], ", +"))) - expect_true(all(eucast_abx %in% AMR::antimicrobials$ab), + interpretive_abx <- AMR:::INTERPRETIVE_RULES_DF$and_these_antibiotics + interpretive_abx <- unique(unlist(strsplit(interpretive_abx[!is.na(interpretive_abx)], ", +"))) + expect_true(all(interpretive_abx %in% AMR::antimicrobials$ab), info = paste0( "Missing in `antimicrobials` data set: ", - toString(eucast_abx[which(!eucast_abx %in% AMR::antimicrobials$ab)]) + toString(interpretive_abx[which(!interpretive_abx %in% AMR::antimicrobials$ab)]) ) ) diff --git a/tests/testthat/test-interpretive_rules.R b/tests/testthat/test-interpretive_rules.R index 3e70f6a1f..f29fda12d 100755 --- a/tests/testthat/test-interpretive_rules.R +++ b/tests/testthat/test-interpretive_rules.R @@ -242,13 +242,6 @@ test_that("test-interpretive_rules.R", { tolerance = 0.5 ) - # deprecated custom_interpretive_rules() still works and emits a warning - expect_warning( - x_old <- custom_interpretive_rules(AMC == "R" ~ aminopenicillins == "R"), - regexp = "custom_interpretive_rules" - ) - expect_inherits(x_old, "custom_interpretive_rules") - # clsi_rules() no longer errors (returns data unchanged until CLSI rows are added) expect_identical( suppressWarnings(clsi_rules(example_isolates, info = FALSE)),