2018-08-28 13:51:13 +02:00
|
|
|
context("mo_property.R")
|
|
|
|
|
|
|
|
test_that("mo_property works", {
|
2018-09-17 20:53:32 +02:00
|
|
|
expect_equal(mo_phylum("E. coli"), "Proteobacteria")
|
|
|
|
expect_equal(mo_class("E. coli"), "Gammaproteobacteria")
|
|
|
|
expect_equal(mo_order("E. coli"), "Enterobacteriales")
|
2018-08-28 13:51:13 +02:00
|
|
|
expect_equal(mo_family("E. coli"), "Enterobacteriaceae")
|
|
|
|
expect_equal(mo_genus("E. coli"), "Escherichia")
|
|
|
|
expect_equal(mo_species("E. coli"), "coli")
|
2018-09-05 12:21:27 +02:00
|
|
|
expect_equal(mo_subspecies("E. coli"), "")
|
2018-08-28 13:51:13 +02:00
|
|
|
expect_equal(mo_fullname("E. coli"), "Escherichia coli")
|
2018-09-08 16:06:47 +02:00
|
|
|
expect_equal(mo_type("E. coli", language = "en"), "Bacteria")
|
|
|
|
expect_equal(mo_gramstain("E. coli", language = "en"), "Negative rods")
|
2018-08-28 13:51:13 +02:00
|
|
|
expect_equal(mo_aerobic("E. coli"), TRUE)
|
2018-09-17 21:51:21 +02:00
|
|
|
expect_equal(class(mo_taxonomy("E. coli")), "list")
|
2018-09-04 11:33:30 +02:00
|
|
|
|
2018-09-05 10:51:46 +02:00
|
|
|
expect_equal(mo_shortname("MRSA"), "S. aureus")
|
|
|
|
expect_equal(mo_shortname("MRSA", Becker = TRUE), "S. aureus")
|
|
|
|
expect_equal(mo_shortname("MRSA", Becker = "all"), "CoPS")
|
|
|
|
expect_equal(mo_shortname("S. aga"), "S. agalactiae")
|
|
|
|
expect_equal(mo_shortname("S. aga", Lancefield = TRUE), "GBS")
|
|
|
|
|
2018-09-10 11:40:54 +02:00
|
|
|
# test integrity
|
|
|
|
library(dplyr)
|
2018-09-16 16:43:29 +02:00
|
|
|
MOs <- AMR::microorganisms %>% filter(!is.na(mo), nchar(mo) > 3)
|
2018-09-10 11:40:54 +02:00
|
|
|
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
|
|
|
|
|
2018-09-10 15:45:25 +02:00
|
|
|
# check languages
|
|
|
|
expect_equal(mo_type("E. coli", language = "de"), "Bakterium")
|
|
|
|
expect_equal(mo_type("E. coli", language = "nl"), "Bacterie")
|
|
|
|
expect_equal(mo_gramstain("E. coli", language = "nl"), "Negatieve staven")
|
|
|
|
|
|
|
|
expect_output(print(mo_gramstain("E. coli", language = "en")))
|
|
|
|
expect_output(print(mo_gramstain("E. coli", language = "de")))
|
|
|
|
expect_output(print(mo_gramstain("E. coli", language = "nl")))
|
|
|
|
expect_output(print(mo_gramstain("E. coli", language = "es")))
|
|
|
|
expect_output(print(mo_gramstain("E. coli", language = "pt")))
|
|
|
|
expect_output(print(mo_gramstain("E. coli", language = "it")))
|
|
|
|
expect_output(print(mo_gramstain("E. coli", language = "fr")))
|
|
|
|
|
|
|
|
expect_error(mo_gramstain("E. coli", language = "UNKNOWN"))
|
|
|
|
|
2018-08-28 13:51:13 +02:00
|
|
|
})
|