Metadata-Version: 2.4
Name: piqtree
Version: 0.8.1
Summary: Python bindings for IQTree
Author: Gavin Huttley, Robert McArthur, Bui Quang Minh , Richard Morris, Thomas Wong
License-Expression: GPL-2.0-only
Project-URL: Repository, https://github.com/cogent3/piqtree
Project-URL: Documentation, https://piqtree.readthedocs.io
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Natural Language :: English
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: citeable>=2026.3.11b0
Requires-Dist: cogent3>=2026.3.10a0
Requires-Dist: pyyaml
Requires-Dist: requests
Provides-Extra: dev
Requires-Dist: cibuildwheel==3.4.0; extra == "dev"
Requires-Dist: pybind11==3.0.2; extra == "dev"
Requires-Dist: delvewheel==1.12.0; extra == "dev"
Requires-Dist: scriv; extra == "dev"
Requires-Dist: piqtree[test]; extra == "dev"
Requires-Dist: piqtree[lint]; extra == "dev"
Requires-Dist: piqtree[typing]; extra == "dev"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: pytest-markdown-docs; extra == "test"
Requires-Dist: pytest-mock; extra == "test"
Requires-Dist: nox; extra == "test"
Provides-Extra: lint
Requires-Dist: ruff==0.15.5; extra == "lint"
Provides-Extra: typing
Requires-Dist: mypy==1.19.1; extra == "typing"
Requires-Dist: piqtree[stubs]; extra == "typing"
Requires-Dist: piqtree[test]; extra == "typing"
Provides-Extra: stubs
Requires-Dist: types-PyYAML; extra == "stubs"
Requires-Dist: types-requests; extra == "stubs"
Provides-Extra: extra
Requires-Dist: cogent3[extra]; extra == "extra"
Provides-Extra: doc
Requires-Dist: mkdocs; extra == "doc"
Requires-Dist: mkdocstrings[python]; extra == "doc"
Requires-Dist: mkdocs-jupyter; extra == "doc"
Requires-Dist: pymdown-extensions; extra == "doc"
Requires-Dist: jupytext; extra == "doc"
Requires-Dist: piqtree[test]; extra == "doc"
Requires-Dist: cogent3[extra]; extra == "doc"
Requires-Dist: diverse-seq>=2025.7.10; extra == "doc"
Requires-Dist: jupyter; extra == "doc"
Requires-Dist: ipywidgets; extra == "doc"
Dynamic: license-file

# piqtree

[![PyPI Version](https://img.shields.io/pypi/v/piqtree)](https://pypi.org/project/piqtree/)
[![Python Version](https://img.shields.io/pypi/pyversions/piqtree)](https://pypi.org/project/piqtree/)
[![License](https://img.shields.io/github/license/iqtree/piqtree)](https://github.com/iqtree/piqtree/blob/main/LICENSE)

[![CI](https://github.com/iqtree/piqtree/workflows/CI/badge.svg)](https://github.com/iqtree/piqtree/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/github/iqtree/piqtree/badge.svg?branch=main)](https://coveralls.io/github/iqtree/piqtree?branch=main)
[![Documentation Status](https://readthedocs.org/projects/piqtree/badge/?version=latest)](https://piqtree.readthedocs.io/en/latest/?badge=latest)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

`piqtree` (pronounced 'pie-cue-tree') is a library which allows you to use IQ-TREE directly from Python! The interface with Python is through [cogent3](https://cogent3.org) objects.
For usage, please refer to the [documentation](https://piqtree.readthedocs.io/) or the examples below.

If you encounter any problems or have any feature requests feel free to raise an [issue](https://github.com/iqtree/piqtree/issues)!

## Contributing

If you would like to help out by contributing to the piqtree project, please check out our [contributor guide](https://piqtree.readthedocs.io/en/latest/developers/)!

## Examples

### Phylogenetic Reconstruction

```python
from piqtree import build_tree
from cogent3 import load_aligned_seqs # Included with piqtree!

# Load Sequences
aln = load_aligned_seqs("tests/data/example.fasta", moltype="dna")
aln = aln.take_seqs(["Human", "Chimpanzee", "Rhesus", "Mouse"])

# Reconstruct a phylogenetic tree with IQ-TREE!
tree = build_tree(aln, "JC", rand_seed=1) # Optionally specify a random seed.

print("Tree topology:", tree) # A cogent3 tree object
print("Log-likelihood:", tree.params["lnL"])
# In a Jupyter notebook, try tree.get_figure() to see a dendrogram
```

> **Note**
> See the [cogent3 docs](https://cogent3.org) for examples on what you can do with cogent3 trees.

### Fit Branch Lengths to Tree Topology

```python
from piqtree import fit_tree
from cogent3 import load_aligned_seqs, make_tree

# Load Sequences
aln = load_aligned_seqs("tests/data/example.fasta", moltype="dna")
aln = aln.take_seqs(["Human", "Chimpanzee", "Rhesus", "Mouse"])

# Construct tree topology
tree = make_tree("(Human, Chimpanzee, (Rhesus, Mouse));")

# Fit branch lengths with IQ-TREE!
tree = fit_tree(aln, tree, "JC")

print("Tree with branch lengths:", tree)
print("Log-likelihood:", tree.params["lnL"])
```

## More

For more examples ranging from using ModelFinder and AliSim, to making rapid neighbour-joining trees, or randomly generated trees be sure to check out the [documentation](https://piqtree.readthedocs.io/)!

## Citation

Please cite

```bibtex
@article{10.1093/molbev/msag061,
  author    = {McArthur, Robert Neil and Wong, Thomas King-Fung and Lang, Yapeng and Morris, Richard Andrew and Caley, Katherine and Mallawaarachchi, Vijini and Minh, Bui Quang and Huttley, Gavin},
  title     = {piqtree: A Python Package for Seamless Phylogenetic Inference with IQ-TREE},
  journal   = {Molecular Biology and Evolution},
  year      = {2026},
  pages     = {msag061},
  doi       = {10.1093/molbev/msag061},
  url       = {https://doi.org/10.1093/molbev/msag061},
}
```
