TaxonTools
TaxonTools can help you use NCBI Taxonomy database
Installation
pip install taxontools
Usage
StoreTaxonDB: convert NCBI Taxonomy database to sqlite format
usage: TaxonTools StoreTaxonDB [-h] taxdump_tar_gz_file taxdump_db_file
positional arguments:
taxdump_tar_gz_file Path for taxdump.tar.gz file
taxdump_db_file Path for sqlite3 file
optional arguments:
-h, --help show this help message and exit
ID2Lineage: extract taxonomy information and lineage information from NCBI Taxonomy database by taxon ID
usage: TaxonTools ID2Lineage [-h] [-l TAXON_ID_LIST] [-o OUTPUT_FILE] taxdump_db_file
positional arguments:
taxdump_db_file Path for taxdump_db_file from StoreTaxonDB
optional arguments:
-h, --help show this help message and exit
-l TAXON_ID_LIST, --taxon_id_list TAXON_ID_LIST
query taxon ID, you can give me a file path or taxon IDs separate by comma
-o OUTPUT_FILE, --output_file OUTPUT_FILE
Output file name (default as $STDOUT)
Name2Lineage: extract taxonomy information and lineage information from NCBI Taxonomy database by taxon Name
usage: TaxonTools Name2Lineage [-h] [-l TAXON_NAME_LIST] [-o OUTPUT_FILE] taxdump_db_file
positional arguments:
taxdump_db_file Path for taxdump_db_file from StoreTaxonDB
optional arguments:
-h, --help show this help message and exit
-l TAXON_NAME_LIST, --taxon_name_list TAXON_NAME_LIST
query taxon Name, you can give me a file path or taxon names separate by comma
-o OUTPUT_FILE, --output_file OUTPUT_FILE
Output file name (default as $STDOUT)
Example
- Download NCBI Taxonomy database
wget ftp://ftp.ncbi.nlm.nih.gov/pub/taxonomy/taxdump.tar.gz
- Convert NCBI Taxonomy database to sqlite format
TaxonTools StoreTaxonDB taxdump.tar.gz taxdump.db
- Extract taxonomy information and lineage information from NCBI Taxonomy database by taxon ID
# query taxon ID 9606,10090,10116
TaxonTools ID2Lineage -l 9606,10090,10116 -o taxon_lineage.txt taxdump.db
# query taxon ID from file
TaxonTools ID2Lineage -l taxon_id_list.txt -o taxon_lineage.txt taxdump.db
- Extract taxonomy information and lineage information from NCBI Taxonomy database by taxon Name
# query taxon ID Arabidopsis thaliana, Mus musculus, Rattus norvegicus
TaxonTools Name2Lineage -l "Arabidopsis\ thaliana,Mus\ musculus,Rattus\ norvegicus" -o taxon_lineage.txt taxdump.db
# query taxon ID from file
TaxonTools Name2Lineage -l taxon_name_list.txt -o taxon_lineage.txt taxdump.db
- Use in python
- convert NCBI taxonomy database to sqlite3 file
from taxontools import build_taxon_database, store_taxon_record_into_sqlite
taxon_record_dict = build_taxon_database(taxdump_tar_gz_file)
store_taxon_record_into_sqlite(taxon_record_dict, taxdump_db_file)
- extract taxon record by taxon ID
from taxontools import read_taxon_record_dict_db
tax_id = '3702'
taxon_dict = read_taxon_record_dict_db(
taxdump_db_file, tax_id_list=[tax_id])
vars(taxon_dict[tax_id])
- extract taxon record by taxon name
from taxontools import read_taxon_name_record_dict_db
tax_name = 'Arabidopsis thaliana'
taxon_dict = read_taxon_name_record_dict_db(
taxdump_db_file, tax_name_list=[tax_name])
vars(taxon_dict[tax_name])
- get MRCA of a taxon list and common tree
from taxontools import get_MRCA_taxon_id
tax_id_list = ['3702', '4128']
taxon_dict = read_taxon_record_dict_db(
taxdump_db_file, tax_id_list=tax_id_list)
MRCA_id = get_MRCA_taxon_id([taxon_dict[i] for i in taxon_dict])
print(read_taxon_record_dict_db(
taxdump_db_file, tax_id_list=[MRCA_id])[MRCA_id])
- get common tree
from taxontools import get_common_tree
from Bio import Phylo
tax_id_list = ['3702', '4128', '4081']
common_tree = get_common_tree(tax_id_list, taxdump_db_file)
Phylo.draw_ascii(common_tree)
Metadata
Release files for taxontools 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| taxontools-0.3.2.tar.gz | 75.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| taxontools-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 151.4 kB
Release files / taxontools-0.3.2.tar.gz
| Download URL | taxontools-0.3.2.tar.gz |
|---|---|
| Size | 75.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c366d3a12ec57c4904bff85ea09512635e03a599a0a6f0e9010fae61c35a4433
|
|
BLAKE2b-256 checksum How to use checksums |
13681a37f37e28634f4c701d5be1c8668ff41b46937ce7cd337ba2ae07c28448
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.7
|
Release files / taxontools-0.3.2-py3-none-any.whl
| Download URL | taxontools-0.3.2-py3-none-any.whl |
|---|---|
| Size | 76.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7168581f3a77f7f16818e8cb0048934e21bd3b5015f546e3c57f45e45216a135
|
|
BLAKE2b-256 checksum How to use checksums |
c1aa4dc22b8b051d9c7b880233367efdf50eb8def629c33bc95631538303e8a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.7
|
Security for taxontools 0.3.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.