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), or for development:

pip install "forestpd[phylozoo]"   # PhyloZoo conversion
pip install "forestpd[dev]"        # testing

Minimum agreement forests need maffe, which is built from source; see the installation guide.

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.0

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.0
File Size Uploaded Provenance Actions
forestpd-0.1.0.tar.gz 181.4 kB With provenance Details for forestpd-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 328.8 kB

Release files / forestpd-0.1.0.tar.gz

Download URL forestpd-0.1.0.tar.gz
Size 181.4 kB
Tags Source
SHA-256 checksum
How to use checksums
94ad8bd8fbbb7a2ad42329ae40d9812ad03870ad2a5e9df09111896fc8f07d8b
BLAKE2b-256 checksum
How to use checksums
95d6e22a8dcca50f598eac501318d1b3e7be764d82b9d0bb61a2492ad2dae3f9
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 Oct 31, 2026.

Transparency log

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

Download URL forestpd-0.1.0-py3-none-any.whl
Size 147.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1858fbb7c950276b62e11cf54568bd084132313e4eb3807b35c7db93320fa50
BLAKE2b-256 checksum
How to use checksums
07dc6dd7b36e7ab5051615642c0b41893b24e701cf2abc57a033d5293b892fd6
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 Oct 31, 2026.

Transparency log

Security for forestpd 0.1.0

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for forestpd-0.1.0.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 Oct 31, 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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