Skip to main content

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:

  1. Explicit constructor arguments (or AppConfig fields)
  2. Environment variables
  3. 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_DIR
  • GET_TAX_INFO_DB
  • GET_TAX_INFO_BUSCO_JSON
  • GET_TAX_INFO_BUSCO_DOWNLOADS
  • GET_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

get_tax_info-0.2.2.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

get_tax_info-0.2.2-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

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

Hashes for get_tax_info-0.2.2.tar.gz
Algorithm Hash digest
SHA256 3dbab276819bfcf4cba68611d46e3fd55630a9ed82166e379aaebc3cf6a543ae
MD5 246943e3b66da72a03a11f6cb967840a
BLAKE2b-256 c195d1189606cc7705aaf814db80d0a5549d1fde3eb85161bc2b6b11f1d5c459

See more details on using hashes here.

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

Hashes for get_tax_info-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6aa433649ed9839f615a02804d1079dc250c645292432639404c7af547257af1
MD5 bd7ab91d870e39c58a7bfa0694392c65
BLAKE2b-256 3711b20dba6a1aee47f49597dc17fca978b15b7bae38fea8c36749bbfe9e9d73

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page