mirror of
https://github.com/msberends/AMR.git
synced 2026-11-16 02:20:49 +01:00
Keep only EUCAST blocking rows that have an effect on as.sir() (#326)
The new internal blocking_row_is_needed() defines this: as.sir() must give another result without the row, so the definition follows the fallback path of as.sir() itself. The build removes all rows without an effect, and the new strict test checks all rows of the latest guideline, and for all years that a blocking row has a breakpoint to block. This replaces the separate taxonomic comparison, handles the points of the review on this pruning, and keeps the sites of blocking rows, which `site` in as.sir() now uses.
This commit is contained in:
1 parent
472c84d20d
commit
fbdfb0a071
4 files changed
+106
-82
No files matched your search
@@ -617,6 +617,36 @@ test_that("clinical_breakpoints: screening tests are under screening agents (#32
|
||||
expect_identical(unname(as.list(ery("ERY-S"))), unname(as.list(ery("ERY"))))
|
||||
})
|
||||
|
||||
test_that("clinical_breakpoints: every blocking row of EUCAST has an effect (#326)", {
|
||||
skip_on_cran()
|
||||
cb <- as.data.frame(clinical_breakpoints, stringsAsFactors = FALSE)
|
||||
cb <- cb[cb$type == "human" & grepl("EUCAST 20(19|2[0-9])", cb$guideline), , drop = FALSE]
|
||||
is_blocking <- is.na(cb$breakpoint_S) & is.na(cb$breakpoint_R)
|
||||
key <- paste(cb$guideline, cb$ab, cb$method)
|
||||
# a blocking row needs a breakpoint to block, for all years
|
||||
has_breakpoint <- key %in% key[!is_blocking]
|
||||
wrong <- unique(key[is_blocking & !has_breakpoint])
|
||||
expect_true(length(wrong) == 0, info = paste("no breakpoints to block:", toString(utils::head(wrong, 20))))
|
||||
# and as.sir() must give another result without it, for the latest guideline; all years are checked during the build
|
||||
latest <- paste0("EUCAST ", max(as.integer(gsub("[^0-9]", "", cb$guideline))))
|
||||
for (k in unique(key[is_blocking & cb$guideline == latest])) {
|
||||
group <- cb[key == k, , drop = FALSE]
|
||||
for (i in which(is.na(group$breakpoint_S) & is.na(group$breakpoint_R))) {
|
||||
expect_true(blocking_row_is_needed(i, group), info = paste(k, group$mo[i], group$site[i]))
|
||||
}
|
||||
}
|
||||
# the definition itself, on a constructed set of rows
|
||||
rows <- cb[cb$guideline == latest & as.character(cb$ab) == "CTX" & cb$method == "MIC" & as.character(cb$mo) == "B_VIBRI", , drop = FALSE][1, ]
|
||||
blocker <- rows
|
||||
blocker$mo <- as.mo("Vibrio fluvialis", info = FALSE)
|
||||
blocker$rank_index <- 2.1
|
||||
blocker$breakpoint_S <- NA_real_
|
||||
blocker$breakpoint_R <- NA_real_
|
||||
group <- rbind(rows, blocker)
|
||||
expect_true(blocking_row_is_needed(2, group))
|
||||
expect_false(blocking_row_is_needed(1, blocker))
|
||||
})
|
||||
|
||||
test_that("clinical_breakpoints: EUCAST breakpoints stated in the Notes (#329)", {
|
||||
skip_on_cran()
|
||||
cb <- as.data.frame(clinical_breakpoints, stringsAsFactors = FALSE)
|
||||
|
||||
Reference in new issue
Block a user