1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-25 18:46:11 +01:00

small fix for microorganisms data set

This commit is contained in:
dr. M.S. (Matthijs) Berends 2018-09-06 16:50:03 +02:00
parent de36b0be23
commit c5073f2fd1
2 changed files with 7 additions and 6 deletions

13
R/mo.R
View File

@ -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

Binary file not shown.