2018-12-16 22:45:12 +01:00
|
|
|
# ==================================================================== #
|
|
|
|
# TITLE #
|
|
|
|
# Antimicrobial Resistance (AMR) Analysis #
|
|
|
|
# #
|
2019-01-02 23:24:07 +01:00
|
|
|
# SOURCE #
|
|
|
|
# https://gitlab.com/msberends/AMR #
|
2018-12-16 22:45:12 +01:00
|
|
|
# #
|
|
|
|
# LICENCE #
|
2019-01-02 23:24:07 +01:00
|
|
|
# (c) 2019 Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) #
|
2018-12-16 22:45:12 +01:00
|
|
|
# #
|
2019-01-02 23:24:07 +01:00
|
|
|
# This R package is free software; you can freely use and distribute #
|
|
|
|
# it for both personal and commercial purposes under the terms of the #
|
|
|
|
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
|
|
|
|
# the Free Software Foundation. #
|
|
|
|
# #
|
|
|
|
# This R package was created for academic research and was publicly #
|
|
|
|
# released in the hope that it will be useful, but it comes WITHOUT #
|
|
|
|
# ANY WARRANTY OR LIABILITY. #
|
|
|
|
# Visit our website for more info: https://msberends.gitab.io/AMR. #
|
2018-12-16 22:45:12 +01:00
|
|
|
# ==================================================================== #
|
|
|
|
|
2018-08-28 13:51:13 +02:00
|
|
|
context("mo_property.R")
|
|
|
|
|
|
|
|
test_that("mo_property works", {
|
2018-11-09 13:11:54 +01:00
|
|
|
expect_equal(mo_kingdom("E. coli"), "Bacteria")
|
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")
|
2019-02-18 02:33:37 +01: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")
|
2018-09-24 23:33:29 +02:00
|
|
|
expect_equal(mo_gramstain("E. coli", language = "en"), "Gram negative")
|
2018-09-17 21:51:21 +02:00
|
|
|
expect_equal(class(mo_taxonomy("E. coli")), "list")
|
2019-02-18 02:33:37 +01:00
|
|
|
expect_equal(names(mo_taxonomy("E. coli")), c("kingdom", "phylum", "class", "order",
|
2018-09-27 23:23:48 +02:00
|
|
|
"family", "genus", "species", "subspecies"))
|
2018-10-01 14:44:40 +02:00
|
|
|
|
2019-02-18 02:33:37 +01:00
|
|
|
expect_equal(mo_ref("E. coli"), "(Migula, 1895) Castellani and Chalmers, 1919")
|
|
|
|
expect_equal(mo_authors("E. coli"), "(Migula) Castellani and Chalmers")
|
2018-12-10 21:47:25 +01:00
|
|
|
expect_equal(mo_year("E. coli"), 1919)
|
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")
|
2018-11-05 13:20:32 +01:00
|
|
|
expect_equal(mo_shortname("MRSA", Becker = "all", language = "en"), "CoPS")
|
2019-02-18 02:33:37 +01:00
|
|
|
expect_equal(mo_shortname("S. agalac"), "S. agalactiae")
|
|
|
|
expect_equal(mo_shortname("S. agalac", Lancefield = TRUE), "GBS")
|
2018-09-05 10:51:46 +02:00
|
|
|
|
2018-09-10 11:40:54 +02:00
|
|
|
# test integrity
|
2018-09-27 23:23:48 +02:00
|
|
|
MOs <- AMR::microorganisms
|
|
|
|
expect_identical(MOs$fullname, mo_fullname(MOs$fullname, language = "en"))
|
2018-09-10 11:40:54 +02:00
|
|
|
|
2018-09-10 15:45:25 +02:00
|
|
|
# check languages
|
2018-09-24 23:33:29 +02:00
|
|
|
expect_equal(mo_type("E. coli", language = "de"), "Bakterien")
|
|
|
|
expect_equal(mo_gramstain("E. coli", language = "nl"), "Gram-negatief")
|
2018-09-10 15:45:25 +02:00
|
|
|
|
|
|
|
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-10-09 15:41:44 +02:00
|
|
|
# manual property function
|
|
|
|
expect_error(mo_property("E. coli", property = c("tsn", "fullname")))
|
|
|
|
expect_error(mo_property("E. coli", property = "UNKNOWN"))
|
|
|
|
expect_identical(mo_property("E. coli", property = "fullname"),
|
|
|
|
mo_fullname("E. coli"))
|
|
|
|
expect_identical(mo_property("E. coli", property = "genus"),
|
|
|
|
mo_genus("E. coli"))
|
|
|
|
expect_identical(mo_property("E. coli", property = "species"),
|
|
|
|
mo_species("E. coli"))
|
|
|
|
|
2018-10-31 12:10:49 +01:00
|
|
|
# check vector with random values
|
|
|
|
library(dplyr)
|
|
|
|
df_sample <- AMR::microorganisms %>% sample_n(100)
|
2018-11-06 16:41:59 +01:00
|
|
|
expect_identical(df_sample %>% pull(mo) %>% mo_fullname(language = "en"),
|
2018-10-31 12:10:49 +01:00
|
|
|
df_sample %>% pull(fullname))
|
|
|
|
|
2018-08-28 13:51:13 +02:00
|
|
|
})
|