Convert NCBI TaxIDs to scientific species names and vice-versa
Project description
get-tax-info
Load NCBI taxonomy (names.dmp and nodes.dmp) into a SQLite database for lightning-fast hash-based lookups.
[!CAUTION] A very similar solution was created by ete4 / ncbiquery.py - I suppose most people should use that implementation instead.
Features
- Fast: Indexed SQLite queries for names, parents, and children.
- Automatic: Downloads and converts NCBI data on first run.
- Easy Storage: Uses standard user cache directories by default.
- BUSCO Integration: Maps TaxIDs to the best BUSCO dataset for lineage analysis.
Installation
pip install get-tax-info
Configuration
Path resolution uses this precedence:
- Explicit constructor arguments (or
AppConfigfields) - Environment variables
platformdirs.user_cache_dir("get-tax-info")defaults
Default cache locations (Linux example):
- DB:
~/.cache/get-tax-info/taxdump.db - BUSCO json:
~/.cache/get-tax-info/busco_datasets.json
Supported environment variables:
GET_TAX_INFO_CACHE_DIRGET_TAX_INFO_DBGET_TAX_INFO_BUSCO_JSONGET_TAX_INFO_BUSCO_DOWNLOADSGET_TAX_INFO_TAXDUMP_TAR
Legacy fallback still supported for BUSCO downloads:
BUSCO_DOWNLOAD_PATH
Programmatic config for embedded usage:
from get_tax_info import AppConfig, GetTaxInfo, GetBusco
cfg = AppConfig.from_sources(
cache_dir="/data/get-tax-info",
busco_download_path="/data/busco_downloads",
)
gti = GetTaxInfo(config=cfg)
gb = GetBusco(config=cfg)
Python Usage
from get_tax_info import GetTaxInfo, TaxID
# Automatically download/init data on first use
gti = GetTaxInfo()
# Use the TaxID object (recommended)
t = gti.get_taxid_object(2590146) # Ektaphelenchus kanzakii
print(t.scientific_name, t.rank) # 'Ektaphelenchus kanzakii', 'species'
# Parents and children
parent = t.parent # <TaxID 483517 (Ektaphelenchus)>
children = parent.children # List of TaxID objects
# Ancestor at specific rank
genus = t.tax_at_rank('genus')
CLI Usage
# Print effective resolved paths (useful in Docker/CI debugging)
get-tax-info show-config
# Get BUSCO dataset for a TaxID
get-tax-info taxid-to-busco-dataset --taxid 110
# Override cache/json paths explicitly (CLI args > env vars > defaults)
get-tax-info taxid-to-busco-dataset \
--taxid 1597 \
--cache_dir /data/get-tax-info \
--busco_json_path /data/get-tax-info/busco_datasets.json \
--busco_download_path /data/busco_downloads
# Add TaxID and BUSCO column to a CSV/TSV table
get-tax-info add-taxid-column table.tsv --sep ,
A complete demonstration of the BUSCO workflow (including Podman usage) can be found in demo_busco_workflow.sh.
Note: BUSCO dataset mapping requires pre-downloaded lineages. See get_busco.py for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file get_tax_info-0.2.2.tar.gz.
File metadata
- Download URL: get_tax_info-0.2.2.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3dbab276819bfcf4cba68611d46e3fd55630a9ed82166e379aaebc3cf6a543ae
|
|
| MD5 |
246943e3b66da72a03a11f6cb967840a
|
|
| BLAKE2b-256 |
c195d1189606cc7705aaf814db80d0a5549d1fde3eb85161bc2b6b11f1d5c459
|
File details
Details for the file get_tax_info-0.2.2-py3-none-any.whl.
File metadata
- Download URL: get_tax_info-0.2.2-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6aa433649ed9839f615a02804d1079dc250c645292432639404c7af547257af1
|
|
| MD5 |
bd7ab91d870e39c58a7bfa0694392c65
|
|
| BLAKE2b-256 |
3711b20dba6a1aee47f49597dc17fca978b15b7bae38fea8c36749bbfe9e9d73
|