2 of 9 files were uploaded without provenance metadata. View details.
taxutils
Utilities for working with NCBI taxonomic data. If the Python interface is not needed, a port is available in Rust at taxutils-rs, available both as a crate and for install with bioconda.
Citation
@article{obrien2026taxutils,
title = {taxutils: Tools for managing and operating on NCBI taxonomy and accession mappings},
author = {O'Brien, William and Lee, Seungmo and Agarwal, Vivek and Eskin, Eleazar},
journal = {bioRxiv},
year = {2026},
doi = {10.64898/2026.09.18.752821}
}
DOI: 10.64898/2026.09.18.752821
Install
Conda Formula
conda install bioconda::taxutils
Pip Formula
pip install taxutils
from taxutils import backend_info
print(backend_info())
# {'selected': 'rust', 'rust_version': '1.1.2', 'api_version': 8}
Building from a repository checkout or source distribution requires Rust. The
extension resolves taxutils 1.1.2 or newer compatible releases directly from
crates.io; a sibling taxutils-rs checkout is not required.
Setup
taxutils stores downloaded taxonomy files (names.dmp, nodes.dmp), pathogen target metadata, and accession-to-taxon mappings in a global save directory. Set TAXUTILS_GLOBALS before importing the package if you want to control where these files live:
export TAXUTILS_GLOBALS=/path/to/taxutils/saves
If TAXUTILS_GLOBALS is not set, taxutils defaults to ./taxutils/ in the current working directory. It is the only environment variable taxutils reads, and it is only a default: save_folder= overrides it per call. We highly recommend setting this variable so that you maintain a single database across each of your projects.
tu = taxutils(save_folder="/path/to/taxutils/saves")
With low_memory=False, the built TaxonomicUtils object is saved in
taxutils.pkl.gz in the same save folder. Later calls load this compressed
pickle directly, skipping names parsing, rank correction, parent mapping, and
construction of target taxa. Gzip level 1 keeps compression and loading fast.
The cache rebuilds if names.dmp, nodes.dmp, or the selected targets_json
changes (path, size, or modification time), on refresh=True, or if it is
unreadable or incompatible. Raw taxonomy files remain unchanged by caching.
Current constructor options and requested accession lookups are applied on
every call; accession mappings are not stored in the object cache. SQLite and
alternative-mapping preparation still run as needed. low_memory=True does
not read or write this cache. The older cnodes.dmp cache is no longer used
and can be deleted.
Keeping the database current
Anything missing is downloaded and a missing or unusable database is built
automatically, so a first run needs no flags. To pick up new NCBI data, pass
refresh=True: it re-fetches the managed taxonomy files and applies only the
accessions NCBI added, changed or withdrew.
tu = taxutils(low_memory=False, wgs=True, refresh=True)
The compressed NCBI mapping is always retained, because low-memory lookups scan
it directly. If an installation will only ever use the SQLite database, the
.accession2taxid.gz files can simply be deleted to reclaim the space; they are
downloaded again only if a later low-memory lookup needs them.
Core usage
Core functions are listed here. See the example notebook for a fuller walkthrough.
# Build object
tu = taxutils(accessions=None, low_memory=True, targets_json=None, wgs=False, save_folder=None, threads=None, refresh=False, canonical=True) # Build the taxonomy utility object.
# Accession parsing and mapping
tu.parse_accession(header_strings, version=True) # Extract one accession per string.
tu.load_a2t(accessions, low_memory=None, extend=False, wgs=None) # Load accession-to-taxon mappings into tu.a2t.
tu.get_t2a(taxa, low_memory=None, wgs=None) # Return accessions assigned to taxa.
# Tree queries
tu.get_branch(taxon) # Return the root-to-taxon branch.
tu.get_subtree(taxon) # Return taxon plus all descendants.
tu.get_ancestor(taxon, anchor_rank) # Return nearest ancestor at a rank.
tu.is_leaf(taxon_or_taxa) # Test whether taxa have no child nodes.
tu.is_child(taxon_a, taxon_b) # Test whether taxon_a is a direct child of taxon_b.
tu.is_descendent(taxon_a, taxon_b) # Test whether taxon_a is below taxon_b.
tu.get_lca(taxon_a, taxon_b) # Return the lowest common ancestor.
tu.get_distance(taxon_a, taxon_b) # Return tree edge distance through the LCA.
tu.sort_taxa(taxa) # Sort taxa in taxonomic order.
tu.format_tree(taxa) # Return an indented tree Series.
tu.topology(taxon, anchor_rank=None) # Return subtree topology metrics.
tu.topology(taxon, anchor_rank=None, stat="topology_scale") # Return one topology statistic.
# Rank utilities
tu.get_rank_order() # Return canonical rank codes.
tu.higher_than_rank(taxa, rank) # Test whether taxa are higher than a rank.
In taxutils, accessions=list/of/accessions can be passed to call load_a2t on construction of the taxutils object. A custom targets_json can similarly be passed in lieu of the default json explained below. A missing or unusable database is built from scratch automatically; refresh=True re-fetches the managed taxonomy files and updates an existing database in place, applying only the rows that changed upstream. By default, accession lookups use nucl_gb.accession2taxid.gz; pass wgs=True to also download/use nucl_wgs.accession2taxid.gz for WGS/TSA accessions. SQLite mode always uses nucl.accession2taxid.db; if it was built GB-only, a later wgs=True call upgrades the same DB with WGS mappings. load_a2t overwrites tu.a2t by default; pass extend=True to add missing mappings without discarding existing ones. Method-level low_memory=None and wgs=None use the modes set when tu was built. save_folder and threads are recorded on tu and reused by every later lookup. canonical=True (the default) preserves NCBI accession assignments, otherwise, with canonical=False, some accessions, mainly influenza A subtypes, derive taxonomic labels from NCBI's AllNuclMetadata.csv.
parse_accession accepts strings, lists, arrays, and pandas Series. It returns the first accession found from each string using the same container type where possible; missing accessions are returned as "NA".
get_lca(a, b) returns the lowest common ancestor of two taxa. get_distance(a, b) returns the edge distance between two taxa through their lowest common ancestor. Depths are cached lazily as these methods are called.
get_ancestor(taxon, anchor_rank) returns the nearest ancestor at the requested corrected rank. If the input taxon already has that rank, it returns the input taxon; if no ancestor has that rank, it returns the input taxon as a fallback. It accepts a single taxon, list-like input, NumPy arrays, or pandas Series and returns the same container type where possible.
is_leaf(taxon) returns whether a taxon has no child nodes in the taxonomy tree. It accepts a single taxon, list-like input, NumPy arrays, or pandas Series. A single taxon returns a bool; a list-like input returns a list of booleans; a NumPy array returns a boolean array with the original shape; and a pandas Series returns a boolean Series with the original index.
is_child(taxon_a, taxon_b) returns whether taxon_a is a direct child of taxon_b. It uses the parent lookup directly, so each pairwise check is O(1).
is_descendent(taxon_a, taxon_b) returns whether taxon_a is a strict descendant of taxon_b; a taxon is not considered a descendant of itself. The first call builds a cached tree interval index in O(n), and subsequent pairwise checks are O(1).
is_child and is_descendent accept either two scalar taxa or two list-like inputs of the same length. Scalar inputs return a bool; list-like inputs return a list of booleans; NumPy arrays return boolean arrays with the original taxon_a shape; and pandas Series return boolean Series with the original taxon_a index.
topology(taxon, anchor_rank=None, stat=None) returns subtree topology metrics such as taxon count, leaf fraction, depth, branchiness, and topology_scale. Pass anchor_rank="F" to summarize the nearest family-level ancestor. With stat=None, a single taxon returns a Series and a list, array, or Series returns a DataFrame.
Pass stat to return one topology metric. A single taxon returns a scalar; a list, array, or Series returns a Series indexed by taxon.
Topology columns
tu.topology(...) returns these columns:
taxon: input taxon.name: input taxon name.rank_code: corrected rank code for the input taxon.anchor_taxon: subtree root used for the topology summary.anchor_name: anchor taxon name.anchor_rank_code: corrected rank code for the anchor.n_taxa: number of taxa in the anchor subtree.n_leaves: number of terminal taxa in the anchor subtree.max_depth: maximum number of edges below the anchor.mean_depth: average number of edges below the anchor.topology_scale: 95th percentile descendant depth, with minimum value 1.max_children: largest number of direct children from any node in the subtree.branching_taxa_fraction: fraction of subtree taxa with at least one child.top_child_fraction: fraction of the anchor subtree contained in its largest immediate child branch.
tu.target_taxa contains the default pathogen-derived target taxa. Use it directly for target filtering or movement checks.
Rust acceleration
The native backend comes from the
taxutils Rust crate. It accelerates
load_a2t, get_t2a, and the extract, clean, grep, deduplicate, and filter FASTA
commands while preserving the Python APIs and return values. Runtime errors are
not retried through Python, so a failed native file operation cannot be run
twice accidentally. Long native FASTA operations release the GIL and respond to
KeyboardInterrupt between bounded batches; atomic-output commands discard
their temporary output when cancelled.
Editable installs also compile an optimized Rust extension. After updating the
source, rerun python -m pip install -e . to rebuild it; an older debug extension
can make large accession scans substantially slower.
pandas/NumPy-returning taxonomy methods remain implemented in Python and return the same datatype as passed as input.
Rank correction
taxutils keeps the raw NCBI rank in rank and adds corrected rank columns. Canonical ranks (R, D, K, P, C, O, F, G, S) are used as anchors only when they move deeper than the corrected parent rank. Noncanonical ranks such as no rank, clade, and other unusual labels inherit position from the tree. If a child would be ranked at the same or a higher level than its parent, it is assigned a subrank such as S2, S3, or F2. The canonical name for the corrected rank is stored in new_rank.
Target taxa
In ZarLab, we are working on metagenomics in the clinical setting, with the goal of creating an "agnostic diagnostic". We often want to look at broad array of taxa (tu.target_taxa) that could cause harm to people. In June 2024, CZI did the work of compiling a list of pathogenic taxa. I did the easy work of turning this into a json and uploading it to my website, so that it is available and easily accessed for all time (in case that link ever breaks). taxutils will extend the taxa list to include subtrees of each of those pathogenic taxa. It will additionally include SARS-CoV2, since it was excluded from CZI's list. If you find any other obvious, missing pathogens, please send me a note, so I can update my json. You can also update the target_taxa member variable yourself, or store an entirely different set of targets, if you wanted.
Contact
Author: Will O'Brien
Affiliation: Computer Science Department, UCLA
Email: wob@cs.ucla.edu
Metadata
Release files for taxutils 1.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Incomplete provenance
2 of 9 files were uploaded without provenance metadata.
We recommend further investigation before installing these files. View details.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| taxutils-1.1.7.tar.gz | 52.8 kB | Without provenance | Details for taxutils-1.1.7.tar.gz |
Built distributions (wheels)
Total release size: 38.7 MB
Release files / taxutils-1.1.7.tar.gz
Incomplete provenance
This file belongs to a release with incomplete provenance: while other files in this release have provenance metadata, this file does not.
We recommend further investigation before installing this file. View details.
| Download URL | taxutils-1.1.7.tar.gz |
|---|---|
| Size | 52.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e45dad6ab113aa5a0d1c417ffa3372ff71860734fe3280537a1a8dfde2b2be27
|
|
BLAKE2b-256 checksum How to use checksums |
262f8076480d42a1925b35051a066e86b5bd715e5fed29438a2c3e7bb785d254
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.10.20 Linux/6.17.0-1021-nvidia
|
Release files / taxutils-1.1.7-cp310-abi3-win_amd64.whl
Incomplete provenance
This file belongs to a release with incomplete provenance: while this file has provenance metadata, other files in this release do not.
We recommend further investigation before installing this file. View details.
| Download URL | taxutils-1.1.7-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 4.1 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ce05b3e6bc722933f790c7f0ba16982b5627887fb8a879c9467d51aebf474dfc
|
|
BLAKE2b-256 checksum How to use checksums |
f5a4b3bd892a0513cd6c626d4a5d08851c3c78bb40faf3c18481ea6f8bb9c826
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.
Transparency logRelease files / taxutils-1.1.7-cp310-abi3-musllinux_1_2_x86_64.whl
Incomplete provenance
This file belongs to a release with incomplete provenance: while this file has provenance metadata, other files in this release do not.
We recommend further investigation before installing this file. View details.
| Download URL | taxutils-1.1.7-cp310-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 5.4 MB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
a0eec851db43dfa06eb25224a738732c894ade5a5574b17eb32bf14a475b44ed
|
|
BLAKE2b-256 checksum How to use checksums |
0052a8d880fbaf61b92cfada59f702606d969de8c26d94d6de56774cb5b35df8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.
Transparency logRelease files / taxutils-1.1.7-cp310-abi3-musllinux_1_2_aarch64.whl
Incomplete provenance
This file belongs to a release with incomplete provenance: while this file has provenance metadata, other files in this release do not.
We recommend further investigation before installing this file. View details.
| Download URL | taxutils-1.1.7-cp310-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | CPython 3.10 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
b93415811e2472e4a3ace07cfeb48996161d815a124fc2486b907287d6ee02ab
|
|
BLAKE2b-256 checksum How to use checksums |
2f743dafea76f482b11b0cf6891a0194610934de84fa41625c8b26b6cb319980
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.
Transparency logRelease files / taxutils-1.1.7-cp310-abi3-manylinux_2_34_aarch64.whl
Incomplete provenance
This file belongs to a release with incomplete provenance: while other files in this release have provenance metadata, this file does not.
We recommend further investigation before installing this file. View details.
| Download URL | taxutils-1.1.7-cp310-abi3-manylinux_2_34_aarch64.whl |
|---|---|
| Size | 5.0 MB |
| Tags | CPython 3.10 Linux glibc 2.34+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
e853d17bdf74e470a11ed1bc1efb42e7d5db448b2d140adbc3b4dffa7d962927
|
|
BLAKE2b-256 checksum How to use checksums |
fc07468ababf68ee609cdb441fb65d9eb68eca3950b56d55f3ff648ef1aa06ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.10.20 Linux/6.17.0-1021-nvidia
|
Release files / taxutils-1.1.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Incomplete provenance
This file belongs to a release with incomplete provenance: while this file has provenance metadata, other files in this release do not.
We recommend further investigation before installing this file. View details.
| Download URL | taxutils-1.1.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
27bac150c144ca7b7bf2126692bd7ee45f5c448adf932f284e7724623bc2d268
|
|
BLAKE2b-256 checksum How to use checksums |
9b7163cef734d149619f9b21849bda2a1fe2b144ba47d9be964345ab2a229b7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.
Transparency logRelease files / taxutils-1.1.7-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Incomplete provenance
This file belongs to a release with incomplete provenance: while this file has provenance metadata, other files in this release do not.
We recommend further investigation before installing this file. View details.
| Download URL | taxutils-1.1.7-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 5.0 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
0cd15975065d366d4c6d576cb5ffb13fab1438aa33df3310f349692a2baa1a75
|
|
BLAKE2b-256 checksum How to use checksums |
3724b67a084311022e187fb05155e890093269532c004a3ca3340d47a95e0dea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.
Transparency logRelease files / taxutils-1.1.7-cp310-abi3-macosx_11_0_arm64.whl
Incomplete provenance
This file belongs to a release with incomplete provenance: while this file has provenance metadata, other files in this release do not.
We recommend further investigation before installing this file. View details.
| Download URL | taxutils-1.1.7-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f1249bd6162093b3400ca9cebe408cb1612f5ec464c612fa33ed29f42d76bf6c
|
|
BLAKE2b-256 checksum How to use checksums |
b37f947e5fade03545a94e30248f90a4f072f6450fd919887795bd091f82ed2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.
Transparency logRelease files / taxutils-1.1.7-cp310-abi3-macosx_10_12_x86_64.whl
Incomplete provenance
This file belongs to a release with incomplete provenance: while this file has provenance metadata, other files in this release do not.
We recommend further investigation before installing this file. View details.
| Download URL | taxutils-1.1.7-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 4.6 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
0d71b530805bf49e5463f89b3398b8181b29cf59d64d4cef63cf9fc2710c3abf
|
|
BLAKE2b-256 checksum How to use checksums |
ee401cd8caf3384b05436343b0a2c26b21f9c50d796a988bd287640eabccc012
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.
Transparency logSecurity for taxutils 1.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Incomplete provenance
2 of 9 files were uploaded without provenance metadata.
Attestations for taxutils-1.1.7.tar.gz
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.