Registry / data / treeswift

treeswift

JSON →
library1.1.45pypypi✓ verified 86d ago

TreeSwift is a fast tree manipulation library for Python 2 and 3, providing a simple interface for reading, writing, and analyzing phylogenetic trees. The current version is 1.1.45, with regular updates and bug fixes.

pip install treeswift
INSTALL
IMPORT
SIG · TREESWIFT
T
treeswift
datapythonv1.1.45
Install
1.6s avg
Import
10ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.45 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.010s · 18MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.008s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Tree
from treeswift import Tree
from treeswift import read_tree
read_tree is a function; Tree is the class.
Node
from treeswift import Node
from treeswift.tree import Node
Node is exported from treeswift directly.

Initialize a tree, read a Newick string, print the tree, and compute the distance between two leaves.

from treeswift import Tree tree = Tree() tree.read('((A:0.1,B:0.2):0.3,C:0.4);') print(tree) # Newick string dist = tree.distance_between('A', 'C') print(dist) # 0.8
Debug
Known issues
gotcha`extract_tree_with` and `extract_tree_without` convert string input to a set of individual characters. If you pass a single string like 'ABC', it will be treated as {'A','B','C'} rather than preserving the string as a single label. Pass a set or list instead.
fix
Use `extract_tree_with(set(['ABC']))` or `extract_tree_with(['ABC'])` to keep the label intact.
affects: <=1.1.41
deprecated`Tree.read` can read gzip files directly, but file extension handling may be simplified in future versions.
fix
Pass an open file handle or a path; gzip is detected internally.
affects: all
gotcha`distance_between` may return incorrect values when one node is an ancestor of the other in versions prior to 1.1.39. Ensure you have the latest version.
fix
Upgrade to >=1.1.39: `pip install --upgrade treeswift`.
affects: <1.1.39
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'treeswift'
Library not installed or installed in a different environment.
fix
Run `pip install treeswift` in the correct Python environment.
TypeError: extract_tree_with() argument after * must be an iterable, not str
Passing a string directly to `extract_tree_with` where an iterable of labels is expected.
fix
Wrap the string in a list: `tree.extract_tree_with(['label'])` instead of `tree.extract_tree_with('label')`.
Upgrade
Version history
1.1.45latest on PyPI · released Nov 19, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
26 hits · last 30 days
node
24
OpenAI (training)
1
Resources
treeswift — pip install treeswift · libregistry