bkbit.utils.ncbi_taxonomy_data.build_subset module

Rebuilds the NCBI taxonomy subset that is bundled inside the bkbit wheel.

The full NCBI taxonomy (~2.6M taxa, ~230MB of JSON) is far too large to ship on PyPI, but bkbit only ever needs a scientific name, a common name, and a taxon id for the organism a GFF3 file belongs to. Every taxon that carries a GenBank common name (~30k of them, which covers every organism anyone realistically runs an annotation pipeline for) fits in well under 1MB gzipped, so that subset is bundled and used as the fast, offline path. Anything outside the subset falls back to the full download managed by bkbit.utils.ncbi_taxonomy_cache.

Usage (maintainers only, not part of the runtime path):

bkbit download-ncbi-taxonomy # build the full cache first python -m bkbit.utils.ncbi_taxonomy_data.build_subset

Commit the regenerated taxonomy_subset.json.gz alongside any release that should pick up a newer taxonomy dump.

bkbit.utils.ncbi_taxonomy_data.build_subset.build_subset(cache_dir: Path | None = None, output_path: Path | None = None) Path[source]

Builds the bundled subset from a fully downloaded taxonomy cache.

Parameters:
  • cache_dir – Directory holding the full taxonomy cache. Defaults to the cache directory bkbit.utils.ncbi_taxonomy_cache resolves to.

  • output_path – Where to write the gzipped subset. Defaults to the bundled location inside this package.

Returns:

The path the subset was written to.

Return type:

Path