mirror of
https://github.com/msberends/AMR.git
synced 2026-11-16 01:30:54 +01:00
(v3.0.1.9096) MO code registry: codes never change meaning, are never guessed, and are validated
- data-raw/microorganisms_files/: registry of all MO codes of every release since v2.0.0 (78,992 codes, built from the git tags), approved renames, and README with the rules; decision by Matthijs S. Berends: MO codes from before v2.0.0 are not supported - as.mo(): codes of earlier releases are translated deterministically via the internal MO_RETIRED_CODES (generated from the registry); unknown codes are no longer guessed (previously F_TRCHP, Trichophyton in v3.0.1, became Talaromyces chlamydosporus) - synonym_mo_to_accepted_mo(): a missing target of one source no longer overwrites a valid target of another source (e.g. Chaetomium abuense), and no 'renamed to itself' - taxonomy build: codes are reused and reserved from the registry instead of the development data (fixes 40 codes reused in the 2026 development data), also for phylum to family; synonym cycles are broken; dangling 'renamed to' identifiers are removed; the build stops on any broken integrity rule before saving - run_microorganisms_build.R: runs the build in chunks at its checkpoints in one R process, with progress logging and resuming from any checkpoint; prompt updated accordingly - tests: shared integrity rules (helper-microorganisms.R) used by build and testthat, registry tests over all codes, sentinel organisms, regression tests; current defects of the data on main are listed in microorganisms_known_defects.csv until the next rebuild Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ca5fa333ca
commit
d683b9e7c6
16 files changed
+80516
-246
No files matched your search
@@ -624,6 +624,28 @@ usethis::use_data(antimicrobials, overwrite = TRUE, version = 2, compress = "xz"
|
||||
pre_commit_lst$AB_LOOKUP <- create_AB_AV_lookup(antimicrobials)
|
||||
pre_commit_lst$AV_LOOKUP <- create_AB_AV_lookup(antivirals)
|
||||
|
||||
# MO codes of earlier releases that are not in the current data set anymore, with the current code of the same
|
||||
# taxon (see data-raw/microorganisms_files/README.md). as.mo() uses this to translate them, instead of guessing.
|
||||
source("tests/testthat/helper-microorganisms.R")
|
||||
mo_registry <- read_mo_registry(".")
|
||||
mo_renames <- read_mo_renames(".")
|
||||
retired <- mo_registry[!mo_registry$mo %in% as.character(microorganisms$mo), c("mo", "fullname", "rank"), drop = FALSE]
|
||||
renamed <- match(retired$mo, mo_renames$mo)
|
||||
retired$fullname[!is.na(renamed)] <- mo_renames$new_name[renamed[!is.na(renamed)]]
|
||||
# the same name, or else the same name without a rank suffix (such as "Kapabacteria {class}") and the same rank
|
||||
current_mo <- as.character(microorganisms$mo)[match(retired$fullname, microorganisms$fullname)]
|
||||
by_rank <- as.character(microorganisms$mo)[match(
|
||||
paste(mo_name_without_suffix(retired$fullname), retired$rank),
|
||||
paste(mo_name_without_suffix(microorganisms$fullname), microorganisms$rank)
|
||||
)]
|
||||
pre_commit_lst$MO_RETIRED_CODES <- data.frame(
|
||||
old_mo = retired$mo,
|
||||
mo = ifelse(is.na(current_mo), by_rank, current_mo),
|
||||
fullname = retired$fullname,
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
rm(mo_registry, mo_renames, retired, renamed, current_mo, by_rank)
|
||||
|
||||
# Export to package as internal data ----
|
||||
# usethis::use_data() must receive unquoted object names, which is not flexible at all.
|
||||
# we'll use good old base::save() instead
|
||||
|
||||
Reference in new issue
Block a user