fix(amr): apply GTDB species matching on the SQLite index path - #50
Merged
Merged
Conversation
The AMR genus SQLite index matched --species with an exact LOWER(species) IN (...) clause against the raw query string, so an unsuffixed NCBI name such as "Enterococcus faecium" returned 0 results when an index existed. v0.22.0's GTDB-suffix stripping reached the parquet scan but not the index path. QueryIndex now resolves the requested species against the stored names with match.SpeciesMatches before building the IN clause, mirroring the internal/index resolver. Explicit clade names still select one clade. Closes #49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #49.
atb amr --species "Enterococcus faecium"(an unsuffixed NCBI name) silently returned 0 results when a genus SQLite index was present.v0.22.0 added GTDB-aware
--speciesmatching, but the AMR SQLite-index path (internal/amr/indexer.go buildSQL) matched the raw query with an exactLOWER(species) IN (...)clause and never applied the_[A-Z]+suffix stripping thatmatch.SpeciesMatchesuses everywhere else. GTDB matching reached the parquet scan andatb query, but not the AMR index.--genus Enterococcusand the explicit--species "Enterococcus_B faecium"were unaffected.Fix
QueryIndexnow resolves the requested species against the index's distinct stored names in Go withmatch.SpeciesMatches(SQLite can't run the suffix regex), then feeds the concrete matched names intobuildSQL's exactINclause — the same patterninternal/index/query.goalready uses. Empty resolution short-circuits to zero rows.Tests
TestQueryAMRSpeciesGTDBSuffixIndexed— builds real.sqliteindexes viaBuildIndexes, then queries the unsuffixed name across both clade partitions (RED before the fix, GREEN after).TestQueryAMRSpeciesCladeSelectIndexed— an explicit clade name still selects only that clade.The original v0.22.0 AMR tests missed this because they only wrote
.parquetfixtures, so execution always fell to the (correct) parquet path.Full suite, gofmt, and vet clean.