Skip to main content

Python bindings for IQTree

Project description

piqtree2

PyPI Version Python Version License

CI Coverage Status

piqtree2 is a library which allows you use IQ-TREE directly from Python! The interface with python is through cogent3 objects, as shown below.

Note

This project is still in early development, if you encounter any problems or have any feature requests feel free to raise an issue!

Examples

Phylogenetic Reconstruction

from piqtree2 import build_tree
from piqtree2.model import DnaModel, Model
from cogent3 import load_aligned_seqs # Included with piqtree2!

# 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, Model(DnaModel.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 for examples on what you can do with cogent3 trees.

Fit Branch Lengths to Tree Topology

from piqtree2 import fit_tree
from piqtree2.model import DnaModel, Model
from cogent3 import load_aligned_seqs, make_tree # Included with piqtree2!

# 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, Model(DnaModel.JC), rand_seed=1) # Optionally specify a random seed.

print("Tree with branch lengths:", tree) # A cogent3 tree object
print("Log-likelihood:", tree.params["lnL"])

Create a Collection of Random Trees

from piqtree2 import TreeGenMode, random_trees

num_taxa = 5
num_trees = 3 

# Also supports YULE_HARDING, CATERPILLAR, BALANCED, BIRTH_DEATH and STAR_TREE
tree_gen_mode = TreeGenMode.UNIFORM 

# Randomly generate trees
trees = random_trees(num_taxa, tree_gen_mode, num_trees, rand_seed=1) # Optionally specify a random seed.

print(trees) # A tuple of 3 trees with 5 taxa each.

Pairwise Robinson-Foulds Distance between Trees

from piqtree2 import robinson_foulds
from cogent3 import make_tree # Included with piqtree2!

# Construct trees
tree1 = make_tree("(a,b,(c,(d,e)));")
tree2 = make_tree("(e,b,(c,(d,a)));")
tree3 = make_tree("(a,b,(d,(c,e)));")

# Calculate pairwise distances
pairwise_distances = robinson_foulds(tree1, tree2, tree3) # Supports any number of trees (for a sequence of trees use *seq_of_trees)

print(pairwise_distances) # A numpy array containing pairwaise Robinson-Foulds distances between trees

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

piqtree2-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (49.5 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

piqtree2-0.3.1-cp312-cp312-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

piqtree2-0.3.1-cp312-cp312-macosx_10_9_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

piqtree2-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (49.5 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

piqtree2-0.3.1-cp311-cp311-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

piqtree2-0.3.1-cp311-cp311-macosx_10_9_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

piqtree2-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (49.5 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

piqtree2-0.3.1-cp310-cp310-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

piqtree2-0.3.1-cp310-cp310-macosx_10_9_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

piqtree2-0.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (49.5 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

piqtree2-0.3.1-cp39-cp39-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

piqtree2-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

Details for the file piqtree2-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for piqtree2-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2aba333ae5fdd65b6a44d4449aca2c5c8d17bc0860971ac15f5524ccb91ede76
MD5 353e6584aef2ff6b8068abe386a91316
BLAKE2b-256 6d3284071df3b84b28ec96366fcfe221875616ebdc7fb7bb0f85ed4d406f1b44

See more details on using hashes here.

File details

Details for the file piqtree2-0.3.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for piqtree2-0.3.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4c1ab2f5520896ddb4447db0abb16a02d16c779e44ce6e635a9ad03594f7ac61
MD5 900bd962b229856741f613a71c8d4a7c
BLAKE2b-256 806b8845cf160268ea404632437039ed3c138a77aaba53fcc079e9cc5ba3931e

See more details on using hashes here.

File details

Details for the file piqtree2-0.3.1-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for piqtree2-0.3.1-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f71b899a58192adf01b68fcbe1c1774aaae56130ded43820c102fdd843645fa0
MD5 4e69af78abda371fbe529046779e24d5
BLAKE2b-256 7f31580833b453a787135d9e73c27714f9a182e081de8114944ffc9c90423dcd

See more details on using hashes here.

File details

Details for the file piqtree2-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for piqtree2-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4e7940574604d33db3ac2f829b63a44d382ce1657b71afc9ff4f7b9ce97f5a8e
MD5 f70e53d80062f074f81856a700bd8c79
BLAKE2b-256 6410aabb3cdf78d18f1660a9fe1878603649bd27358786662bf214332b205a4e

See more details on using hashes here.

File details

Details for the file piqtree2-0.3.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for piqtree2-0.3.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fc83ca908c1b9d552c2dc4f7e37f9db159e75c51b2ed0a70b29c16a0b7023650
MD5 863a57a6eff048ffd09dd1f47d848afa
BLAKE2b-256 1100f55759fd61c5d7e7237e33ae2143ee338f55f4ca51d2b954c481d6dcab1d

See more details on using hashes here.

File details

Details for the file piqtree2-0.3.1-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for piqtree2-0.3.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8163441e2d804dbf38e68b5e8ff7628b05af305bb2769ab46824e01a03d9bb02
MD5 054c88ce8e11235dac710fea762a58ae
BLAKE2b-256 e5de3317f2c2954f0d704743466ec788ad231b684740fdc7828ea89f60251863

See more details on using hashes here.

File details

Details for the file piqtree2-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for piqtree2-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aaa2f63b554b1dc732d5149d95ad206a8ccf127101e58ae47d260a685216c70f
MD5 b0302aa0dd5ee08dc69f2d73e4ab9e60
BLAKE2b-256 4044251b00cfabd56ba6eb50724ce9a73c9db0f03efbcab54f7159bba49c9ae1

See more details on using hashes here.

File details

Details for the file piqtree2-0.3.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for piqtree2-0.3.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 55ba50cf538d9a1cc0c6f5ebeb8e6dc8e6c7198c7c1bfac8d867699bca7f8242
MD5 2764be1b15b4e8331edbdb7f9e77cc03
BLAKE2b-256 9229b9ad1b7b9e042bd76f1221ed630aaf1d7cf28f670c3a98bde48207e1c9ce

See more details on using hashes here.

File details

Details for the file piqtree2-0.3.1-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for piqtree2-0.3.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 067d86531bdc3950ba570aacb31ba1067c36b4b46380cc573da87eb6069267c5
MD5 1f157e6235e8d18021b24779e2779804
BLAKE2b-256 81463c2fce72febac199b30f0de463c435c5007ba9d2c88cbf9686dbb36e7ebd

See more details on using hashes here.

File details

Details for the file piqtree2-0.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for piqtree2-0.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7d54673af202ba70556113e443b4cfe71fe0af38e336a69719f91bbabb34d3ee
MD5 bb7f6eb3601ff731f4838017a82b72bb
BLAKE2b-256 72aeef3df4cf6915ce367d960739d4cafee42d55d009a2fb72347e460d04c607

See more details on using hashes here.

File details

Details for the file piqtree2-0.3.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for piqtree2-0.3.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bd55d2528eb4f9f992bc9eb1248214c74be5ef6bcb373c5faee01e5bb76260a3
MD5 c2ec4fc02a098914c20ab9d2adcc0e8f
BLAKE2b-256 0527bbc5e20674ec7b41df5fe8726574c5d0aaa6bc91332e3b20cc098e097696

See more details on using hashes here.

File details

Details for the file piqtree2-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for piqtree2-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 cc15f9203d47ae594eed75d12c9da2251461d81cc958ad9859bd1e963a66172a
MD5 79f8b68671125ed2d489f756214f8d2d
BLAKE2b-256 397b0f1b2d9095247f21f1d4216e3121da39dc400cec510a061718f1448eb20c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page