Routines for loading, saving, and manipulating taxonomic trees
Project description
Taxonomy
This is a Rust library for reading, writing, and editing biological taxonomies. There are associated Python bindings for accessing most of the functionality from Python.
This library was developed initially as a component in One Codex's metagenomic classification pipeline before being refactored out, expanded, and open-sourced. It is designed such that it can be used as is with a number of taxonomic formats or the Taxonomy trait it provides can be used to add last common ancestor, traversal, etc. methods to a downstream package's taxonomy implementation.
The library ships with a number of features:
- Common support for taxonomy handling across Rust and Python
- Fast and low(er) memory usage
- NCBI taxonomy, JSON ("tree" and "node_link_data" formats), Newick, and PhyloXML support
- Easily extensible (in Rust) to support other formats and operations
Python Usage
The Python taxonomy API can open and manipulate all of the formats from the Rust library:
from taxonomy import Taxonomy
tax = Taxonomy.from_newick('(A,(B,C)D)E;')
assert tax.parent('A') == 'E'
assert tax.parent('B') == 'D'
If you have the NCBI taxonomy locally (found on their FTP), you can use that too:
ncbi_tax = Taxonomy.from_ncbi('./nodes.dmp', './names.dmp')
assert tax.name('562') == 'Escherichia coli'
assert tax.rank('562') == 'species'
Note that Taxonomy IDs in NCBI format are integers, but they're converted to strings on import. We find working with "string taxonomy IDs" greatly simplifies interoperation between different taxonomy systems.
Installation
Rust
This library can be added to an existing Cargo.toml file and installed straight from crates.io.
Python
You can install the Python bindings directly from PyPI (binaries are only built for select architextures) with:
pip install taxonomy
Development
Rust
There is a test suite runable with cargo test
. To test the Python-bindings you need to use the additional python_test
feature: cargo test --features python_test
.
Python
To work on the Python library on a Mac OS X/Unix system (requires Python 3):
# you need the nightly version of Rust installed
curl https://sh.rustup.rs -sSf | sh
rustup default nightly
# finally, install the library
maturin install --cargo-extra-args="--features=python"
Building binary wheels and pushing to PyPI
# The Mac build requires switching through a few different python versions
maturin build --cargo-extra-args="--features=python" --release --strip
# The linux build is automated through cross-compiling in a docker image
docker run --rm -v $(pwd):/io konstin2/maturin:master build --cargo-extra-args="--features=python" --release --strip
twine upload target/wheels/*
Other Taxonomy Libraries
There are taxonomic toolkits for other programming languages that offer different features and provided some inspiration for this library:
ETE Toolkit (http://etetoolkit.org/) A Python taxonomy library
Taxize (https://ropensci.github.io/taxize-book/) An R toolkit for working with taxonomic data
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 Distributions
Built Distributions
File details
Details for the file taxonomy-0.4.1-cp38-cp38-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: taxonomy-0.4.1-cp38-cp38-macosx_10_7_x86_64.whl
- Upload date:
- Size: 289.6 kB
- Tags: CPython 3.8, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f428e3b6687a3a9d295d2a81d9acccfea796c9c62d6ed05800da6ccf5463b7c0 |
|
MD5 | 77df13e4b20bece35fff6b473b0d703c |
|
BLAKE2b-256 | f617869c56e99b15ba86c23f280d5be0bd5bde4977d8cfc79c7ae9ac9c5a31c7 |
File details
Details for the file taxonomy-0.4.1-cp37-cp37m-manylinux1_x86_64.whl
.
File metadata
- Download URL: taxonomy-0.4.1-cp37-cp37m-manylinux1_x86_64.whl
- Upload date:
- Size: 323.6 kB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6a7cf705a91d5299a078ee71fdbad775eef8a84fd38dde67e2dbe1051b50544 |
|
MD5 | 23e3fe3a12dd951cb0064935ef52bbe8 |
|
BLAKE2b-256 | 5a1abc40191481ce6b87544ff863b69426dd87eae76cb59a342b0a87d27b68ef |
File details
Details for the file taxonomy-0.4.1-cp37-cp37m-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: taxonomy-0.4.1-cp37-cp37m-macosx_10_7_x86_64.whl
- Upload date:
- Size: 289.6 kB
- Tags: CPython 3.7m, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6c3b8021a5646e18562137d100da75b12008a4e55437074d4d7cd04e90e8aa4 |
|
MD5 | 45fed5672a25c8d9d349379af8f29465 |
|
BLAKE2b-256 | d165ba7f1e370d8ecfdefe91d78f7c714a3290cf7594f65b044c3033a2d6636e |
File details
Details for the file taxonomy-0.4.1-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: taxonomy-0.4.1-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 323.9 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b85dc14b08e5b11353c48d81f6b24e48fdd2dbf98a51892e210545749bf2d07 |
|
MD5 | 8145400e132040a89020210d5fc3663a |
|
BLAKE2b-256 | 398cafd4fa9c2615a8421f7cb9d98803d44998a5d11745b68065ad29d611e7a9 |
File details
Details for the file taxonomy-0.4.1-cp36-cp36m-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: taxonomy-0.4.1-cp36-cp36m-macosx_10_7_x86_64.whl
- Upload date:
- Size: 289.7 kB
- Tags: CPython 3.6m, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 895150ca64f736ff4e7ce44a8bd89f3d15047a1b985c1ad1b2005488c27fd7a4 |
|
MD5 | d9e10cde6417960ab6a858861dd16498 |
|
BLAKE2b-256 | bb312b6ae4c99c35042ca3b9a0fa9cd5e865740144bf96ed3265ebed0a3b3d82 |
File details
Details for the file taxonomy-0.4.1-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: taxonomy-0.4.1-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 323.8 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bb825951e0c83a158ef7d04b51d8457d88004d8e679240c48cb4a46c174769f |
|
MD5 | 37ddc5d04fa696f7f244ae2b3b144d8d |
|
BLAKE2b-256 | 6737b2cf79babf9fdb12d3aa3e7a27b7cdd0c28b9078c84b91bba6457c5ddd1c |
File details
Details for the file taxonomy-0.4.1-cp35-cp35m-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: taxonomy-0.4.1-cp35-cp35m-macosx_10_7_x86_64.whl
- Upload date:
- Size: 289.7 kB
- Tags: CPython 3.5m, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb4fafdf081983ff954e270d3b60c254494b157a58dd63aabdd59065f8a897bb |
|
MD5 | 9e272ba5294eeb898f22e63a64aae892 |
|
BLAKE2b-256 | fb8c842f552fe6a0d21cec4464b9b1f2fb37185cea6b8b59f9d1c1b8f5781b26 |