1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 10:31:53 +02:00

algoritm improvement, removed all Catabacter except for C. hongkongensis

This commit is contained in:
2018-09-10 11:40:54 +02:00
parent 4816419f0c
commit b83e6a9380
9 changed files with 56 additions and 11 deletions

View File

@ -4,9 +4,7 @@ test_that("as.mo works", {
library(dplyr)
MOs <- AMR::microorganisms %>% filter(!is.na(mo))
expect_identical(as.character(MOs$mo), as.character(as.mo(MOs$mo)))
expect_identical(MOs$fullname, mo_fullname(MOs$fullname, language = "en"))
expect_identical(
as.character(as.mo(c("E. coli", "H. influenzae"))),
@ -21,6 +19,9 @@ test_that("as.mo works", {
expect_equal(as.character(as.mo("K. pneu rhino")), "KLEPNERH") # K. pneumoniae subspp. rhinoscleromatis
expect_equal(as.character(as.mo("Bartonella")), "BAR")
expect_equal(as.character(as.mo("C. difficile")), "CLODIF")
expect_equal(as.character(as.mo("L. pneumophila")), "LEGPNE")
expect_equal(as.character(as.mo("L. non pneumophila")), "LEGNON")
expect_equal(as.character(as.mo("S. beta-haemolytic")), "STCHAE")
expect_equal(as.character(as.mo("S. pyo")), "STCPYO") # not Actinomyces pyogenes

View File

@ -22,4 +22,27 @@ test_that("mo_property works", {
expect_equal(mo_gramstain("E. coli", language = "nl"), "Negatieve staven")
expect_error(mo_type("E. coli", language = "INVALID"))
# test integrity
library(dplyr)
MOs <- AMR::microorganisms %>% filter(!is.na(mo))
expect_identical(MOs$fullname, mo_fullname(MOs$fullname, language = "en"))
mo_clean <- MOs$mo
mo_from_shortname <- as.mo(mo_shortname(mo_clean))
mo_clean <- mo_clean[nchar(mo_from_shortname) == 6 &
!is.na(mo_from_shortname) &
!mo_from_shortname %like% "...SPP"]
mo_from_shortname <- mo_from_shortname[nchar(mo_from_shortname) == 6 &
!is.na(mo_from_shortname) &
!mo_from_shortname %like% "...SPP"]
tb <- tibble(a = substr(mo_clean, 1, 6),
b = mo_from_shortname,
c = a == b,
d = mo_shortname(a),
e = mo_shortname(b),
f = d == e)
expect_gt(sum(tb$c) / nrow(tb), 0.9) # more than 90% of MO code should be identical
expect_identical(sum(tb$f), nrow(tb)) # all shortnames should be identical
})