diff --git a/DESCRIPTION b/DESCRIPTION
index 9d2d9dbe..d87df6de 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,5 +1,5 @@
Package: AMR
-Version: 1.4.0.9030
+Version: 1.4.0.9031
Date: 2020-12-03
Title: Antimicrobial Resistance Analysis
Authors@R: c(
diff --git a/NEWS.md b/NEWS.md
index 3f014348..756fb329 100755
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,4 +1,4 @@
-# AMR 1.4.0.9030
+# AMR 1.4.0.9031
## Last updated: 3 December 2020
### New
@@ -32,6 +32,7 @@
* `as.rsi()` on a data.frame will not print a message anymore if the values are already clean R/SI values
* Fixed a bug where `mo_uncertainties()` would not return the results based on the MO matching score
* Fixed a bug where `as.mo()` would not return results for known laboratory codes for microorganisms
+* Fixed a bug where `as.ab()` would sometimes fail
### Other
* All messages and warnings thrown by this package now break sentences on whole words
diff --git a/R/ab.R b/R/ab.R
index cd9192cc..a9e2d4e8 100755
--- a/R/ab.R
+++ b/R/ab.R
@@ -153,7 +153,8 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) {
}
if (isTRUE(flag_multiple_results) & x[i] %like% "[ ]") {
- from_text <- suppressWarnings(ab_from_text(x[i], initial_search = FALSE, translate_ab = FALSE)[[1]])
+ from_text <- tryCatch(suppressWarnings(ab_from_text(x[i], initial_search = FALSE, translate_ab = FALSE)[[1]]),
+ error = function(e) character(0))
} else {
from_text <- character(0)
}
@@ -345,7 +346,8 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) {
if (isTRUE(flag_multiple_results)) {
found <- from_text[1L]
} else {
- found <- suppressWarnings(ab_from_text(x[i], initial_search = FALSE, translate_ab = FALSE)[[1]][1L])
+ found <- tryCatch(suppressWarnings(ab_from_text(x[i], initial_search = FALSE, translate_ab = FALSE)[[1]][1L]),
+ error = function(e) NA_character_)
}
if (!is.na(found)) {
x_new[i] <- note_if_more_than_one_found(found, i, from_text)
diff --git a/R/eucast_rules.R b/R/eucast_rules.R
index 5a9fa5dc..163ddd78 100755
--- a/R/eucast_rules.R
+++ b/R/eucast_rules.R
@@ -38,12 +38,17 @@ EUCAST_VERSION_EXPERT_RULES <- list("3.1" = list(version_txt = "v3.1",
title = "'EUCAST Expert Rules' and 'EUCAST Intrinsic Resistance and Unusual Phenotypes'",
url = "https://www.eucast.org/expert_rules_and_intrinsic_resistance/"))
-format_eucast_version_nr <- function(version) {
+format_eucast_version_nr <- function(version, markdown = TRUE) {
# for documentation - adds title, version number, year and url in markdown language
lst <- c(EUCAST_VERSION_BREAKPOINTS, EUCAST_VERSION_EXPERT_RULES)
version <- format(version, nsmall = 1)
- paste0("[", lst[[version]]$title, " ", lst[[version]]$version_txt, "](", lst[[version]]$url, ")",
- " from ", lst[[version]]$year)
+ if (markdown == TRUE) {
+ paste0("[", lst[[version]]$title, " ", lst[[version]]$version_txt, "](", lst[[version]]$url, ")",
+ " from ", lst[[version]]$year)
+ } else {
+ paste0(lst[[version]]$title, " ", lst[[version]]$version_txt,
+ " from ", lst[[version]]$year)
+ }
}
#' Apply EUCAST rules
diff --git a/R/mo_property.R b/R/mo_property.R
index e88e8a82..23842286 100755
--- a/R/mo_property.R
+++ b/R/mo_property.R
@@ -386,6 +386,14 @@ mo_is_intrinsic_resistant <- function(x, ab, language = get_locale(), ...) {
stop_("length of `x` and `ab` must be equal, or one of them must be of length 1.")
}
+ # show used version number once per session
+ if (is.null(getOption("AMR_intrinsic_resistance_note", NULL))) {
+ message_("Determining intrinsic resistance based on ",
+ AMR:::format_eucast_version_nr(3.2, FALSE), ". ",
+ font_bold("This message is shown once per session."))
+ options(AMR_intrinsic_resistance_note = "shown")
+ }
+
# this saves about 50% in calculation time
intrinsic_to_check <- intrinsic_resistant[which(intrinsic_resistant$microorganism %in% x |
intrinsic_resistant$antibiotic %in% ab), , drop = FALSE]
diff --git a/docs/404.html b/docs/404.html
index 37052d8d..5562eea2 100644
--- a/docs/404.html
+++ b/docs/404.html
@@ -81,7 +81,7 @@
NEWS.md
-
Function is_new_episode()
to determine patient episodes which are not necessarily based on microorganisms. It also supports grouped variables with e.g. mutate()
, filter()
and summarise()
of the dplyr
package:
example_isolates %>% - group_by(patient_id, hospital_id) %>% - filter(is_new_episode(date, episode_days = 60))
Functions mo_is_gram_negative()
and mo_is_gram_positive()
as wrappers around mo_gramstain()
. They always return TRUE
or FALSE
(except when the input is NA
or the MO code is UNKNOWN
), thus always return FALSE
for species outside the taxonomic kingdom of Bacteria. They can even determine the column with microorganisms themselves when used inside dplyr
verbs:
example_isolates %>% - filter(mo_is_gram_positive()) + filter(mo_is_gram_positive()) #> NOTE: Using column `mo` as input for mo_is_gram_positive()
Function mo_is_intrinsic_resistant()
to test for intrinsic resistance, based on EUCAST Intrinsic Resistance and Unusual Phenotypes v3.2 from 2020. As with the new mo_is_gram_*()
functions, if you have the dplyr
package installed the column with microorganisms will be automatically determined when used inside dplyr
verbs:
example_isolates %>% - filter(mo_is_intrinsic_resistant(ab = "Vancomycin")) + filter(mo_is_intrinsic_resistant(ab = "Vancomycin")) #> NOTE: Using column `mo` as input for mo_is_intrinsic_resistant()
as.rsi()
on a data.frame will not print a message anymore if the values are already clean R/SI values
mo_uncertainties()
would not return the results based on the MO matching scoreas.mo()
would not return results for known laboratory codes for microorganismsas.ab()
would sometimes fail