mirror of
https://github.com/msberends/AMR.git
synced 2024-12-26 18:46:13 +01:00
(v2.1.1.9090) website error
This commit is contained in:
parent
0736ac7a7e
commit
325664f5aa
@ -1,5 +1,5 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 2.1.1.9089
|
Version: 2.1.1.9090
|
||||||
Date: 2024-10-04
|
Date: 2024-10-04
|
||||||
Title: Antimicrobial Resistance Data Analysis
|
Title: Antimicrobial Resistance Data Analysis
|
||||||
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||||
|
2
NEWS.md
2
NEWS.md
@ -1,4 +1,4 @@
|
|||||||
# AMR 2.1.1.9089
|
# AMR 2.1.1.9090
|
||||||
|
|
||||||
*(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).)*
|
*(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).)*
|
||||||
|
|
||||||
|
@ -59,7 +59,6 @@ home:
|
|||||||
sidebar:
|
sidebar:
|
||||||
structure: [gpthelp, toc, links, authors]
|
structure: [gpthelp, toc, links, authors]
|
||||||
components:
|
components:
|
||||||
<a href="https://chatgpt.com/g/g-M4UNLwFi5-amr-for-r-assistant"><img src="AMRforRGPT.svg" style="min-width: 300px; width: 10%;" /></a>
|
|
||||||
gpthelp: '<a target="_blank" href="https://chatgpt.com/g/g-M4UNLwFi5-amr-for-r-assistant"><img src="https://github.com/msberends/AMR/raw/main/pkgdown/assets/AMRforRGPT.svg" style="width: 80%;"></a>'
|
gpthelp: '<a target="_blank" href="https://chatgpt.com/g/g-M4UNLwFi5-amr-for-r-assistant"><img src="https://github.com/msberends/AMR/raw/main/pkgdown/assets/AMRforRGPT.svg" style="width: 80%;"></a>'
|
||||||
|
|
||||||
navbar:
|
navbar:
|
||||||
|
@ -263,11 +263,28 @@ get_synonyms <- function(CID, clean = TRUE) {
|
|||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# we will now get the closest compounds with a 96% threshold
|
||||||
|
similar_cids <- tryCatch(
|
||||||
|
data.table::fread(
|
||||||
|
paste0(
|
||||||
|
"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/fastsimilarity_2d/cid/",
|
||||||
|
CID[i],
|
||||||
|
"/cids/TXT?Threshold=96&MaxRecords=5"
|
||||||
|
),
|
||||||
|
sep = "\n",
|
||||||
|
showProgress = FALSE
|
||||||
|
)[[1]],
|
||||||
|
error = function(e) NA_character_
|
||||||
|
)
|
||||||
|
all_cids <- unique(c(CID[i], similar_cids))
|
||||||
|
# for each one, we are getting the synonyms
|
||||||
|
current_syns <- character(0)
|
||||||
|
for (j in seq_len(length(all_cids))) {
|
||||||
synonyms_txt <- tryCatch(
|
synonyms_txt <- tryCatch(
|
||||||
data.table::fread(
|
data.table::fread(
|
||||||
paste0(
|
paste0(
|
||||||
"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/fastidentity/cid/",
|
"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/fastidentity/cid/",
|
||||||
CID[i],
|
all_cids[j],
|
||||||
"/synonyms/TXT"
|
"/synonyms/TXT"
|
||||||
),
|
),
|
||||||
sep = "\n",
|
sep = "\n",
|
||||||
@ -276,7 +293,7 @@ get_synonyms <- function(CID, clean = TRUE) {
|
|||||||
error = function(e) NA_character_
|
error = function(e) NA_character_
|
||||||
)
|
)
|
||||||
|
|
||||||
Sys.sleep(0.1)
|
Sys.sleep(0.05)
|
||||||
|
|
||||||
if (clean == TRUE) {
|
if (clean == TRUE) {
|
||||||
# remove text between brackets
|
# remove text between brackets
|
||||||
@ -291,14 +308,20 @@ get_synonyms <- function(CID, clean = TRUE) {
|
|||||||
)
|
)
|
||||||
))
|
))
|
||||||
synonyms_txt <- gsub("Co-", "Co", synonyms_txt, fixed = TRUE)
|
synonyms_txt <- gsub("Co-", "Co", synonyms_txt, fixed = TRUE)
|
||||||
|
synonyms_txt <- gsub(" ?(mono)?sodium ?", "", ignore.case = TRUE, synonyms_txt)
|
||||||
|
synonyms_txt <- gsub(" ?injection ?", "", ignore.case = TRUE, synonyms_txt)
|
||||||
# only length 6 to 20 and no txt with reading marks or numbers and must start with capital letter (= brand)
|
# only length 6 to 20 and no txt with reading marks or numbers and must start with capital letter (= brand)
|
||||||
synonyms_txt <- synonyms_txt[nchar(synonyms_txt) %in% c(6:20) &
|
synonyms_txt <- synonyms_txt[nchar(synonyms_txt) %in% c(5:20) &
|
||||||
!grepl("[-&{},_0-9/:]", synonyms_txt) &
|
!grepl("[-&{},_0-9/:]", synonyms_txt) &
|
||||||
grepl("^[A-Z]", synonyms_txt, ignore.case = FALSE)]
|
grepl("^[A-Z]", synonyms_txt, ignore.case = FALSE)]
|
||||||
synonyms_txt <- unlist(strsplit(synonyms_txt, ";", fixed = TRUE))
|
synonyms_txt <- unlist(strsplit(synonyms_txt, ";", fixed = TRUE))
|
||||||
}
|
}
|
||||||
synonyms_txt <- unique(trimws(synonyms_txt[tolower(synonyms_txt) %in% unique(tolower(synonyms_txt))]))
|
|
||||||
synonyms[i] <- list(sort(synonyms_txt))
|
current_syns <- c(current_syns, synonyms_txt)
|
||||||
|
}
|
||||||
|
|
||||||
|
current_syns <- unique(trimws(current_syns[tolower(current_syns) %in% unique(tolower(current_syns))]))
|
||||||
|
synonyms[i] <- list(sort(current_syns))
|
||||||
}
|
}
|
||||||
names(synonyms) <- CID
|
names(synonyms) <- CID
|
||||||
synonyms
|
synonyms
|
||||||
@ -319,7 +342,7 @@ for (i in seq_len(length(synonyms))) {
|
|||||||
|
|
||||||
antibiotics$synonyms <- synonyms
|
antibiotics$synonyms <- synonyms
|
||||||
|
|
||||||
stop("remember to remove co-trimoxazole as synonyms from SXT (Sulfamethoxazole), so it only exists in SXT!")
|
stop("remember to remove co-trimoxazole as synonyms from SMX (Sulfamethoxazole), so it only exists in SXT!")
|
||||||
sulfa <- antibiotics[which(antibiotics$ab == "SMX"), "synonyms", drop = TRUE][[1]]
|
sulfa <- antibiotics[which(antibiotics$ab == "SMX"), "synonyms", drop = TRUE][[1]]
|
||||||
cotrim <- antibiotics[which(antibiotics$ab == "SXT"), "synonyms", drop = TRUE][[1]]
|
cotrim <- antibiotics[which(antibiotics$ab == "SXT"), "synonyms", drop = TRUE][[1]]
|
||||||
sulfa <- sulfa[!sulfa %in% cotrim]
|
sulfa <- sulfa[!sulfa %in% cotrim]
|
||||||
|
Loading…
Reference in New Issue
Block a user