Skip to content

fix: accept case/plural EC/GO annotation key variants in annotate (addresses #96) - #104

Merged
nextgenusfs merged 1 commit into
nextgenusfs:mainfrom
vinvomero:fix/eggnog-annotation-key-variants
Oct 19, 2026
Merged

nextgenusfs merged 1 commit into
nextgenusfs:mainfrom
vinvomero:fix/eggnog-annotation-key-variants

Conversation

@vinvomero

Copy link
Copy Markdown
Contributor

Addresses the EC/GO portion of #96.

Problem

annotate() merges functional annotations with exact-key checks:

if "ec_number" in fa:
    n["ec_number"][i] = fa["ec_number"]
if "go_terms" in fa:
    n["go_terms"][i] = fa["go_terms"]

but eggNOG / funannotate2-addons write the EC number as EC_number, and InterProScan writes GO terms as go_term (singular). Those annotations were loaded and then silently dropped. In the #96 reporter's data, a local patch for these keys recovered 5,296 GO terms.

Fix

Adds utilities.resolve_annotation_key(fa, canonical_key), which finds the key present in an annotation dict for ec_number / go_terms, tolerant of those known variants. A key that actually carries data is preferred, so an empty canonical key never hides a populated variant; when both carry data the canonical key wins, so existing canonical-key inputs behave exactly as before. The EC/GO merge in annotate() now goes through it.

Scope

This covers the EC and GO keys from #96. The InterPro/SignalP summary counts the reporter also mentions are computed in the gfftk dependency (gfftk/stats.py), so they aren't changed here.

Tests

New tests/unit/test_utilities_annotation.py (9 tests): canonical keys, the EC_number / go_term variants, a populated variant winning over an empty canonical key, the canonical key winning when both are populated, absent keys, unknown keys matching only themselves, and a present-but-None value being preserved.

Full unit suite run locally on top of current main: 205 passed vs 196 on unmodified main. The difference is the 9 new tests, with no regressions. (Run on Windows, where annorefine and gapmm2 don't install, so test_predict*.py didn't run locally, and one tmpdir test fails identically on main because it expects a /tmp path. CI here should cover those.)

🤖 Generated with Claude Code

…dresses nextgenusfs#96)

annotate() merged functional annotations with exact-key checks
(`if "ec_number" in fa` / `if "go_terms" in fa`), but eggNOG / funannotate2-addons
emit the EC number under `EC_number` and InterProScan emits GO terms under
`go_term` (singular), so those annotations were silently dropped. In the
reporter's dataset, a local patch for these keys recovered 5,296 GO terms.

Add utilities.resolve_annotation_key(), which resolves the canonical funannotate2
key (ec_number/go_terms) tolerant of the known case/plural variants. A key that
actually carries data is preferred, so an empty canonical key never hides a
populated variant; when both carry data the canonical key wins, so
canonical-key inputs are unchanged. Route the EC/GO merge in annotate() through it.

Addresses the EC/GO portion of nextgenusfs#96. The InterPro/SignalP summary counts the
reporter also notes are computed in the gfftk dependency (gfftk/stats.py) and are
out of scope here.

New tests: tests/unit/test_utilities_annotation.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nextgenusfs
nextgenusfs merged commit 30f0cb8 into nextgenusfs:main Oct 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants