1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 23:21:56 +02:00

(v1.2.0.9035) as.mo() speed improvement

This commit is contained in:
2020-07-22 10:24:23 +02:00
parent 6ab468362d
commit 09fba38ea6
37 changed files with 174 additions and 441 deletions

View File

@ -38,6 +38,7 @@ test_that("data sets are valid", {
expect_true(all(rsi_translation$mo %in% microorganisms$mo))
expect_false(any(is.na(microorganisms.codes$code)))
expect_false(any(is.na(microorganisms.codes$mo)))
expect_false(any(microorganisms.translation$mo_old %in% microorganisms$mo))
# antibiotic names must always be coercible to their original AB code
expect_identical(antibiotics$ab, as.ab(antibiotics$name))
@ -62,10 +63,7 @@ test_that("creation of data sets is valid", {
olddf <- create_MO.old_lookup()
expect_true(all(c("fullname", "fullname_new", "ref", "prevalence",
"fullname_lower", "g_species") %in% colnames(olddf)))
old <- make_trans_tbl()
expect_gt(length(old), 0)
})
test_that("CoL version info works", {

View File

@ -24,6 +24,8 @@ context("mo.R")
test_that("as.mo works", {
skip_on_cran()
library(dplyr)
MOs <- microorganisms %>% filter(!is.na(mo), nchar(mo) > 3)
expect_identical(as.character(MOs$mo), as.character(as.mo(MOs$mo)))
@ -50,7 +52,6 @@ test_that("as.mo works", {
expect_equal(as.character(as.mo("Streptococcus")), "B_STRPT") # not Peptostreptoccus
expect_equal(as.character(as.mo("Estreptococos grupo B")), "B_STRPT_GRPB")
expect_equal(as.character(as.mo("Group B Streptococci")), "B_STRPT_GRPB")
expect_equal(as.character(suppressWarnings(as.mo("B_STRPTC"))), "B_STRPT") # old MO code (<=v0.5.0)
expect_equal(as.character(suppressWarnings(as.mo("B_STRPT_PNE"))), "B_STRPT_PNMN") # old MO code (<=v0.8.0)
expect_equal(as.character(as.mo(c("GAS", "GBS"))), c("B_STRPT_GRPA", "B_STRPT_GRPB"))
@ -144,9 +145,7 @@ test_that("as.mo works", {
expect_identical(as.character(as.mo("S. sanguinis", Lancefield = TRUE)), "B_STRPT_GRPH") # group H
expect_identical(as.character(as.mo("S. salivarius", Lancefield = FALSE)), "B_STRPT_SLVR")
expect_identical(as.character(as.mo("S. salivarius", Lancefield = TRUE)), "B_STRPT_GRPK") # group K
library(dplyr)
# select with one column
expect_identical(
example_isolates[1:10, ] %>%
@ -259,11 +258,7 @@ test_that("as.mo works", {
expect_true(example_isolates %>% pull(mo) %>% is.mo())
expect_error(translate_allow_uncertain(5))
# very old MO codes (<= v0.5.0)
expect_equal(suppressWarnings(as.character(as.mo("F_CCCCS_NEO"))), "F_CRYPT_NFRM")
expect_equal(suppressWarnings(as.character(as.mo("F_CANDD_GLB"))), "F_CANDD_GLBR")
# debug mode
expect_output(print(suppressMessages(suppressWarnings(as.mo("kshgcjkhsdgkshjdfsfvsdfv", debug = TRUE, allow_uncertain = 3)))))