build¶
omnitax build -o FILE SPEC... [--file KIND=PATH]... [--source-url KIND=URL]... [--cache-dir DIR] [--overlay DIR|FILE]...
[--no-fuzzy] [--columns COLS] [--sep SEP] [--custom-header] [-q] [--log-level LEVEL]
Adds taxonomies to a SQLite file (created if it does not exist). One file holds any number; the
query commands, omnitax serve and
omnitax.open read it. The files are parsed as a stream straight
into the file, so a build needs little memory (omnitax.load does the same into a temporary file, see the Python guide; omnitax build is load(..., path=FILE)).
A SPEC is kind[:version][+modifier].... Each taxonomy is one spec, and its modifiers combine with +: ncbi+assemblies+gtdb:232 is NCBI with both kinds of genome links. Two specs of the same taxonomy (ncbi+assemblies ncbi+gtdb:232, or ncbi ncbi:current) are refused before anything is downloaded, because the second would replace the first and the file would lose its links. The kinds:
| SPEC | Source |
|---|---|
ncbi, ncbi:2026-11-26 |
NCBI new_taxdump: the current dump, which is named by its date (ncbi:2026-11-26, from the dates of the files inside it), or the dump of a date: NCBI's monthly archive (taxdump_archive/, the first of every month from 2018-12-01, 96 files) or the day of the current dump. Any other date is an error that names the nearest dates |
gtdb, gtdb:226, ... |
GTDB releases 232 (default), 226, 220, 214.1, 207, 202, 95, 89, 86.2, 83, 80 |
silva:ssu_138.2, silva:lsu_138.2 |
SILVA taxonomy |
greengenes, greengenes:2022.10 |
Greengenes 2024.09 (default) and 2022.10 |
ott, ott:3.6 |
Open Tree taxonomy 3.7.3 (default) and 3.6 |
custom:NAME |
your own table, from --file custom=PATH |
taxdump:NAME |
an NCBI-style taxdump (a TaxonKit create-taxdump one: gtdb-taxdump, ictv-taxdump; or NCBI's), from --file taxdump=DIRECTORY-OR-TARBALL; its taxid.map becomes genome links (see taxdumps) |
Add --overlay DIR (repeatable, applied in order to each SPEC) to change the taxonomy with your own taxa; it is checked before anything is written and its files are recorded in the provenance (see Adding your own taxa).
Modifiers: ncbi+assemblies and ncbi+gtdb:VERSION add genomes (below), and gtdb:VERSION+representatives
keeps only the species-representative genomes of that release (it also reads the release's metadata
files; with --file, pass them too).
| Option | Default | Meaning |
|---|---|---|
-o, --output FILE |
required | the SQLite file |
--file KIND=PATH |
download | a local file instead of a download; repeatable (--file gtdb=bac120.tsv.gz --file gtdb=ar53.tsv.gz). Plain, .gz, tarballs and directories (the files directly in them) work; two files of one name are an error. KIND is the kind of a SPEC (ncbi, gtdb, custom, taxdump, ...), or gtdb-links for the GTDB metadata of ncbi+gtdb:VERSION. Without KIND=, or with a kind that no SPEC has, it is an error (nothing is downloaded) |
--source-url KIND=URL |
the default | download from this URL instead of the default; repeatable; KIND as for --file (the GTDB metadata of +gtdb: can only be given with --file gtdb-links=) |
--overlay DIR\|FILE |
none | apply an overlay to every SPEC, in the order given; repeatable (Adding your own taxa) |
--cache-dir DIR |
temporary | keep downloads there and reuse them (delete a file to refresh it) |
--no-fuzzy |
off | skip the trigram index, which fuzzy and substring search need (about 5 % of an NCBI file); the word index (word starts, abbreviations) stays |
--columns, --sep, --custom-header |
id,parent,rank,name, tab, no |
custom: the columns of the table (id and parent are required; name any others -), its separator, whether it has a header |
-q, --quiet |
off | no progress output (downloads, steps, counts); warnings stay |
--log-level LEVEL |
info |
the library logs to the omnitax logger and the command prints it: info the steps and the genome links per source, warning also the number of genomes the sources disagree on, debug examples of them |
A taxonomy with the same kind:version is replaced in one transaction (the build says so, and when the old one had link sources, which of them and how many links, as a warning: a rebuild of ncbi alone drops the genome links an earlier ncbi+assemblies had): a failed build leaves the
file as it was, a first build that fails leaves nothing, and a running server serves the old or the
new taxonomy, never half of one.
Wrong input is an error (exit status 1, nothing written), not an empty taxonomy: a file the SPEC needs that is missing (the metadata
files of +representatives), a custom row with fewer columns than --columns names (the message has file and line: often a wrong
--sep), a file that is not UTF-8 text, a build that reads no nodes, or no genomes where the SPEC asked for them (+assemblies,
+gtdb:VERSION, +representatives). Every SPEC, version and --file/--source-url is checked before the first download.
A download goes to NAME.part and is resumed after an interruption only when the server says the file is still the same
(If-Range, with the ETag or Last-Modified kept in NAME.part.validator), else it starts over. Connection errors and 5xx
answers are tried again up to three times. Files are saved as the server sends them.
omnitax build -o taxonomies.sqlite ncbi gtdb:232 silva
omnitax build -o taxonomies.sqlite --file custom=tree.tsv custom:mytree
omnitax build -o taxonomies.sqlite --file gtdb=bac120.tsv.gz --file gtdb=ar53.tsv.gz gtdb:232
Genomes and translation¶
Genomes link taxonomies (they are links of kind genome; sequence accessions and the ids of other taxonomies are links too, see the Python guide): GTDB's own files name the genome (RS_GCF_000005845.2) of each species;
NCBI's assembly summaries name its taxid. Two modifiers of ncbi add them as genomes of NCBI:
ncbi+assemblies: NCBI's RefSeq and GenBank assembly summaries (about 4.6 million genome links, with their organism names; streamed, not stored unless--cache-diris given).ncbi+gtdb:232: the NCBI taxid of every genome of GTDB 232, from GTDB's metadata files (two downloads, 296 MB for release 232 (the table below has the others);--file gtdb-links=PATHfor local copies). It is much smaller than the assembly summaries, and it covers exactly the genomes GTDB knows.
Genome links often carry old taxids: real assembly summaries and GTDB metadata name taxids that NCBI has merged into others (and a few it deleted). The build moves such a link to the node the id was merged into (through chains of merges) and drops links of deleted or unknown taxids, so every stored link points at a node of the taxonomy.
Both can be combined (ncbi+assemblies+gtdb:232). The two sources overlap and may disagree (GTDB's taxids
are a snapshot of the release): every link is kept with its source (ncbi-assemblies, gtdb:232), nothing is dropped,
and the build reports how many accessions the sources put on different nodes. Which source decides is a choice at query
time (--source, link). A genome listed twice within one source is an error: the build fails and the
file stays as it was. With genomes in both, omnitax translate
and Taxonomy.translate go from GTDB to NCBI and back, and between GTDB releases:
omnitax build -o taxonomies.sqlite gtdb:232 ncbi+gtdb:232
omnitax translate --db taxonomies.sqlite -t gtdb:232 --to ncbi "s__Escherichia coli"
Provenance¶
Every source file of a taxonomy is recorded in the file, downloaded or local: its URL or path, its size and its
sha256 (computed while it downloads; a cached or local file is read once), and whether it matched the checksum its
publisher gives (a file of a URL is recorded under its URL, downloaded now or found in a --cache-dir, then with its path too; a local file by its path). NCBI publishes new_taxdump.tar.gz.md5 and GTDB an MD5SUM.txt for releases 207 and later: a download that does
not match fails the build and nothing is kept. When such a file cannot be checked (a GTDB release before 207, or a checksum list that cannot be fetched) the build warns, and the entry says verified: null. NCBI's assembly summaries (ncbi+assemblies), the archive dumps and
the other sources have no published checksum, so the checksum is only recorded. The version of omnitax that wrote the file is
recorded too. The files are split as the data is: a taxonomy keeps those its tree came from, and every genome source (ncbi-assemblies, gtdb:232) the assembly summaries or metadata files its links came from. omnitax list shows it, omnitax list --json all of it, and Taxonomy.provenance has it in Python.
The dump of ncbi:YYYY-MM-DD can be rebuilt from the archive (a zip named new_taxdump_YYYY-MM-01.zip: its files are
of the day before, the name is the date). NCBI keeps no archive of the assembly summaries: genome links from
ncbi-assemblies cannot be rebuilt for an old date, only told apart by the recorded checksums. Keep the file, or
a --cache-dir with the downloads, if you need them.
GTDB releases¶
Every release below was loaded end to end (taxonomy files, and the metadata files for
ncbi+gtdb:VERSION). Metadata files are the large download; the loader finds the accession and
ncbi_taxid columns by name, because their position moved between releases (column 50, 51, 77, 80),
and skips genomes without a numeric taxid.
| release | nodes | genomes | metadata download |
|---|---|---|---|
| 232 (default) | 247 369 | 901 341 | 296 MB |
| 226 | 181 960 | 732 475 | 241 MB |
| 220 | 146 380 | 596 859 | 197 MB |
| 214.1 | 113 318 | 402 709 | 119 MB |
| 207 | 88 762 | 317 542 | 81 MB (.tar.gz) |
| 202 | 65 949 | 258 406 | 65 MB (.tar.gz, ar122) |
| 95 | 45 503 | 194 600 | 41 MB (.tar.gz, ar122) |
| 89 | 36 283 | 145 896 | 210 MB (plain .tsv, ar122) |
| 86.2 | 21 818 | 127 315 | 158 MB (plain, ar122) |
| 83 | 18 385 | 109 414 | 134 MB (plain, one bac file with both domains) |
| 80 | 16 971 | 94 734 | 115 MB (plain, one bac file with both domains) |
All URLs resolve and nothing had to be dropped. Because the genomes of a release are named in its own taxonomy files, GTDB releases translate into each other without any download beyond the taxonomies:
omnitax build -o gtdb.sqlite gtdb:214.1 gtdb:232
omnitax translate --db gtdb.sqlite -t gtdb:214.1 --to gtdb:232 g__Lactobacillus
Size and time¶
Measured on the full current releases (peak memory of omnitax build about 1.1 GB for every NCBI
build, since the nodes of the taxdump are read once into memory for their scientific names):
omnitax build |
time | file |
|---|---|---|
ncbi (3.0 M nodes, 4.2 M names, with fuzzy index) |
59 s | 1.15 GB |
ncbi --no-fuzzy |
44 s | 1.00 GB |
ncbi+assemblies (4.6 M genome links, incl. download) |
3 min | 1.34 GB |
gtdb:232 ncbi+gtdb:232 (0.9 M genome links, incl. downloads) |
2 min 43 s | 1.40 GB |
Times include downloads from a fast connection.
Keeping it current¶
NCBI updates the taxdump daily. Rebuild whenever you want to follow it (--cache-dir keeps GTDB's
and the others' downloads; delete the NCBI one):
A running server serves the new taxonomy from its next request on, with no restart. When a build replaced a
taxonomy, the file is VACUUMed afterwards so it does not keep the old copy's pages; that needs free
disk space of about the file's size.