Skip to main content

A library for tree data structures and algorithms

Project description

tralda

License: MIT pypi version Python PyPI downloads DOI

A Python library for tree algorithms and data structures.

Installation and usage

The package requires Python 3.10 or higher. The tralda package is available on PyPI:

pip install tralda

See also the page Installation in the documentation.

The tralda documentation contains a user guide with example code as well as the API reference.

If you want to contribute to the project, please see the contributing guidelines. Please report any bugs and questions in the Issues section.

Overview

tralda provides a collection of efficient algorithms and data structures centered around rooted trees, with a focus on phylogenetics and combinatorial algorithms. It is designed to serve as a building block for research software in computational biology and related fields.

Tree data structure — The Tree and TreeNode classes in tralda.datastructures offer a flexible rooted-tree representation with support for traversals (preorder, postorder, level-order), subtree operations, tree generation, and utilities such as topology comparison and hierarchy extraction.

Lowest common ancestor (LCA) — An $O(n)$-time/space preprocessing structure for $O(1)$ LCA queries, based on the algorithm by Bender et al. (2005). Available as LCA in tralda.datastructures.

Supertree computation — The tralda.supertree subpackage implements several algorithms for constructing supertrees and consensus trees from a set of (partial) input trees:

  • BUILD (Aho et al. 1981) — classic triple-based supertree construction.
  • BuildST (Deng & Fernández-Baca 2016) — fast compatibility testing and supertree construction for rooted phylogenetic trees.
  • LinCR (Schaller et al. 2021) — linear-time algorithm for the minimal common refinement of rooted phylogenetic trees on a common leaf set.
  • Loose consensus tree (Jansson et al. 2016) — linear-time construction of the loose consensus tree for trees with the same leaf set.

Balanced binary search treestralda.datastructures.bst provides AVL trees and red-black trees (ordered sets and dictionaries) with $O(\log n)$ insertion, deletion, and lookup, as well as efficient split and join operations.

Dynamic graph connectivity — The HDTGraph class in tralda.datastructures.hdtgraph implements the poly-logarithmic dynamic graph structure described by Holm et al. (2001), supporting edge insertions and deletions with $O(\log^2 n)$ amortized cost while answering connectivity queries in $O(\log n)$.

Cograph detection and editingtralda.cograph offers linear-time cograph recognition (Corneil et al. 1985) with cotree construction, as well as a heuristic for cograph editing (Crespelle 2021) that modifies a graph with a near-minimum number of edge insertions/deletions to make it a cograph.

Citation and references

If you use tralda in your project or code from it, please consider citing:

Schaller, D., Hellmuth, M., Stadler, P.F. (2021) A simpler linear-time algorithm for the common refinement of rooted phylogenetic trees on a common leaf set. Algorithms for Molecular Biology 16, 23 (2021). https://doi.org/10.1186/s13015-021-00202-8

Additional references to algorithms that were implemented are given in the source code.

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

tralda-2.0.2.tar.gz (66.9 kB view details)

Uploaded Source

Built Distribution

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

tralda-2.0.2-py3-none-any.whl (77.9 kB view details)

Uploaded Python 3

File details

Details for the file tralda-2.0.2.tar.gz.

File metadata

  • Download URL: tralda-2.0.2.tar.gz
  • Upload date:
  • Size: 66.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tralda-2.0.2.tar.gz
Algorithm Hash digest
SHA256 780b495c66b9e432b21e1d779f8768002033521f9e969c6cc3b5a11cd2b5edb5
MD5 54b1cc1517ae2300ae3445bcc945511e
BLAKE2b-256 700908e2192a2654e31697d86c755237f7d424d7f8140431e66c4ebfcc6c887d

See more details on using hashes here.

Provenance

The following attestation bundles were made for tralda-2.0.2.tar.gz:

Publisher: publish.yml on david-schaller/tralda

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tralda-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: tralda-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 77.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tralda-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e87053fc3a908340831a5571df125ebeef70ca85b37d8b6a1d5da6648886d068
MD5 ec232f1970d50d16e2485c93e16de73f
BLAKE2b-256 131f53db121a783fab8ff69792c3049df39bd7addc212334e6e670019eac081e

See more details on using hashes here.

Provenance

The following attestation bundles were made for tralda-2.0.2-py3-none-any.whl:

Publisher: publish.yml on david-schaller/tralda

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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