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 #
|
2020-01-05 17:22:09 +01:00
|
|
|
# (c) 2018-2020 Berends MS, Luz CF et al. #
|
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. #
|
|
|
|
# #
|
2020-01-05 17:22:09 +01:00
|
|
|
# We created this package for both routine data analysis and academic #
|
|
|
|
# research and it was publicly released in the hope that it will be #
|
|
|
|
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
|
2019-04-05 18:47:39 +02:00
|
|
|
# Visit our website for more info: https://msberends.gitlab.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", {
|
2019-10-15 14:35:23 +02:00
|
|
|
|
|
|
|
skip_on_cran()
|
|
|
|
|
2019-06-16 21:42:40 +02:00
|
|
|
expect_equal(mo_kingdom("Escherichia coli"), "Bacteria")
|
2020-06-22 11:18:40 +02:00
|
|
|
expect_equal(mo_kingdom("Escherichia coli"), mo_domain("Escherichia coli"))
|
2019-06-16 21:42:40 +02:00
|
|
|
expect_equal(mo_phylum("Escherichia coli"), "Proteobacteria")
|
|
|
|
expect_equal(mo_class("Escherichia coli"), "Gammaproteobacteria")
|
2019-10-30 23:02:50 +01:00
|
|
|
expect_equal(mo_order("Escherichia coli"), "Enterobacterales")
|
2019-06-16 21:42:40 +02:00
|
|
|
expect_equal(mo_family("Escherichia coli"), "Enterobacteriaceae")
|
|
|
|
expect_equal(mo_genus("Escherichia coli"), "Escherichia")
|
|
|
|
expect_equal(mo_species("Escherichia coli"), "coli")
|
|
|
|
expect_equal(mo_subspecies("Escherichia coli"), "")
|
|
|
|
expect_equal(mo_fullname("Escherichia coli"), "Escherichia coli")
|
|
|
|
expect_equal(mo_name("Escherichia coli"), "Escherichia coli")
|
|
|
|
expect_equal(mo_type("Escherichia coli", language = "en"), "Bacteria")
|
|
|
|
expect_equal(mo_gramstain("Escherichia coli", language = "en"), "Gram-negative")
|
|
|
|
expect_equal(class(mo_taxonomy("Escherichia coli")), "list")
|
|
|
|
expect_equal(names(mo_taxonomy("Escherichia coli")), c("kingdom", "phylum", "class", "order",
|
2018-09-27 23:23:48 +02:00
|
|
|
"family", "genus", "species", "subspecies"))
|
2019-06-16 21:42:40 +02:00
|
|
|
expect_equal(mo_synonyms("Escherichia coli"), NULL)
|
2019-06-22 14:49:12 +02:00
|
|
|
expect_gt(length(mo_synonyms("Candida albicans")), 1)
|
|
|
|
expect_equal(class(mo_synonyms(c("Candida albicans", "Escherichia coli"))), "list")
|
2019-06-16 21:42:40 +02:00
|
|
|
expect_equal(names(mo_info("Escherichia coli")), c("kingdom", "phylum", "class", "order",
|
2019-06-11 14:18:25 +02:00
|
|
|
"family", "genus", "species", "subspecies",
|
2019-11-28 23:00:37 +01:00
|
|
|
"synonyms", "gramstain", "url", "ref"))
|
2019-06-22 14:49:12 +02:00
|
|
|
expect_equal(class(mo_info(c("Escherichia coli", "Staphylococcus aureus"))), "list")
|
2018-10-01 14:44:40 +02:00
|
|
|
|
2019-06-16 21:42:40 +02:00
|
|
|
expect_equal(mo_ref("Escherichia coli"), "Castellani et al., 1919")
|
|
|
|
expect_equal(mo_authors("Escherichia coli"), "Castellani et al.")
|
|
|
|
expect_equal(mo_year("Escherichia coli"), 1919)
|
2018-09-04 11:33:30 +02:00
|
|
|
|
2019-06-16 21:42:40 +02:00
|
|
|
expect_equal(mo_shortname("Escherichia coli"), "E. coli")
|
2019-07-10 21:36:51 +02:00
|
|
|
expect_equal(mo_shortname("Escherichia"), "E. spp.")
|
2019-06-16 21:42:40 +02:00
|
|
|
expect_equal(mo_shortname("Staphylococcus aureus"), "S. aureus")
|
|
|
|
expect_equal(mo_shortname("Staphylococcus aureus", Becker = TRUE), "S. aureus")
|
|
|
|
expect_equal(mo_shortname("Staphylococcus aureus", Becker = "all", language = "en"), "CoPS")
|
|
|
|
expect_equal(mo_shortname("Streptococcus agalactiae"), "S. agalactiae")
|
|
|
|
expect_equal(mo_shortname("Streptococcus agalactiae", Lancefield = TRUE), "GBS")
|
2018-09-05 10:51:46 +02:00
|
|
|
|
2019-10-11 17:21:02 +02:00
|
|
|
expect_true(mo_url("Escherichia coli") %like% "www.catalogueoflife.org")
|
2019-05-13 12:21:57 +02:00
|
|
|
|
2018-09-10 11:40:54 +02:00
|
|
|
# test integrity
|
2020-02-14 19:54:13 +01:00
|
|
|
MOs <- microorganisms
|
2018-09-27 23:23:48 +02:00
|
|
|
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
|
2019-06-16 21:42:40 +02:00
|
|
|
expect_equal(mo_type("Escherichia coli", language = "de"), "Bakterien")
|
|
|
|
expect_equal(mo_gramstain("Escherichia coli", language = "nl"), "Gram-negatief")
|
2018-09-10 15:45:25 +02:00
|
|
|
|
2019-06-16 21:42:40 +02:00
|
|
|
expect_output(print(mo_gramstain("Escherichia coli", language = "en")))
|
|
|
|
expect_output(print(mo_gramstain("Escherichia coli", language = "de")))
|
|
|
|
expect_output(print(mo_gramstain("Escherichia coli", language = "nl")))
|
|
|
|
expect_output(print(mo_gramstain("Escherichia coli", language = "es")))
|
|
|
|
expect_output(print(mo_gramstain("Escherichia coli", language = "pt")))
|
|
|
|
expect_output(print(mo_gramstain("Escherichia coli", language = "it")))
|
|
|
|
expect_output(print(mo_gramstain("Escherichia coli", language = "fr")))
|
2018-09-10 15:45:25 +02:00
|
|
|
|
2019-06-16 21:42:40 +02:00
|
|
|
expect_error(mo_gramstain("Escherichia coli", language = "UNKNOWN"))
|
2018-09-10 15:45:25 +02:00
|
|
|
|
2018-10-09 15:41:44 +02:00
|
|
|
# manual property function
|
2019-06-16 21:42:40 +02:00
|
|
|
expect_error(mo_property("Escherichia coli", property = c("tsn", "fullname")))
|
|
|
|
expect_error(mo_property("Escherichia coli", property = "UNKNOWN"))
|
|
|
|
expect_identical(mo_property("Escherichia coli", property = "fullname"),
|
|
|
|
mo_fullname("Escherichia coli"))
|
|
|
|
expect_identical(mo_property("Escherichia coli", property = "genus"),
|
|
|
|
mo_genus("Escherichia coli"))
|
|
|
|
expect_identical(mo_property("Escherichia coli", property = "species"),
|
|
|
|
mo_species("Escherichia coli"))
|
2018-10-09 15:41:44 +02:00
|
|
|
|
2019-02-21 23:32:30 +01:00
|
|
|
expect_identical(suppressWarnings(mo_ref("Chlamydia psittaci")), "Page, 1968")
|
|
|
|
expect_identical(mo_ref("Chlamydophila psittaci"), "Everett et al., 1999")
|
|
|
|
|
2020-05-27 16:37:49 +02:00
|
|
|
expect_equal(mo_snomed("Escherichia coli"), 112283007)
|
2020-01-27 19:14:23 +01:00
|
|
|
|
2019-09-23 20:55:54 +02:00
|
|
|
# old codes must throw a warning in mo_* family
|
|
|
|
expect_warning(mo_name(c("B_ESCHR_COL", "B_STPHY_AUR")))
|
|
|
|
|
2019-02-27 17:39:39 +01:00
|
|
|
# outcome of mo_fullname must always return the fullname from the data set
|
2020-05-16 13:05:47 +02:00
|
|
|
x <- data.frame(mo = microorganisms$mo,
|
|
|
|
# fullname from the original data:
|
|
|
|
f1 = microorganisms$fullname,
|
|
|
|
# newly created fullname based on MO code:
|
|
|
|
f2 = mo_fullname(microorganisms$mo, language = "en"),
|
|
|
|
stringsAsFactors = FALSE)
|
|
|
|
expect_equal(nrow(subset(x, f1 != f2)), 0)
|
|
|
|
|
2018-08-28 13:51:13 +02:00
|
|
|
})
|