1
0
mirror of https://github.com/msberends/AMR.git synced 2025-09-03 20:49:43 +02:00

(v1.1.0.9004) lose dependencies

This commit is contained in:
2020-05-16 13:05:47 +02:00
parent 9fce546901
commit 7f3da74b17
111 changed files with 3211 additions and 2345 deletions

View File

@@ -24,24 +24,24 @@ context("eucast_rules.R")
test_that("EUCAST rules work", {
skip_on_cran()
# thoroughly check input table
expect_equal(colnames(eucast_rules_file),
c("if_mo_property", "like.is.one_of", "this_value",
"and_these_antibiotics", "have_these_values",
"then_change_these_antibiotics", "to_value",
"reference.rule", "reference.rule_group"))
expect_error(suppressWarnings(eucast_rules(example_isolates, col_mo = "Non-existing")))
expect_error(eucast_rules(x = "text"))
expect_error(eucast_rules(data.frame(a = "test")))
expect_error(eucast_rules(data.frame(mo = "test"), rules = "invalid rules set"))
expect_warning(eucast_rules(data.frame(mo = "Escherichia coli", vancomycin = "S", stringsAsFactors = TRUE)))
expect_identical(colnames(example_isolates),
colnames(suppressWarnings(eucast_rules(example_isolates))))
a <- data.frame(mo = c("Klebsiella pneumoniae",
"Pseudomonas aeruginosa",
"Enterobacter aerogenes"),
@@ -54,7 +54,7 @@ test_that("EUCAST rules work", {
stringsAsFactors = FALSE)
expect_identical(suppressWarnings(eucast_rules(a, "mo", info = FALSE)), b)
expect_identical(suppressWarnings(eucast_rules(a, "mo", info = TRUE)), b)
a <- data.frame(mo = c("Staphylococcus aureus",
"Streptococcus group A"),
COL = "-", # Colistin
@@ -64,7 +64,7 @@ test_that("EUCAST rules work", {
COL = "R", # Colistin
stringsAsFactors = FALSE)
expect_equal(suppressWarnings(eucast_rules(a, "mo", info = FALSE)), b)
# piperacillin must be R in Enterobacteriaceae when tica is R
library(dplyr)
expect_equal(suppressWarnings(
@@ -78,25 +78,17 @@ test_that("EUCAST rules work", {
unique() %>%
as.character()),
"R")
# Azithromicin and Clarythromycin must be equal to Erythromycin
a <- suppressWarnings(
example_isolates %>%
transmute(mo,
ERY,
AZM = as.rsi("R"),
CLR = as.rsi("R")) %>%
eucast_rules(col_mo = "mo") %>%
pull(CLR))
b <- suppressWarnings(
example_isolates %>%
select(mo, ERY) %>%
eucast_rules(col_mo = "mo") %>%
pull(ERY))
a <- eucast_rules(data.frame(mo = example_isolates$mo,
ERY = example_isolates$ERY,
AZM = as.rsi("R"),
CLR = as.rsi("R"),
stringsAsFactors = FALSE))$CLR
b <- example_isolates$ERY
expect_identical(a[!is.na(b)],
b[!is.na(b)])
# amox is inferred by benzylpenicillin in Kingella kingae
expect_equal(
suppressWarnings(
@@ -108,11 +100,11 @@ test_that("EUCAST rules work", {
, info = FALSE))$AMX
),
"S")
# also test norf
expect_output(suppressWarnings(eucast_rules(example_isolates %>% mutate(NOR = "S", NAL = "S"), info = TRUE)))
# check verbose output
expect_output(suppressWarnings(eucast_rules(example_isolates, verbose = TRUE, info = TRUE)))
})