diff --git a/R/mo.R b/R/mo.R index cc506973..e0c95de8 100644 --- a/R/mo.R +++ b/R/mo.R @@ -37,7 +37,6 @@ #' \itemize{ #' \item{\code{"E. coli"} will return the ID of \emph{Escherichia coli} and not \emph{Entamoeba coli}, although the latter would alphabetically come first} #' \item{\code{"H. influenzae"} will return the ID of \emph{Haemophilus influenzae} and not \emph{Haematobacter influenzae}} -#' \item{Something like \code{"s pyo"} will return the ID of \emph{Streptococcus pyogenes} and not \emph{Actinomyes pyogenes}} #' \item{Something like \code{"p aer"} will return the ID of \emph{Pseudomonas aeruginosa} and not \emph{Pasteurella aerogenes}} #' \item{Something like \code{"stau"} or \code{"staaur"} will return the ID of \emph{Staphylococcus aureus} and not \emph{Staphylococcus auricularis}} #' } @@ -139,6 +138,7 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE) { # add start en stop regex x <- paste0('^', x, '$') x_withspaces_all <- x_withspaces + x_withspaces_start <- paste0('^', x_withspaces) x_withspaces <- paste0('^', x_withspaces, '$') for (i in 1:length(x)) { @@ -177,11 +177,6 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE) { x[i] <- 'STAAUR' next } - if (tolower(x[i]) == '^s.*pyo$') { - # avoid detection of Actinomyces pyogenes in case of Streptococcus pyogenes - x[i] <- 'STCPYO' - next - } if (tolower(x[i]) == '^p.*aer$') { # avoid detection of Pasteurella aerogenes in case of Pseudomonas aeruginosa x[i] <- 'PSEAER' @@ -240,6 +235,12 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE) { x[i] <- found[1L] next } + # try any match keeping spaces, not ending with $ + found <- MOs[which(MOs$fullname %like% x_withspaces_start[i]),]$mo + if (length(found) > 0) { + x[i] <- found[1L] + next + } # try any match diregarding spaces found <- MOs[which(MOs$fullname %like% x[i]),]$mo diff --git a/data/microorganisms.rda b/data/microorganisms.rda index cd8e5b99..7ea84719 100755 Binary files a/data/microorganisms.rda and b/data/microorganisms.rda differ