Skip to content

Design

omnitax reads biological taxonomies (NCBI, GTDB, SILVA, Greengenes2, Open Tree, custom) and answers the same questions about all of them, whether the taxonomy was just parsed into a temporary SQLite file, sits in a file of its own, or lives on a server. The aim is lean code: one algorithm layer on top of two small storage backends (a SQLite file and a client of the server).

Layers

 Taxon / Taxonomy            algorithms, written once (pure Python)
 ──────────────────────────────────────────────────────────────────
 Store protocol              a few batched primitives
 ──────────────────────────────────────────────────────────────────
 SqliteStore | RemoteStore
 ──────────────────────────────────────────────────────────────────
 loaders (ncbi, gtdb, silva, greengenes, ott, custom, taxdump)  → rows
  • Loaders (omnitax.loaders, omnitax.load(kind, version, files, cache_dir=, **options)) download (or read local) source files and yield plain rows: nodes, extra names, aliases (merged/deleted ids) and genomes. A loader does not know where the rows go.
  • Stores keep rows. SqliteStore is one file holding any number of taxonomies (there is no in-memory store: a taxonomy that is loaded, subset or edited is built into a temporary file that its Taxonomy owns and removes, see Temporary files); RemoteStore speaks HTTP to omnitax serve (URL or Unix socket). A store implements only batched primitives, so a remote call costs one round trip per batch, never one per node.
  • Taxonomy and Taxon implement everything else (lineages, ranks, LCA, consensus, translation, filtering, export) once, against the protocol.

Identity

  • Node ids are strings everywhere ("562", "g__Escherichia"). Methods that take ids also accept int and Taxon.
  • A taxonomy is addressed as kind:version (ncbi:2026-11-26, gtdb:232, silva:ssu_138.2). gtdb alone means the newest version in the store.
  • Merged and deleted ids are aliases: looking up an old id returns the current node (taxon.id != requested id tells you it moved).

Public API

import omnitax

tax = omnitax.load("gtdb", version="232")          # parse into a temporary SQLite file
tax = omnitax.open("taxonomy.sqlite", "ncbi")      # a file
tax = omnitax.connect(url="https://…", taxonomy="ncbi")  # a server (or socket=)
tax = omnitax.connect()   # $OMNITAX_DB, $OMNITAX_URL, $OMNITAX_SOCKET, default socket
omnitax.taxonomies("taxonomy.sqlite")                    # what a file holds

t = tax["562"]                 # Taxon; KeyError when unknown; tax.get() → None
t.name, t.rank, t.parent, t.children, t.attrs   # attrs: taxonomy-specific (NCBI genetic codes, specified_species, …)
t.lineage()                    # root … t, as Taxa
t.lineage(ranks=omnitax.GTDB_RANKS)   # fixed slots, None where missing
t.lineage(root="2")            # cut at an ancestor
t.at("genus")                  # ancestor-or-self at a rank, or None
t.closest(ranks=…, formal=True)            # nearest ancestor-or-self with one of the ranks
t.leaves(), t.descendants()
t.lineage_string()             # "d__Bacteria;p__…;s__Escherichia coli" (GTDB's format)

tax.many(ids)                  # batched lookup
tax.search("escherichia", rank="genus", match="fuzzy")   # "exact" | "prefix" | "substring" | "fuzzy"
tax.of_rank("genus")           # every node of a rank, streamed
tax.meta["genetic_codes"]      # tables about the taxonomy (NCBI: divisions, genetic codes)
tax.link("GCF_000005845.2")    # key → Linked(key, taxon, name, source, kind), or None; the kind is "genome" unless given: tax.link(key, "seq")
tax.lca(ids)                   # = consensus(ids, threshold=1.0)
tax.consensus(ids_or_weights, threshold=0.9, exclude=tax.uninformative)
tax.stats()

other = omnitax.open("taxonomy.sqlite", "gtdb:232")
tax.translate("562", other, threshold=0.9)   # through shared genomes
tax.translate("562", other, top=0.95)        # multitax's top_perc heuristic
tax.translate("562", other, weight="genome", cap=True, top=0.95)   # all of multitax's translate

small = tax.subset(["g__Escherichia"], descendants=True)  # → a new Taxonomy, in a temporary file
small = tax.prune(["d__Archaea"])
mine = tax.apply(nodes=[{"id": "my_node", "parent": "g__Escherichia", "rank": "strain"}], remove=["g__Bacillus"])   # edits: one rebuild
small.save("taxonomy.sqlite")      # into a SQLite file (next to other taxonomies)
small.write("tax.tsv", columns=["id", "rank", "name_lineage"])

Store protocol and rows

A taxonomy's data travels as Rows (omnitax.store): four streams, nodes (Rec(id, parent, rank, name, attrs)), names (node, name, class), aliases (old, new | None), links (Link(key, node, name, source, kind, attrs), the name and the attributes optional, the kind genome unless given) and a small meta table (JSON-able, per taxonomy). Loaders produce them, write_taxonomy(rows) takes them in, Store.rows() gives them out again, so every copying edit is a filter over streams and works the same for any store. Raw rows are normalised by write_taxonomy (tests/test_stores.py feeds one adversarial Rows through it and compares every primitive of the file's store and of a server over it): parent == id is a root, names of unknown nodes and aliases of live nodes are dropped, an id is followed through at most MAX_ALIAS_HOPS (100) merges, a genome of a merged id moves to its current node and one of an unknown or deleted id is dropped, a genome listed twice is a ValueError. The primitives (all batched, unknown ids left out, aliases answered with the current node under the id asked); meta is an attribute, not a call:

primitive answer
nodes(ids) {id: Rec}
ancestors(ids) {id: [Rec]}, root first, the node last
children(ids) {id: [Rec]}
search(text, rank, match, limit, classes, within) [Hit(rec, name, name_class)]: exact, then (by match) prefix, word start, substring or fuzzy; within: the id of a node whose subtree is searched
subtree(id) the node and everything below it as (Rec, is leaf), in pre-order, streamed
by_name(texts) {text: [Hit]}: the nodes each text names exactly, any class, best first
names(ids) {id: [(name, class)]}, the best first
of_rank(rank) every Rec of a rank, streamed
links(kind, bases, attrs=True) {base: [Link]}: every stored version or region of the bases, in the sources of that kind, with node, name and attributes (attrs=False: without, as a translation asks)
links_under(id) (key, node id, source) at and below a node, of every kind, an iterator (streamed: there may be millions)
rows() everything

A node of a taxonomy with several top nodes (GTDB, SILVA, Greengenes) hangs below a synthetic root, so every LCA exists. NCBI's superkingdom is stored as domain.

A link attaches a key to a node of a taxonomy: Link(key, node, name, source, kind, attrs). Translation between two taxonomies is a vote through the keys they share, so everything that can name the same thing in two taxonomies is a link: a genome accession (GTDB and NCBI), a sequence accession (SILVA, NCBI, Greengenes), the id of a node of another taxonomy (OTT nodes list ncbi:562). A link table is just key → node of that taxonomy.

Kinds. Each key has a kind, which says what it is and so how it is written and matched; all of it lives in one place, omnitax.links (link_key, split_key, match_link), and the stores only ever see normalised keys and bases:

kind key normalised base (what lookups ask for) matching (match_link)
genome GCF_000005845.2 upper case, no RS_/GB_, the version stays without the version (1) the same accession; (2) else the genomes of that version (gca_gcf: of the other database); (3) else all of the number, whatever the version
seq AB000278, A16379.1.1485 (acc.start.stop) upper case without the region (1) the same key; (3) else all keys of the accession, whatever the region
a taxonomy kind (ncbi, gbif, ...) 562 stripped the key the same key

One match is a match, several are ambiguous (candidates listed, not voting), none is unknown: the rule of versions of a genome, applied to regions of a sequence. gca_gcf=True makes GCA_ and GCF_ accessions of one number the same genome. A region is part of the key; a different region of the same accession finds the stored one when there is exactly one (a decision: the rule stays one rule, and the same for both directions).

Where the kind lives. A source has one kind (link_source.kind, LinkSource(kind, links, provenance)), not each row: a lookup of a kind is source IN (its sources), rows stay as small as before, and a loader that has two kinds of keys names two sources (ott:3.7.3/ncbi, ott:3.7.3/gbif: the labels carry the version coupling anyway). The alternative, a prefix in the key (ncbi:562), would be parsed in every store and cost bytes in 5 million rows. The public key is the bare key; the kind is always asked for (links(keys, kind="genome")).

Implicit links. Every taxonomy carries the key <its kind>:<id> for each of its own nodes, with no rows: ncbi.link("12", "ncbi") is the node 12 was merged into, through the alias handling that every store has (so a taxid from a 2019 OTT resolves to its current node for free). translate joins on every kind the two share, and a kind is shared when one side has stored links of it and the other has links of it or is of that kind (OTT with stored ncbi links against NCBI, whose ids are the keys). Two taxonomies of one kind do not join on their own ids (GTDB 214.1 to 232 goes through genomes, not through names). via= restricts the kinds. The votes are the same code: one key per node, weight 1 (leaf) or 1 (genome), abstention and cap unchanged; with ids as keys every node of the source subtree holds one, so a single-child chain can answer finer than the source node, which cap is for.

Genomes. A genome is stored under its full accession (genome_key): GCF_000005845.1 and GCF_000005845.2 are two genomes (assemblies are versioned), so are GCA_000005845.1 and GCF_000005845.1. Looking one up (link(s) of kind genome, and the join of translate) follows the rule above on top of the stores' links(kind, bases). A versionless query finds the genome if one version is stored, a query for a version that is not stored falls back to the only stored one. GTDB's metadata files carry the NCBI taxid of each genome; rather than a second kind of link, these are genome links of the NCBI taxonomy: gtdb_links(version) yields Link(accession, ncbi taxid, organism, "gtdb:232"), and load("ncbi", assemblies=links) (or ncbi.with_links(links)) adds them. Real links carry old taxids (assembly summaries and GTDB metadata name taxids that were merged since, and deleted ones): at build or load (write_taxonomy, tested on both stores) a merged taxid moves to its current node (through at most MAX_ALIAS_HOPS merges) and a link of a deleted, unknown or cyclic one is dropped, so stored links always point at nodes. assemblies=True streams NCBI's RefSeq and GenBank assembly summaries instead. No special cross-taxonomy machinery: one table shape, one join, either direction.

Link sources. The links of one taxonomy can come from several sources (NCBI with ncbi-assemblies, which NCBI keeps current, and gtdb:232, a snapshot of release time) and may disagree. Every link has a source label (Link.source; the default is taxonomy, a loader's own links; with_links(links, source=) labels added ones), the file keeps the labels in the order they were built (store.link_sources, label to LinkSource(kind, links, provenance): the link_source table, which link.source refers to, with the kind, the number of links and the files the links came from), and nothing is dropped at build time: a source that lists a key twice is an error, different sources may list it, on different nodes. link(key, kind, sources=), links and translate(sources=, other_sources=) take sources: a label, a list of labels in order of precedence, or None for all of the kind. A lookup in all sources (None) finds the key when they agree on the node and is ambiguous when they disagree: the candidates (Link, with their sources) are listed exactly as the versions of an ambiguous accession, one mechanism (match_link). With a list the first source that has the key wins. translate always resolves by precedence (the list, else the order of the build) so a key votes once, with the node of its first source; a key whose first link lies outside the subtree of the node being translated is not in that subtree (a second lookup, only for links of a later source). sources is for the taxonomy translated from, other_sources for the one translated into. The build logs the links per source at INFO and, at WARNING, the number of keys the sources put on different nodes (examples at DEBUG): omnitax build shows how far GTDB's snapshot is behind.

Link attributes. A link has attrs, one JSON dict (Link.attrs, the link.attrs column: an id of the attrs table, so equal dicts are stored once and nodes and links share the table): what else is known of the link, so that a new field never needs a new column. The ncbi-assemblies source fills it from the assembly summaries with the columns that say what kind of assembly it is (refseq_category, assembly_level, version_status, genome_rep, assembly_type, group, release_type, seq_rel_date, relation_to_type_material, excluded_from_refseq, asm_not_live_date, species_taxid). The size decides what is kept, because a dict that is different for every link is stored 4.6 million times: measured on the real build (RefSeq and GenBank, 4.6 million links, 2.02 GB without attributes) the low-cardinality fields and the species taxid cost 3 % (2.08 GB), with the release date 6.6 % (2.15 GB), with the three rarer ones 9 % (2.21 GB, the set kept), and the genome size and GC added 52 % (3.06 GB), the assembly name 52 % (3.06 GB), the FTP path 88 % (3.79 GB). So those are not kept; a download goes by accession. A translation asks the stores for links attrs=False (a server leaves them out of the answer). Choosing sets of genomes by these attributes, and the historical summaries, are open decisions: today a selection is a filter over store.rows().links.

Taxdumps

Taxonomy.write_taxdump(directory) (omnitax export-taxdump) writes any taxonomy as NCBI-style files, omnitax.taxdump. Ids that are all numbers (NCBI) are kept and written streaming, with the node attributes in the 18 columns of new_taxdump (unknown ones empty, so reading it back adds nothing: the tree, names, attributes, aliases and genome links of the fixture NCBI come back equal). Others get TaxonKit's ids, a port of taxonkit/cmd/create-taxdump.go (Assigner): the xxHash64 of the rank and the lower-cased name, 31 bits, the root 1, a collision in one export moves to the next number, so does the same name under another parent, lineages fed one at a time, lowest rank first; GTDB's domain is written superkingdom and hashed so; genomes are no rank nodes named by their assembly number without prefix and version; taxid.map is key<TAB>taxids. The port is order dependent where ids collide (911 collisions among GTDB 232's 1.1 million nodes), so the records are the genome links in order: a taxonomy loaded from GTDB's files (ar53, bac120) writes byte-identical nodes.dmp, names.dmp and taxid.map to gtdb-taxdump R232 (1,148,710 nodes, 901,341 genomes); one saved into a SQLite file keeps its links in their order (link.seq) and writes the same bytes. merged.dmp and delnodes.dmp of the releases carry the history of the earlier ones and are not reproducible from one release; omnitax writes its aliases that have numbers. The xxHash64 is the xxhash package's when installed (optional extra taxdump), else a pure-Python one (tested against the package and published digests; 34 s against 12 s for GTDB 232). The reader is the loader kind taxdump (NCBI's parser, the dump's taxid.map as genome links of source taxid.map, further taxids of a key in taxid.map/2, ...): gtdb-taxdump and ictv-taxdump are readable sources; ictv-taxdump loaded, hashed again with the recipe, has all 20,850 of its ids. No native ICTV loader.

Overlays (omnitax.overlay). Changes kept as data and applied again to every new version: the format of the custom loader in nodes.tsv (id parent rank name, parent_name guard, other columns are attributes), links.tsv (key node kind name source) and remove.tsv. Declarative: a new id adds a node, an existing id changes it, so applying twice or in another order gives the same taxonomy (a JSON operation log was rejected: no comments, not spreadsheet friendly). _Apply stages every change on the base's nodes and aliases (in memory; names and links stay streams), collects every problem with its file and line, and only then lets the rows through, so the SQLite write (one transaction, FILE.PID.RANDOM.part + rename for a new file) never starts on a bad overlay. Rules: merged parents followed (info), deleted or unknown parent, parent_name mismatch, numeric new ids in a taxonomy of numbers (the majority of ids are digits), merged or deleted ids, cycles, nodes with children removed (an error unless the overlay deals with the children: the least surprising, nothing moves silently), links to missing nodes; changes to the base's own nodes are one summary warning (a count and three examples; each at DEBUG); uninformative.tsv / apply(uninformative=) extend meta["uninformative"], the list the loader of a taxonomy declares (NCBI's three nodes: the one NCBI fact that was a constant in core) and Taxonomy.uninformative reads. Taxonomy.apply(overlay) and omnitax build --overlay (repeatable); the files' sha256 are in the provenance with "role": "overlay". Links keep the order they were given in (link.seq), which makes the taxdump export of a file the same as that of the files it came from. In a taxdump, nodes with ids that are not numbers of an otherwise numeric taxonomy get the recipe's ids, avoiding every id of the export.

How SILVA, Greengenes2 and OTT could plug in (planned, nothing of this is implemented: see the roadmap): each would be a loader that emits links, a pure addition.

  • SILVA to NCBI: silva_ena_links(version) reads taxmap_slv_* and ncbi/taxmap_embl-ebi_ena_* together and emits Link(acc.start.stop, silva id, source="silva-ena:138.2", kind="seq") for the SILVA taxonomy and Link(acc.start.stop, ncbi taxid, ...) for NCBI. Sequences are many-to-one (510 000 for 11 000 SILVA nodes): the vote does the rest, merged taxids (1.7 %) follow the aliases.
  • GTDB to SILVA: gtdb_links also emits Link(genome accession, silva node, "gtdb-silva:232", "genome") from ssu_silva_blast_subject_id (a SILVA sequence id, resolved to its node), optionally by identity; the genome kind joins it to everything that has genomes (NCBI, GG2).
  • Greengenes2: its loader emits genome links from the G... and RS/GB-... feature ids and seq links from the bare accessions and contigs (gg2:2024.09, GTDB r220), as it streams taxonomy.id.tsv.
  • OTT: sourceinfo becomes one source per foreign kind (ott:3.7.3/ncbi, /gbif, /irmng, /worms, /if) of ncbi:562-style links, silva:ACC a seq source: OTT to NCBI needs nothing else, because NCBI's own ids are implicit keys (one key per node, the same vote); OTT to GBIF waits for a GBIF taxonomy with its ids as nodes.
  • In each case the source label carries the version coupling (silva-ena:138.2, ott:3.7.3/ncbi = NCBI 2019-10-15), and DEFAULTS gets an entry only when a benchmark has measured the conversion.

The tree as nested intervals

One depth-first pass numbers the nodes (dbwrite.number_tree): a node's lft is its position in pre-order (children in the order of their ids), its rgt the last position in its subtree, so the subtree of a node is the nodes whose lft is between its lft and rgt, a range of one index (node_by_lft). A parent that is no node makes a root; nodes in a cycle no root reaches have no numbers and no subtree. write_taxonomy numbers the nodes after inserting them (3 million NCBI nodes: a few seconds, from the sorted ids; an edited copy is a new file, so it renumbers). What it replaces and what it makes possible:

  • the store primitive subtree(id) (pre-order, with whether each node is a leaf: rgt == lft) replaces the level by level children() walks of descendants(), leaves(), subset(descendants=True) and prune; it streams one range of an index, and over the wire one request (GET /{taxonomy}/subtree?id=) instead of one per level;
  • links_under(id) is one join of the subtree range with the links (link_by_node) instead of a query per level; it is what translate collects its votes with, streamed (a SQL cursor, an NDJSON response: no cap, any size, over a socket too); translate looks the accessions up in the other taxonomy MATCH_BATCH (20 000) at a time and keeps only the node of each, so its memory is the {accession: node} of the clade and not a link object per genome (d__Bacteria, 700 000 genomes: 760 MB to 440 MB), a link that is alone for its number skips the sort of match_link, a Placement is built from the lineages the vote already fetched, and the weights of a Placement are rounded to 12 significant digits (sums of fractions carry float noise such as 187784.99999999988);
  • search(..., within=id) restricts the names to a subtree. Every plan joins the node already, so the range is one more condition (n.lft BETWEEN ? AND ?); when the subtree has fewer than 20 000 nodes the search reads the names of those nodes (name_by_node) in one query, like it does for a rare rank or class. Names of the best rank are still read first, so a subtree that holds a tenth of the names costs ten times the rows of an unrestricted search, and stops at the limit.

Provenance

Where a taxonomy came from is recorded with it, Taxonomy.provenance: {"omnitax": version of the writer, "files": [{"source", "size", "sha256", "verified"}]}, one entry for every file of the build, downloads and local files alike, links for genomes (ncbi-assemblies, GTDB's metadata) included. A download is hashed as it arrives (sha256 and md5 in one pass, a resumed download reads what it already has once); a cached or local file is read once; an assembly summary that is streamed (no cache) is hashed as its lines are read, and its entry is added when it ends, which is why write_taxonomy reads the provenance at the end, after the rows. verified is "md5" for a download that matched the checksum the publisher gives: NCBI's new_taxdump.tar.gz.md5, the MD5SUM.txt of a GTDB release; a mismatch fails the build and the file is not kept. NCBI publishes no checksum for the assembly summaries or for the archive dumps (checked: 404), so those are only recorded. Stores carry the provenance (SqliteStore, RemoteStore: /taxonomies), copies keep it. It is split as the data is: Taxonomy.provenance is that of the tree (the taxdump, the GTDB taxonomy files), and every source of genome links keeps the files its links came from (Taxonomy.link_sources[label].provenance: the assembly summaries of ncbi-assemblies, GTDB's metadata for gtdb:232), because they are different files at different dates. The loaders hand write_taxonomy one dict, {"files": [...], "link_sources": {label: {"files": [...]}}}, and it files each part where it belongs. A file of a URL is recorded under its URL, downloaded now or found in a --cache-dir (then with its path too); only a local file (--file, files=) is recorded by its path.

NCBI versions are dates. A dump has no version number, but the files inside new_taxdump.tar.gz carry the time they were made (all within ten minutes of one day, UTC: the dump of 2026-11-26 has members of 11:31 to 11:40, published at 14:42), so a dump's version is the day of its newest member: ncbi:2026-11-26. A bare ncbi still means the newest in a file, and omnitax build ncbi builds the current dump under its date. The monthly archive (taxdump_archive/new_taxdump_YYYY-MM-01.zip, 96 files from 2018-12-01) is taken at midnight, so its members are dated the day before: for an archive file the date is in its name. ncbi:DATE builds from the archive if the date is there, or from the current dump if the date is its day, and is otherwise an error that names the nearest dates. A local tarball is dated by its members, a local archive zip by its name, loose files (a directory) have no date and keep the version you give. The assembly summaries have no archive: links from ncbi-assemblies can be told apart by their checksums but not rebuilt.

Read-only views, copying edits

prune(ids) removes the nodes and everything below (keep=True keeps the nodes themselves as leaves, which is what multitax's prune does). apply(remove=) takes out single nodes, and refuses a node that has children unless the same call removes them or gives them another parent, so a tree is never broken. Subsets and edits keep nodes, extra names, aliases and links of what is left.

Every Taxonomy is read-only. subset, prune and apply return a new taxonomy (built into a temporary file of its own) and never change the store they came from, so the same calls work on a file or a server (subset a remote NCBI into a local tree) and nothing is ever half-edited. save() writes a taxonomy into a SQLite file.

Temporary files

There is one local store, SqliteStore; a taxonomy that is not in a file you gave (load, subset, prune, apply, with_links) is built by Taxonomy.build(rows, kind, version, provenance, path=None, fuzzy=None): write_taxonomy into a file in a private tempfile.mkdtemp directory (of $OMNITAX_TMPDIR, else the system's: on this Fedora /tmp is a RAM disk, so NCBI's ~1.2 GB sit in memory, as the dicts of the first design did), opened as a SqliteStore. The Taxonomy owns it: close() removes the directory, and a weakref.finalize on the store does it when the store is garbage collected (a taxon, a lazy rows() stream or a with_links result keeps the store, and so the file, alive) and at exit. path= keeps the file there instead, as omnitax build does (cmd_build is load(..., path=, fuzzy=)); fuzzy defaults to off for a temporary file and on for path. Taxonomy(store) reads kind, version and provenance from the store (Store.kind, Store.version), so a taxonomy is the same object whether it was built, opened or connected.

Why a file and not sqlite3.connect(":memory:"): a store opens read-only connections to a file by path (lent to the calls and streams that need one) and notices a replaced file by its identity; a plain in-memory database exists for one connection, which would need a second, locked single-connection code path, and a shared-cache one is discouraged by SQLite, cannot be mode=ro and vanishes with its last connection. A temporary file has the one code path of a persistent file, works with threads, can be passed to serve as it is, and is copied to a new path by VACUUM INTO in save(), with the trigram index added to the copy when the caller asks for fuzzy and the file has none (NCBI: 6 s against 65 s for a rebuild). What it costs: an edit is a rebuild (GTDB seconds, NCBI about 90 s), so edits are batched in one apply(nodes=, links=, remove=), and a read of a local taxonomy is a SQL query where it was a dict lookup (the record cache of SqliteStore and the nested intervals keep that small). The word index stays (prefix search needs it); the secondary indexes are created after the bulk insert for a new file (schema.INDEXES), which is cheaper than keeping them up to date and also smaller. Measured on the real NCBI new_taxdump: see the changelog.

Consensus, LCA and translation

One function covers all of them. Given weighted nodes (a node may appear with the number of genomes behind it):

  • threshold=t (default 0.9): the deepest node that strictly more than t of the weight has as ancestor-or-self. threshold=1.0 is the strict LCA. With t=0.5 this is the majority rule used by CAT/BAT.
  • top=p: multitax's heuristic: keep the most common nodes until they cover p of the weight, then take their LCA. Giving both threshold and top is a ValueError.
  • Ties are broken the same way everywhere, so the input order never matters: the deeper node, then (for threshold) the heavier, then the smaller id.
  • min_informative=f (off by default in consensus; translate turns on 0.2 for GTDB → NCBI; False: off; top= has none): abstention. Votes on informal species are lifted to their nearest formal ancestor (with ranks, to the nearest ancestor of one of them), and when a node X is judged the votes whose node is a proper ancestor of X are not in X's total (they say nothing below their node); votes in other branches still count against, and the weight left must be at least f of all the weight (the guard against one informative vote among many placeholders). Passing means support(X) > threshold * (total - abstaining(X)), which is monotone down the tree (a failing node fails all its descendants), so the deepest passing node is found among where[id] = (depth, abstaining weight) of one pass over the vote paths. top= has no abstention (it is a different rule: a fixed share of the heaviest votes), so top= with a min_informative other than False is a ValueError; lca is plain. A Placement has the support, the informative total and the abstained weight. The benchmark (below) picked the guard and the default, and shows precision and recall per rank. threshold stays 0.9 (naming, precision first); for placing novel genomes 0.8 is the recommended value (benchmark README).
  • Defaults per conversion. translate reads threshold, min_informative, ranks and the exclusion of the target's uninformative nodes from consensus.DEFAULTS[(source kind, target kind)], falling back to consensus.FALLBACK (consensus always uses the fallback: threshold 0.9, plain voting, no ladder, nothing excluded); the signature defaults are None (= from the table; min_informative=False, ranks=() and exclude=() are off). Only measured conversions are entered, each with the benchmark that measured it: today ("gtdb", "ncbi") = threshold 0.9, min_informative 0.2, ranks=GTDB_RANKS, uninformative nodes excluded (the whole entry is the measured configuration), measured on GTDB 232 → NCBI 2026-11 (bacteria and archaea, leave-one-species-out and leave-one-genome-out; benchmarks/). NCBI → GTDB and GTDB release → release were not measured and use the fallback. Taxonomy.defaults_for(other) shows what applies. Translation needs keys that both taxonomies share (today genome accessions: NCBI assemblies, GTDB), so SILVA, Greengenes and OTT cannot be translated yet.
  • exclude: subtrees whose members do not vote (for NCBI: unclassified sequences, other sequences, environmental samples; tax.uninformative).
  • ranks/formal: lift the result to the nearest ancestor-or-self with a listed rank, optionally skipping informally named species (NCBI specified_species = 0). The result is None when nothing at or above the consensus has one of the ranks: the signal, in a nearest-taxon walk over ever larger clades, to try the next one.

Translation from taxonomy A to B maps a node of A to the genomes under it, the genomes to their nodes in B (accessions matched with or without version), and runs the consensus on those. The same mechanism converts between GTDB releases. Keys are normalised (link_key; for genomes genome_key) inside the stores; every public method that takes accessions accepts raw ones (RS_GCF_…, any case).

Which rule works best is measured, not argued. The leave-out benchmark (benchmarks/README.md: GTDB r232 genomes with known NCBI taxid, placed into NCBI, standard ranks) shows that threshold beats top at equal precision (it never answers "none", and resolves deeper), and that 0.5 is too eager: leaving out a whole species, 85.3 % of the answers are not wrong at 0.5, 91.6 % at 0.7, 95.6 % at 0.9 (20 % of the answers correct at genus or finer), 96.3 % at 0.95 and 96.8 % at 0.99, where resolution collapses (10 % at genus or finer). 0.9 is the elbow, hence the default. Method and tables: the translation page.

translate adds two orthogonal options, measured by benchmarks/translate_weights.py:

  • weight="leaf" (default) or "genome". By genome, a heavily sequenced species decides for its genus (GTDB Pseudomonas 214.1 → NCBI P. aeruginosa). By leaf, every node of the source subtree that holds genomes votes with weight 1 in total, split equally among its genomes (fractional weights; ties stay deterministic, and comparisons carry a relative slack of 1e-9 so that 1/3 + 1/3 + 1/3 is not a coin toss). Rank-free, so it works for any taxonomy pair; for one leaf it equals genome weighting. Genomes sit on the node they are attached to, which is a leaf in GTDB and mostly in NCBI. Genomes whose target node falls under exclude are dropped before the weights are split, so a leaf's vote is shared only among its voting genomes, and a leaf left with none contributes nothing.
  • cap=False (default), True or a ladder of ranks (coarse to fine): never answer finer than the source, compared on GTDB_RANKS for True or on the given ladder (a source off the ladder counts as its nearest ancestor on it; a finer result is lifted to the nearest ancestor whose own rank is on the ladder and at most the source's; with no ladder rank in either lineage nothing is capped). GTDB_RANKS is GTDB's seven ranks, which also fix lineage_string's d__...;s__ format; it is not a universal ladder (no kingdom), and everything that needs ranks takes ranks=; the abstention lift uses the ranks it is given, not GTDB_RANKS. multitax's translation is weight="genome", cap=True with top=.

consensus has neither (its weights are the caller's, and it has no source node). In the benchmark leaf weighting is a small gain (0.3 to 1.6 points of precision over genome weights); the cap was measured earlier, before the truth was lifted to its formal ancestor: at 0.9 it bought 2.3 points of precision for 0.12 of yield, and is not in the current grid (benchmark README). The default is leaf, no cap.

Details. consensus and translate take details=True and then return a Placement(taxon, support, total, votes, abstained) (one mechanism: both compose three steps, votes_of (who votes, with their lineages), decide (the id of the answer, by threshold or top; these are in omnitax.consensus, pure functions over lineages) and _answer (the rank lift), and _placement turns the votes into the object): support is the weight at or below the final taxon (after the rank lift and the cap), total the voting weight, votes the whole input distribution as (Taxon, weight), heaviest first; for translate that is multitax's translate(counts=True). The default return stays the taxon, so nothing is built (no extra lookup) unless asked.

Search is autocomplete (the tables are in the Python guide). match: exact, prefix (default), substring, fuzzy, each finding what the one before finds and then more; the kinds of match inside them are tiers, tried in this order until limit nodes are found: equal; starts with; a later word starts with (sapiens); an abbreviated binomial (e. coli: first word starts with e, second with coli); for substring contains; for fuzzy resembles. Inside a tier, names are ordered by name_pref: class (the node's own name, then synonyms and common names, then includes, in-part and type material; authorities only match exactly), then standard rank before any other, then length, then alphabetically, then node id; a node appears once, by its best name, and the answer says which (Hit, Match). Names and queries pass through one normalize (case, diacritics, whitespace, _ - brackets as blanks, quotes dropped, × as x), so what the user types and what is stored compare alike; the trailing space of a query is kept because it ends a word. classes restricts the name classes and rank the rank, both inside the query; unknown ones are errors, the stores list what they have (ranks, name_classes). Why the pieces are what they are:

  • A file keeps its names in rank order: the id of a name row is its rank, so "the best 10" is "the first 10 by id" and any index that yields ids in order needs no sort. write_taxonomy stages the names and inserts them sorted by (pref, lc, node, seq); tests/reference_search.py sorts by the same key in plain Python, and tests/test_stores.py compares the SQL strategies with it on adversarial names (the oracle of the search, which no store ships).
  • Starts with: a prefix with fewer than 3000 names (counted, capped, on name_by_lc) is read from that index and sorted; a longer one (e, esc) reads the names of the taxonomy by id, that is in order of rank (or, with a rank, those of that rank through name_by_rank), checks lc of each and stops at limit. The matches of a prefix with at least 3000 names are at least 1 in 1600 of the 4.8 million NCBI names, so a letter reads hundreds of rows and the work is bounded by the limit and the density, not by the millions of names of e; nothing is sorted. Word start and abbreviation read the word index (ft, FTS5, yields rowids in order) for the first word of the text and check each name (instr(lc, ' ' || text)), also in order of rank, stopping at limit. CROSS JOIN fixes the join order (SQLite otherwise starts at the names and matches the index for each of them: minutes). The word index (ft) is always built. Substring and fuzzy search need the trigram index (fw, fg: the vocabulary of ft and its trigrams), which --no-fuzzy leaves out: substring behaves as prefix then, fuzzy is an error.
  • Authorities (1.16 million NCBI names such as Homo sapiens Linnaeus, 1758) are left out of the word index and of default searches: they drown the real names (escherichia found Leclercia through "Escherich's ..."). An exact match still finds them and classes=["authority"] asks for them (prefix and exact only).
  • Substring on SQLite needs a word of three letters or more (the trigram index narrows the names); otherwise there is nothing to narrow by, a scan per keystroke is not acceptable, and it behaves as prefix.
  • Fuzzy search (words and trigrams) has no reference to compare with; the other three modes are compared with tests/reference_search.py.

Links may carry a name (the organism of a genome: NCBI assembly summaries, GTDB ncbi_organism_name). link(key) returns Linked(key, taxon, name, source, kind) (None when unknown or ambiguous); links(keys) is the batched form (the kind is genome unless given: there is no separate genome()). The name travels in the links primitive with the node: one query, one request.

GTDB representatives=True is a load option: the taxonomy keeps all its nodes but only the species- representative genomes (gtdb_representative of the metadata files). multitax's convert uses exactly those genomes of the source release and looks them up in the target's full genome table, which is old.translate(clade, new) with old loaded with representatives. multitax returns the set of target nodes of the clade's rank; details=True gives that set with weights.

Metadata (Rows.meta, Taxonomy.meta, the meta column of the taxonomy table, GET /{taxonomy}/meta): NCBI's division and genetic code tables, with ids as strings (JSON); a node's attrs hold the ids, so a genetic code is tax.meta["genetic_codes"][str(t.attrs["genetic_code"])]. No NCBI specific property on Taxon: it stays generic. The layout number of a file (PRAGMA user_version) is derived from the DDL (omnitax.schema.LAYOUT, a CRC of the tables, indexes and index templates with comments and white space left out), so any change of the layout refuses the files of the old one at open (LayoutError) and nobody has to remember to bump it.

Not done: multitax's latest column of write: for a node of the taxonomy it is the node itself (merged ids are aliases, which many resolves), so the column would only repeat id.

SQLite file

One file, many taxonomies, addressed as kind:version (a bare kind is the newest version; no name is fine for a file with one). Every table is keyed by the taxonomy's row id. Full layout in the database reference.

table content
taxonomy id, kind, version, provenance (JSON, of the tree), built, fuzzy, counts, meta (JSON), ranks (cache)
attrs taxonomy, id, JSON: one row per distinct attribute set
node taxonomy, id, parent, rank, name (the id of the node's own row in name), attrs (an attrs.id), lft, rgt (nested intervals, below)
name_class taxonomy, name, count: the classes of the names (name, synonym, authority, ...)
name taxonomy, node, name, class (a name_class), normalised name (lc), rank of the node (a cache): every name, in rank order
alias taxonomy, old id, new id (NULL: deleted)
link_source taxonomy, label, kind, links, provenance (JSON, the files of its links): where links come from
link taxonomy, key (a genome: upper case, no RS_/GB_), source (a link_source, which has the kind), base (without version or region), node, name (optional), attrs (an attrs.id, optional)

Every reference is a declared foreign key (deferred: a node refers to its name and a name to its node), enforced when OMNITAX_FOREIGN_KEYS is set, as the tests do, and a parent that is no node is stored as a root. A node's name is stored once, as its row in name (node.name is the id): before, the name was in node and again in name. name.rank and taxonomy.ranks are caches of the node table that make rank filters cheap. Details in the database reference.

Deviations from the first sketch: attributes are interned in attrs (NCBI's attribute JSON would have been 400 MB of 1.1 GB; now it is a few thousand rows), and name holds the primary names too, so one index serves exact, prefix and synonym search and Taxon.names is one query. The fuzzy index (FTS5 words, vocabulary, trigrams) is per taxonomy, in tables named after its id.

Reads: a store keeps a few idle read-only connections (IDLE_CONNECTIONS) and lends one to each call; a stream keeps its connection until it ends. What a store knows of its taxonomy (its row id, the ids of its name classes and link sources, the record cache) is a _View of the file, and every call first checks that the file is still the one the view was made of (same device, inode and modification time; the taxonomy still there with the same row id). If the file was written again or renamed over, the next call makes a new view and the old one is retired: calls and streams that are running finish on the file they began on. A taxonomy that is gone is a KeyError, a replacement between two steps of one call a FileChanged (the call retries once itself). Files are opened mode=ro with query_only; one on a medium that cannot be written is opened immutable. ancestors and children walk the tree one level per query for all ids at once (measured faster than a recursive CTE per id and sharing work between lineages; a store keeps the records it fetched, up to 100,000, so that the upper levels, which every lineage passes through, are fetched once: a consensus over a file went from 8 times slower than the dicts it replaced to about 3 times); links_under and subtree are one range of node_by_lft; the node_by_parent index is forced (INDEXED BY) because without ANALYZE the planner scans the taxonomy for children.

Writes: one transaction per taxonomy, replacing an existing kind:version inside it. A new file is written as FILE.PID.RANDOM.part (a name of its own, so two builds of one path do not meet) without syncs and with the journal in memory, switched to WAL, flushed (fsync) and renamed into place (then the directory is synced). Files stay in WAL mode, so readers and the one writer do not wait for each other; a second writer waits 60 seconds and then fails. An existing file is written in one transaction and VACUUMed afterwards when a taxonomy was replaced (a failing VACUUM is a warning, not a failed write). A reader that only reads leaves -wal and -shm files beside the file (see the database reference). The secondary indexes are created after the bulk insert of a new file.

Server

omnitax serve FILE serves every taxonomy in the file. A Catalog (the file, stores opened on demand and found again when taxonomies are added or replaced) is closed over by taxonomy_routes(catalog), which can be mounted anywhere without shared names. Endpoints mirror the store protocol and are batched: GET /taxonomies (with the batch limit, so RemoteStore splits to it, and the integer api_version, which RemoteStore compares for equality with its own store.API_VERSION: a different server is refused), POST /{taxonomy}/nodes, /ancestors, /children, /names, /search, /links (a kind and bases), /links_under (GET /{taxonomy}/links_under?id=, NDJSON like subtree, so any size) and GET /{taxonomy}/meta, GET /{taxonomy}/rank/{rank} and GET /{taxonomy}/rows/{nodes,names,aliases,links} as NDJSON (four independent streams, because Rows has four independent iterables; --no-export refuses them). Algorithms run in the client. The status of a stream is sent with its first chunk: a file that cannot be read at the start is a 503; a failure later just ends the response (see Errors for the statuses: an unknown taxonomy is a 404, a file that is missing, locked, replaced or of another layout a 503 that the client retries).

ancestors answers {lineages: {id: [ids]}, nodes: {id: record}}: every node once, since lineages share most of theirs. ancestors(ids, attrs=True) takes a hint: algorithms that only need ids (consensus, subset, the lineage columns of write) pass attrs=False and a store may leave the attributes out; the remote one does, on the wire (1000 random NCBI taxids: 1.0 MB with, about 0.18 MB without), local ones ignore it. Taxon.lineage and closest keep them. (An attrs-reference wire format would need no flag, but costs a table in every answer and code on both sides; the optional hint is leaner.)

The server has no authentication and no rate limit: those belong to the host app or a reverse proxy (see serve). omnitax.server holds the endpoints, omnitax._serve the sockets (mode 0660, a live socket is never taken, SIGTERM removes ours).

Command line

  • omnitax build -o FILE ncbi gtdb:232 silva ... adds taxonomies to a file (replacing the same kind:version); modifiers +assemblies and +gtdb:232 add genomes to ncbi; --file KIND=PATH uses local files; custom:NAME loads a table. The spec grammar is loaders.parse_spec. Files are parsed as streams straight into the file.
  • omnitax export-taxdump DIR: a taxonomy as NCBI-style taxdump files (see Taxdumps below).
  • omnitax list, lookup, lineage, search, link (--kind seq, ...), translate (--via KIND): queries against a file, a server or the environment default (-t kind:version picks the taxonomy), TSV with a header.
  • Names that tie in rank are ordered by the node id: numerically when it is digits (9 before 10), else as text (write_taxonomy sorts the names so in SQL), so every store, search, by_name and annotate agree.
  • omnitax annotate [FILE]: adds columns of taxa (id, name, rank, lineage, a rank such as genus) to a table, one batch of rows at a time: the batches are Taxonomy.many, Taxonomy.lookup (the store primitive by_name: exact names for many texts at once, as search(match="exact") gives them, for one query or one request) and Taxonomy.links (--by link, with --kind seq for another kind), plus one ancestors call for the lineages. Homonyms (a name of several nodes) and accessions of several versions or sources are ambiguous: empty cells, or the best with --ambiguous first; the count of what was not found is logged.
  • omnitax serve FILE.

Not doing

  • No search across several taxonomies (owner's decision): the ids of different taxonomies mean different things and so would the ranks, and a ranking across them would be a guess. Search one taxonomy, or ask each.
  • No mutable trees (so no add and remove on a taxonomy: edits are apply, which makes a copy) and no lazily built caches to manage (multitax's build_lca, build_lineages): lookups are fast enough per backend.
  • No compatibility layer for multitax or for the previous (NCBI-only) schema or wire format.
  • No taxid autocomplete (digits completing ids), no genetic code tables: search is about names. Genetic codes survive as node attributes.

Notes

  • GTDB releases 80 to 232 all load (taxonomy and metadata); the metadata accession and ncbi_taxid columns are found by header name (their index moves between releases) and only numeric taxids count. Release-to-release translation uses the genomes named in the taxonomy files themselves. Measured 214.1 to 232: genera such as Lactobacillus, Bacillus, Clostridium map to themselves and back; E. coli of 214.1 lands on family Enterobacteriaceae at 0.9 (31 % of its genomes moved to other 232 species, at 0.5 it gives Escherichia coli), which is what the threshold is for.

  • Downloads go to a temporary directory that lives while parsing, or into cache_dir (an existing file is reused; delete it to refresh). There is no separate output option. Assembly summaries are streamed and never stored unless cache_dir is given.

  • Memory: omnitax build streams into the file; NCBI peaks at about 1.1 GB, since the nodes of the taxdump are read once for their scientific names. load writes the same temporary file (see Temporary files).
  • SILVA's current/ URL moved to another release; the release-specific release_138_2/ path is used.
  • omnitax.Taxonomy and omnitax.Taxon are the core classes (the NCBI-only ones are gone).