1
0
mirror of https://github.com/msberends/AMR.git synced 2026-05-31 12:21:40 +02:00
This commit is contained in:
2026-05-01 19:05:14 +02:00
parent b6d80f9578
commit d805fece8c
4 changed files with 18 additions and 21 deletions

View File

@@ -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 ----

View File

@@ -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")
})

View File

@@ -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)])
)
)

View File

@@ -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)),