Skip to content

feat(query): match GTDB taxonomy for --species and --genus - #48

Merged
thanhleviet merged 1 commit into
mainfrom
feat/gtdb-species-normalize
Sep 2, 2026
Merged

thanhleviet merged 1 commit into
mainfrom
feat/gtdb-species-normalize

Conversation

@thanhleviet

Copy link
Copy Markdown
Collaborator

Summary

Fixes #47. ATB stores GTDB names, which split NCBI genera and species into alphabetic clades (Enterococcus_A faecium, Campylobacter jejunii_A), so an NCBI-style query such as atb mlst --species "Enterococcus faecium" returned zero rows. The GTDB alphabetic suffix is now stripped from the stored name during comparison.

The match is directional: an unsuffixed query matches every clade, while an explicit clade name (Campylobacter_D) still selects only that clade, preserving clade-specific filtering.

A single matcher (internal/match.SpeciesMatches) backs all filtering paths:

  • SQLite index (mlst, query): resolves matching stored names into an IN (...) clause
  • parquet executor (query): per-row species/genus comparison
  • AMR (amr): row filter plus genus-to-partition expansion (a requested genus expands to every on-disk clade partition) and the HQ sample filter

Testing

  • TDD throughout (failing tests written first for match, index, query, and AMR paths)
  • go test ./... all green; gofmt and go vet clean; binary builds
  • Note: golangci-lint is not installed in the working environment, so make lint was not run locally; gofmt (checked separately in CI) is clean

Closes #47

ATB stores GTDB names, which split NCBI genera and species into
alphabetic clades (Enterococcus_A faecium, Campylobacter jejunii_A).
An NCBI-style query such as `atb mlst --species "Enterococcus faecium"`
returned zero rows because the stored names never matched verbatim.

Strip the GTDB alphabetic suffix from the stored name during comparison.
The match is directional: an unsuffixed query matches every clade, while
an explicit clade name (Campylobacter_D) still selects only that clade,
so clade-specific filtering is preserved.

A single matcher (internal/match.SpeciesMatches) backs all filtering
paths: the SQLite index resolves matching stored names into an IN clause,
the parquet executor and AMR row filter compare per row, and AMR genus
partitions expand a requested genus to every on-disk clade partition.

Closes #47
@thanhleviet
thanhleviet merged commit 9a60dac into main Sep 2, 2026
6 checks passed
@thanhleviet
thanhleviet deleted the feat/gtdb-species-normalize branch September 2, 2026 08:56
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.

Handle --species better with GTDB taxons

1 participant