diff --git a/DESCRIPTION b/DESCRIPTION index 2fc55a1bd..ccabc99f4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 2.1.1.9222 +Version: 2.1.1.9223 Date: 2025-03-20 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NAMESPACE b/NAMESPACE index 3c5a8e75f..4077d6671 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,7 @@ S3method("!=",amr_selector) S3method("&",amr_selector) +S3method("+",ab) S3method("+",amr_selector) S3method("==",amr_selector) S3method("[",ab) diff --git a/NEWS.md b/NEWS.md index 49a1507e8..57b81cbf9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 2.1.1.9222 +# AMR 2.1.1.9223 *(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://msberends.github.io/AMR/#latest-development-version).)* diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index 73e60c8b1..c0c205b62 100644 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -539,7 +539,7 @@ word_wrap <- function(..., ) # text starting with `?` must also lead to the help page parts[parts %like% "^[?]"] <- font_url( - url = paste0("ide:help:AMR::", parts[parts %like% "^[?]"]), + url = paste0("ide:help:AMR::", gsub("?", "", parts[parts %like% "^[?]"], fixed = TRUE)), txt = parts[parts %like% "^[?]"] ) msg <- paste0(parts, collapse = "`") diff --git a/R/ab.R b/R/ab.R index d7e29c9fa..9d12c22f2 100755 --- a/R/ab.R +++ b/R/ab.R @@ -610,6 +610,16 @@ rep.ab <- function(x, ...) { y } +#' @method + ab +#' @export +#' @noRd +`+.ab` <- function(e1, e2) { + # this does not return ab class, it should just allow console usage of e.g., carbapenems() + c("", aminoglycosides()) + out <- as.character(outer(e1, e2, paste, sep = " + ")) + out <- gsub(" [+] $", "", out) + out +} + generalise_antibiotic_name <- function(x) { x <- toupper(x) # remove suffices diff --git a/R/amr_selectors.R b/R/amr_selectors.R index fafdce1cf..67641f588 100755 --- a/R/amr_selectors.R +++ b/R/amr_selectors.R @@ -954,9 +954,10 @@ any.amr_selector_any_all <- function(..., na.rm = FALSE) { #' @noRd `+.amr_selector` <- function(e1, e2) { # this is useful for `antibiogram()`: antibiogram(example_isolates, carbapenems() + c("", "GEN", "TOB")) - structure(as.character(outer(e1, e2, paste, sep = " + ")), - class = c("amr_selector", "character") - ) + # this is also implemented for ab class, to allow direct console usage + out <- as.character(outer(e1, e2, paste, sep = " + ")) + out <- gsub(" [+] $", "", out) + structure(out, class = c("amr_selector", "character")) } is_any <- function(el1) { diff --git a/R/antibiogram.R b/R/antibiogram.R index 6ba5db248..383f0420c 100755 --- a/R/antibiogram.R +++ b/R/antibiogram.R @@ -42,8 +42,9 @@ #' - `c(aminoglycosides(), "AMP", "AMC")` #' - `c(aminoglycosides(), carbapenems())` #' - Combination therapy, indicated by using `"+"`, with or without [antimicrobial selectors][antimicrobial_selectors], e.g.: -#' - `"TZP+TOB"` #' - `"cipro + genta"` +#' - `"TZP+TOB"` +#' - `c("TZP", "TZP+GEN", "TZP+TOB")` #' - `carbapenems() + "GEN"` #' - `carbapenems() + c("", "GEN")` #' - `carbapenems() + c("", aminoglycosides())` diff --git a/data-raw/_generate_python_wrapper.sh b/data-raw/_generate_python_wrapper.sh index c3625c97c..3d9fc8b9b 100644 --- a/data-raw/_generate_python_wrapper.sh +++ b/data-raw/_generate_python_wrapper.sh @@ -73,26 +73,23 @@ if not isinstalled('AMR', lib_loc=r_lib_path): print(f"AMR: Installing latest AMR R package to {r_lib_path}...", flush=True) utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True) -# Retrieve Python AMR version -try: - python_amr_version = metadata.version('AMR') -except metadata.PackageNotFoundError: - python_amr_version = '' - -# Retrieve R AMR version -r_amr_version = robjects.r(f'as.character(packageVersion("AMR", lib.loc = "{r_lib_path}"))') -r_amr_version = str(r_amr_version[0]) - -print(python_amr_version) -print(r_amr_version) - -# Compare R and Python package versions -if r_amr_version != python_amr_version: - try: - print(f"AMR: Updating AMR package in {r_lib_path}...", flush=True) - utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True) - except Exception as e: - print(f"AMR: Could not update: {e}", flush=True) +# # Retrieve Python AMR version +# try: +# python_amr_version = metadata.version('AMR') +# except metadata.PackageNotFoundError: +# python_amr_version = '' +# +# # Retrieve R AMR version +# r_amr_version = robjects.r(f'as.character(packageVersion("AMR", lib.loc = "{r_lib_path}"))') +# r_amr_version = str(r_amr_version[0]) +# +# # Compare R and Python package versions +# if r_amr_version != python_amr_version: +# try: +# print(f"AMR: Updating AMR package in {r_lib_path}...", flush=True) +# utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True) +# except Exception as e: +# print(f"AMR: Could not update: {e}", flush=True) print(f"AMR: Setting up R environment and AMR datasets...", flush=True) diff --git a/data-raw/gpt_training_text_v2.1.1.9222.txt b/data-raw/gpt_training_text_v2.1.1.9223.txt similarity index 99% rename from data-raw/gpt_training_text_v2.1.1.9222.txt rename to data-raw/gpt_training_text_v2.1.1.9223.txt index 58873026d..7ce0457e6 100644 --- a/data-raw/gpt_training_text_v2.1.1.9222.txt +++ b/data-raw/gpt_training_text_v2.1.1.9223.txt @@ -1,6 +1,6 @@ This knowledge base contains all context you must know about the AMR package for R. You are a GPT trained to be an assistant for the AMR package in R. You are an incredible R specialist, especially trained in this package and in the tidyverse. -First and foremost, you are trained on version 2.1.1.9222. Remember this whenever someone asks which AMR package version you’re at. +First and foremost, you are trained on version 2.1.1.9223. Remember this whenever someone asks which AMR package version you’re at. Below are the contents of the NAMESPACE file, the index.md file, and all the man/*.Rd files (documentation) in the package. Every file content is split using 100 hypens. ---------------------------------------------------------------------------------------------------- @@ -13,6 +13,7 @@ THE PART HEREAFTER CONTAINS CONTENTS FROM FILE 'NAMESPACE': S3method("!=",amr_selector) S3method("&",amr_selector) +S3method("+",ab) S3method("+",amr_selector) S3method("==",amr_selector) S3method("[",ab) @@ -1713,8 +1714,9 @@ retrieve_wisca_parameters(wisca_model, ...) } \item Combination therapy, indicated by using \code{"+"}, with or without \link[=antimicrobial_selectors]{antimicrobial selectors}, e.g.: \itemize{ -\item \code{"TZP+TOB"} \item \code{"cipro + genta"} +\item \code{"TZP+TOB"} +\item \code{c("TZP", "TZP+GEN", "TZP+TOB")} \item \code{carbapenems() + "GEN"} \item \code{carbapenems() + c("", "GEN")} \item \code{carbapenems() + c("", aminoglycosides())} diff --git a/man/antibiogram.Rd b/man/antibiogram.Rd index 190acbebd..01f117bd1 100644 --- a/man/antibiogram.Rd +++ b/man/antibiogram.Rd @@ -58,8 +58,9 @@ retrieve_wisca_parameters(wisca_model, ...) } \item Combination therapy, indicated by using \code{"+"}, with or without \link[=antimicrobial_selectors]{antimicrobial selectors}, e.g.: \itemize{ -\item \code{"TZP+TOB"} \item \code{"cipro + genta"} +\item \code{"TZP+TOB"} +\item \code{c("TZP", "TZP+GEN", "TZP+TOB")} \item \code{carbapenems() + "GEN"} \item \code{carbapenems() + c("", "GEN")} \item \code{carbapenems() + c("", aminoglycosides())}