mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 11:11:54 +02:00
atc and bactid functions, readme update
This commit is contained in:
@ -5,7 +5,7 @@ test_that("abname works", {
|
||||
expect_equal(abname(c("AMOX", "GENT")), c("Amoxicillin", "Gentamicin"))
|
||||
expect_equal(abname(c("AMOX+GENT")), "Amoxicillin + gentamicin")
|
||||
expect_equal(abname("AMOX", from = 'umcg'), "Amoxicillin")
|
||||
expect_equal(abname("amox", from = 'molis', tolower = TRUE), "amoxicillin")
|
||||
expect_equal(abname("amox", from = 'certe', tolower = TRUE), "amoxicillin")
|
||||
expect_equal(abname("J01CA04", from = 'atc'), "Amoxicillin")
|
||||
expect_equal(abname(c("amox", "J01CA04", "Trimox", "dispermox", "Amoxil")),
|
||||
rep("Amoxicillin", 5))
|
||||
|
@ -22,14 +22,25 @@ test_that("atc_property works", {
|
||||
})
|
||||
|
||||
test_that("guess_atc works", {
|
||||
expect_equal(guess_atc(c("J01FA01",
|
||||
expect_equal(as.character(guess_atc(c("J01FA01",
|
||||
"Erythromycin",
|
||||
"eryt",
|
||||
"ERYT",
|
||||
"ERY",
|
||||
"Erythrocin",
|
||||
"Eryzole",
|
||||
"Pediamycin")),
|
||||
"Pediamycin"))),
|
||||
rep("J01FA01", 8))
|
||||
|
||||
expect_identical(class(as.atc("amox")), "atc")
|
||||
|
||||
|
||||
})
|
||||
|
||||
test_that("atc.property works", {
|
||||
expect_equal(atc.certe("J01CA04"), "amox")
|
||||
expect_equal(atc.umcg("J01CA04"), "AMOX")
|
||||
expect_equal(atc.official("J01CA04"), "Amoxicillin")
|
||||
expect_equal(atc.official_nl("J01CA04"), "Amoxicilline")
|
||||
expect_equal(atc.trivial_nl("J01CA04"), "Amoxicilline")
|
||||
})
|
||||
|
@ -108,3 +108,16 @@ test_that("as.bactid works", {
|
||||
NA_character_)
|
||||
|
||||
})
|
||||
|
||||
test_that("bactid.property works", {
|
||||
expect_equal(bactid.family("E. coli"), "Enterobacteriaceae")
|
||||
expect_equal(bactid.genus("E. coli"), "Escherichia")
|
||||
expect_equal(bactid.species("E. coli"), "coli")
|
||||
expect_equal(bactid.subspecies("E. coli"), NA_character_)
|
||||
expect_equal(bactid.fullname("E. coli"), "Escherichia coli")
|
||||
expect_equal(bactid.type("E. coli"), "Bacteria")
|
||||
expect_equal(bactid.gramstain("E. coli"), "Negative rods")
|
||||
expect_equal(bactid.aerobic("E. coli"), TRUE)
|
||||
expect_equal(bactid.type_nl("E. coli"), "Bacterie")
|
||||
expect_equal(bactid.gramstain_nl("E. coli"), "Negatieve staven")
|
||||
})
|
||||
|
@ -32,8 +32,3 @@ test_that("EUCAST rules work", {
|
||||
stringsAsFactors = FALSE)
|
||||
expect_equal(suppressWarnings(EUCAST_rules(a, info = FALSE)), b)
|
||||
})
|
||||
|
||||
test_that("MO properties work", {
|
||||
expect_equal(mo_property("ESCCOL"), "Escherichia coli")
|
||||
expect_equal(mo_property("STAAUR"), "Staphylococcus aureus")
|
||||
})
|
||||
|
@ -1,25 +1,4 @@
|
||||
context("classes.R")
|
||||
|
||||
test_that("rsi works", {
|
||||
expect_true(as.rsi("S") < as.rsi("I"))
|
||||
expect_true(as.rsi("I") < as.rsi("R"))
|
||||
expect_true(as.rsi("R") > as.rsi("S"))
|
||||
expect_true(is.rsi(as.rsi("S")))
|
||||
|
||||
# print plots, should not raise errors
|
||||
barplot(as.rsi(c("S", "I", "R")))
|
||||
plot(as.rsi(c("S", "I", "R")))
|
||||
print(as.rsi(c("S", "I", "R")))
|
||||
|
||||
expect_equal(suppressWarnings(as.logical(as.rsi("INVALID VALUE"))), NA)
|
||||
|
||||
expect_equal(summary(as.rsi(c("S", "R"))), c("Mode" = 'rsi',
|
||||
"<NA>" = "0",
|
||||
"Sum S" = "1",
|
||||
"Sum IR" = "1",
|
||||
"-Sum R" = "1",
|
||||
"-Sum I" = "0"))
|
||||
})
|
||||
context("mic.R")
|
||||
|
||||
test_that("mic works", {
|
||||
expect_true(as.mic(8) == as.mic("8"))
|
22
tests/testthat/test-rsi.R
Normal file
22
tests/testthat/test-rsi.R
Normal file
@ -0,0 +1,22 @@
|
||||
context("rsi.R")
|
||||
|
||||
test_that("rsi works", {
|
||||
expect_true(as.rsi("S") < as.rsi("I"))
|
||||
expect_true(as.rsi("I") < as.rsi("R"))
|
||||
expect_true(as.rsi("R") > as.rsi("S"))
|
||||
expect_true(is.rsi(as.rsi("S")))
|
||||
|
||||
# print plots, should not raise errors
|
||||
barplot(as.rsi(c("S", "I", "R")))
|
||||
plot(as.rsi(c("S", "I", "R")))
|
||||
print(as.rsi(c("S", "I", "R")))
|
||||
|
||||
expect_equal(suppressWarnings(as.logical(as.rsi("INVALID VALUE"))), NA)
|
||||
|
||||
expect_equal(summary(as.rsi(c("S", "R"))), c("Mode" = 'rsi',
|
||||
"<NA>" = "0",
|
||||
"Sum S" = "1",
|
||||
"Sum IR" = "1",
|
||||
"-Sum R" = "1",
|
||||
"-Sum I" = "0"))
|
||||
})
|
Reference in New Issue
Block a user