mirror of
https://github.com/msberends/AMR.git
synced 2024-12-26 06:46:11 +01:00
(v2.1.1.9090) website error
This commit is contained in:
parent
0736ac7a7e
commit
325664f5aa
@ -1,5 +1,5 @@
|
||||
Package: AMR
|
||||
Version: 2.1.1.9089
|
||||
Version: 2.1.1.9090
|
||||
Date: 2024-10-04
|
||||
Title: Antimicrobial Resistance Data Analysis
|
||||
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).)*
|
||||
|
||||
|
@ -59,7 +59,6 @@ home:
|
||||
sidebar:
|
||||
structure: [gpthelp, toc, links, authors]
|
||||
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>'
|
||||
|
||||
navbar:
|
||||
|
@ -262,43 +262,66 @@ get_synonyms <- function(CID, clean = TRUE) {
|
||||
if (is.na(CID[i])) {
|
||||
next
|
||||
}
|
||||
|
||||
synonyms_txt <- tryCatch(
|
||||
|
||||
# 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/fastidentity/cid/",
|
||||
"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/fastsimilarity_2d/cid/",
|
||||
CID[i],
|
||||
"/synonyms/TXT"
|
||||
"/cids/TXT?Threshold=96&MaxRecords=5"
|
||||
),
|
||||
sep = "\n",
|
||||
showProgress = FALSE
|
||||
)[[1]],
|
||||
error = function(e) NA_character_
|
||||
)
|
||||
|
||||
Sys.sleep(0.1)
|
||||
|
||||
if (clean == TRUE) {
|
||||
# remove text between brackets
|
||||
synonyms_txt <- trimws(gsub(
|
||||
"[(].*[)]", "",
|
||||
gsub(
|
||||
"[[].*[]]", "",
|
||||
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(
|
||||
data.table::fread(
|
||||
paste0(
|
||||
"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/fastidentity/cid/",
|
||||
all_cids[j],
|
||||
"/synonyms/TXT"
|
||||
),
|
||||
sep = "\n",
|
||||
showProgress = FALSE
|
||||
)[[1]],
|
||||
error = function(e) NA_character_
|
||||
)
|
||||
|
||||
Sys.sleep(0.05)
|
||||
|
||||
if (clean == TRUE) {
|
||||
# remove text between brackets
|
||||
synonyms_txt <- trimws(gsub(
|
||||
"[(].*[)]", "",
|
||||
gsub(
|
||||
"[(].*[]]", "",
|
||||
gsub("[[].*[)]", "", synonyms_txt)
|
||||
"[[].*[]]", "",
|
||||
gsub(
|
||||
"[(].*[]]", "",
|
||||
gsub("[[].*[)]", "", synonyms_txt)
|
||||
)
|
||||
)
|
||||
)
|
||||
))
|
||||
synonyms_txt <- gsub("Co-", "Co", synonyms_txt, fixed = TRUE)
|
||||
# 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) &
|
||||
!grepl("[-&{},_0-9/:]", synonyms_txt) &
|
||||
grepl("^[A-Z]", synonyms_txt, ignore.case = FALSE)]
|
||||
synonyms_txt <- unlist(strsplit(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)
|
||||
synonyms_txt <- synonyms_txt[nchar(synonyms_txt) %in% c(5:20) &
|
||||
!grepl("[-&{},_0-9/:]", synonyms_txt) &
|
||||
grepl("^[A-Z]", synonyms_txt, ignore.case = FALSE)]
|
||||
synonyms_txt <- unlist(strsplit(synonyms_txt, ";", fixed = TRUE))
|
||||
}
|
||||
|
||||
current_syns <- c(current_syns, synonyms_txt)
|
||||
}
|
||||
synonyms_txt <- unique(trimws(synonyms_txt[tolower(synonyms_txt) %in% unique(tolower(synonyms_txt))]))
|
||||
synonyms[i] <- list(sort(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
|
||||
synonyms
|
||||
@ -319,7 +342,7 @@ for (i in seq_len(length(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]]
|
||||
cotrim <- antibiotics[which(antibiotics$ab == "SXT"), "synonyms", drop = TRUE][[1]]
|
||||
sulfa <- sulfa[!sulfa %in% cotrim]
|
||||
|
Loading…
Reference in New Issue
Block a user