mirror of
https://github.com/msberends/AMR.git
synced 2026-06-29 08:56:20 +02:00
(v3.0.1.9080) fix(as.mo): resolve abbreviated genus when species has subspecies (#288 follow-up) (#301)
When a genus+species abbreviation like "P. ovale" was used, the previous bypass (Issue #288) checked sum(sp_exact) == 1, which failed if the species also had subspecies sharing the epithet (ovale curtisi, ovale wallikeri). The fix extends the bypass to fire whenever all exact species matches belong to one genus, collapsing to the species-rank record (subspecies == "") for genus+species queries and preserving the chosen row for explicit subspecies queries. Also extends the data-invariant test to cover all taxonomic rank columns from domain to subspecies, not just the terminal three. Claude-Session: https://claude.ai/code/session_01M4fqQYQYJ3drdudkDYNqAY Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -338,3 +338,30 @@ test_that("test-mo.R", {
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
test_that("as.mo() resolves abbreviated genus when species carries subspecies (#288 follow-up)", {
|
||||
# "P. ovale" must resolve to Plasmodium ovale, not a Pseudomonas species,
|
||||
# even though P. ovale has subspecies (curtisi, wallikeri) sharing the epithet.
|
||||
expect_identical(
|
||||
as.mo("P. ovale", keep_synonyms = TRUE, info = FALSE),
|
||||
as.mo("Plasmodium ovale", keep_synonyms = TRUE, info = FALSE)
|
||||
)
|
||||
expect_identical(
|
||||
mo_name("P. ovale", keep_synonyms = TRUE, language = NULL),
|
||||
"Plasmodium ovale"
|
||||
)
|
||||
|
||||
# Non-regression: the original #288 example must still work.
|
||||
expect_identical(
|
||||
mo_genus("S. apiospermum", keep_synonyms = TRUE, language = NULL),
|
||||
"Scedosporium"
|
||||
)
|
||||
|
||||
# Explicit subspecies must not be collapsed to species rank.
|
||||
if (any(microorganisms$fullname == "Plasmodium ovale curtisi")) {
|
||||
expect_identical(
|
||||
mo_name("P. ovale curtisi", keep_synonyms = TRUE, language = NULL),
|
||||
"Plasmodium ovale curtisi"
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user