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

first inclusion of ITIS data

This commit is contained in:
2018-09-24 23:33:29 +02:00
parent df5d82fff3
commit 9c566585b0
29 changed files with 734 additions and 466 deletions

View File

@ -1,6 +1,7 @@
context("mo_property.R")
test_that("mo_property works", {
expect_equal(mo_subkingdom("E. coli"), "Negibacteria")
expect_equal(mo_phylum("E. coli"), "Proteobacteria")
expect_equal(mo_class("E. coli"), "Gammaproteobacteria")
expect_equal(mo_order("E. coli"), "Enterobacteriales")
@ -10,8 +11,7 @@ test_that("mo_property works", {
expect_equal(mo_subspecies("E. coli"), "")
expect_equal(mo_fullname("E. coli"), "Escherichia coli")
expect_equal(mo_type("E. coli", language = "en"), "Bacteria")
expect_equal(mo_gramstain("E. coli", language = "en"), "Negative rods")
expect_equal(mo_aerobic("E. coli"), TRUE)
expect_equal(mo_gramstain("E. coli", language = "en"), "Gram negative")
expect_equal(class(mo_taxonomy("E. coli")), "list")
expect_equal(mo_shortname("MRSA"), "S. aureus")
@ -22,30 +22,16 @@ test_that("mo_property works", {
# test integrity
library(dplyr)
MOs <- AMR::microorganisms %>% filter(!is.na(mo), nchar(mo) > 3)
rnd <- sample(1:nrow(AMR::microorganisms), 500, replace = FALSE) # random 500 rows
MOs <- AMR::microorganisms %>% filter(!is.na(mo),
species != "species",
dplyr::row_number() %in% rnd)
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
# 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_equal(mo_type("E. coli", language = "de"), "Bakterien")
expect_equal(mo_type("E. coli", language = "nl"), "Bacteri\u00ebn")
expect_equal(mo_gramstain("E. coli", language = "nl"), "Gram-negatief")
expect_output(print(mo_gramstain("E. coli", language = "en")))
expect_output(print(mo_gramstain("E. coli", language = "de")))