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 (Windows and Linux, for macOS, see the installation guide):
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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| forestpd-0.1.1.tar.gz | 181.6 kB | With provenance | Details for forestpd-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| forestpd-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for forestpd-0.1.1-py3-none-any.whl |
Total release size: 329.0 kB
Release files / forestpd-0.1.1.tar.gz
| Download URL | forestpd-0.1.1.tar.gz |
|---|---|
| Size | 181.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c78a5c2ad7b0224d92a937cf86d053e6e1a041baa5323529fd7059b24ec3fdd
|
|
BLAKE2b-256 checksum How to use checksums |
81b1bc185870dc05e5fa9bd9ab2ef79a4aa6af21cb65e64065e89dd172a4aa85
|
| 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 1, 2026.
Transparency logRelease files / forestpd-0.1.1-py3-none-any.whl
| Download URL | forestpd-0.1.1-py3-none-any.whl |
|---|---|
| Size | 147.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
76c22ca4e96026f09730a9cf119f1250d606e938359922a45132b7ced94079bd
|
|
BLAKE2b-256 checksum How to use checksums |
d57d5bfb2a7ad1425f3dd311d84f277125a6603aa00a37573a90b56cc9161677
|
| 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 1, 2026.
Transparency logSecurity for forestpd 0.1.1
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.
Attestation for forestpd-0.1.1.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 1, 2026.
Transparency logA 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.