Skip to main content

PyPI License: MIT Docs

ForestPD logo

ForestPD (Python package forestpd) chooses which taxa to protect so that as much phylogenetic diversity (PD) as possible is preserved across many phylogenetic trees at once. It uses numba for JIT-accelerated computation, and connects to phylozoo for plotting and further analysis.


Key Features

  • Many trees at once: maximize PD summed over a whole collection of trees, such as posterior samples, bootstrap replicates or gene trees, optionally weighted per tree, with no summary tree or network in between.
  • Budgets and extinction risks: assign integer costs to taxa and maximize PD under a budget; optional survival probabilities make the objective the expected PD of the surviving taxa.
  • Whole budget curves: a single run gives the optimum, and optionally an optimal taxon set, for every budget up to the one asked for.
  • Exact, and fast when the trees mostly agree: the running time is exponential only in the size of agreement forests of the clusters shared by all trees, so ForestPD scales to tens of thousands of taxa and thousands of trees.
  • Agreement forests: a fast built-in heuristic, or minimum agreement forests through the optional maffe solver.
  • Rooted and unrooted PD: unrooted by default, rooted with rooted=True.
  • Interoperability: read and write Newick, export the trees as one weighted split system (NEXUS) for split-diversity tools such as PDA, and convert to and from PhyloZoo trees.

Installation

pip install forestpd

Runtime dependencies (numpy, numba) are installed automatically.

For conversion to and from PhyloZoo (e.g. for plotting):

pip install "forestpd[phylozoo]"

For minimum agreement forests with maffe:

pip install "forestpd[maffe]"

Quickstart

Choose the taxa to protect on two trees, then add costs and survival probabilities and solve for several budgets in one run:

import forestpd as fpd

trees = ["(A:1,B:1,(C:1,D:1):2);", "(A:1,C:1,(B:1,D:1):2);"]  # or a file, one Newick tree per line

result = fpd.optimize_maxmpd(trees, budget=2, return_taxa=True)
print(result.value)         # 8.0
print(sorted(result.taxa))  # ['B', 'C']  (['A', 'D'] is optimal too)

# Costs (default 1) and survival probabilities of unprotected taxa (default 0)
instance = fpd.MaxMPDInstance(trees, costs={"A": 2, "C": 3}, survival={"B": 0.5, "D": 0.2})
budgets = [1, 2, 3, 4]
for budget, r in zip(budgets, instance.optimize_many(budgets, return_taxa=True)):
    print(budget, round(r.value, 2), sorted(r.taxa))
# 1 3.0 ['D']
# 2 6.0 ['B', 'D']
# 3 9.0 ['A', 'D']
# 4 10.0 ['A', 'B', 'D']

See the user guide for everything else, including rooted PD, per-tree weights, pruning trees to a taxon set, and the choice of agreement forest.

Documentation

For the full manual, API reference, worked examples, and installation guide, visit the ForestPD docs.

Citation

If you use ForestPD, please cite:

Niels Holtgrefe, Jannik Schestag, and Norbert Zeh. ForestPD: Maximizing Phylogenetic Diversity under Phylogenetic and Extinction Uncertainty. 2026.

Metadata

Release files for forestpd 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for forestpd 0.1.2
File Size Uploaded Provenance Actions
forestpd-0.1.2.tar.gz 181.4 kB With provenance Details for forestpd-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for forestpd 0.1.2
File Interpreter ABI Platform Actions
forestpd-0.1.2-py3-none-any.whl Python 3 none any Details for forestpd-0.1.2-py3-none-any.whl

Total release size: 328.8 kB

Release files / forestpd-0.1.2.tar.gz

Download URL forestpd-0.1.2.tar.gz
Size 181.4 kB
Tags Source
SHA-256 checksum
How to use checksums
784b3ff59322e26cbd300363ff07de4884b3b3d290d596704976870f05880fdf
BLAKE2b-256 checksum
How to use checksums
73a28fc9d7d8772d3e4df90ce81a393e69a3dd075792d30b6ed6e8a8fa298ae8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / forestpd-0.1.2-py3-none-any.whl

Download URL forestpd-0.1.2-py3-none-any.whl
Size 147.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
66f5478f143ac392ca3d1eee90aa1e78b66f5be0a8bb61533de777f42d8ea017
BLAKE2b-256 checksum
How to use checksums
2eb8cdb59029ee9dda9267ab29963b050f0994a95bd46d1ee10e7e3440cc4b34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for forestpd 0.1.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for forestpd-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page