Python bindings for IQTree
Project description
piqtree2
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
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, 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
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, 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
Close
Hashes for piqtree2-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cf1acf4017a3426613d937fffcd58f50c9246eb0b39c830188a3a0d29995309 |
|
MD5 | 94e65a72939f1667b7290e20cbcb5aea |
|
BLAKE2b-256 | 410ac01a73c30a763ed6a7b1576cb6820a530e2728aad132696c14a166b7b4e1 |
Close
Hashes for piqtree2-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e460fcbf79e859219e3891913827c8f7d98e2d4b93a191a328b9af39c51ec4ca |
|
MD5 | f4c2a04915e7d2a1de85bc90d4e3b24d |
|
BLAKE2b-256 | 8cb742115a4ca01cdefa3d0b4ae68baf0376134da5699daefd34625376bd3df4 |
Close
Hashes for piqtree2-0.2.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5fe7f4222cc13a7e6964df1f7c4974bb7bbf0c9852fb72d5d4460d838db8f76 |
|
MD5 | 055c7d7a0c327d7b64e201ef2a787f74 |
|
BLAKE2b-256 | 5df58bf67e6ce41839867c8ab0157b4d56bdd20a6df01d58211feec07f859668 |
Close
Hashes for piqtree2-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f855cd43983d1c11a9638c0a01ced6401feb6f688a5219c6ac662e6e437dbc5 |
|
MD5 | 0d49cea74203abe1480da11dc1c97ce7 |
|
BLAKE2b-256 | 5b6c3d2237789ff800e50a3e575a120f504501209e66da2966527eb908368d30 |
Close
Hashes for piqtree2-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d67ef824c8b94c08bac38de7516153224ff0dc765632a5180370988611839f6 |
|
MD5 | 881919572a4d21f423829932d11f9e6f |
|
BLAKE2b-256 | 7faee20e0ca141d1b3de8f785127548663e75f44e5c308e1976a611e412ada5b |
Close
Hashes for piqtree2-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29be0135c8a8b4032bc0111f76c2c4b10ca07ac99e608a84a7fcf1c7f93d566b |
|
MD5 | 3d0015dc8727f650f0bb1d6f9ef3b421 |
|
BLAKE2b-256 | 4967f4ee663acec0b9ea8cbcddd6f50a8b0f91e712d98b6f17d31c861b5ebf7c |
Close
Hashes for piqtree2-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8dfd47a0e4dc6bf4a1ec1b863c042cf30316b242f8ab0ef176f70731a2dbf8b |
|
MD5 | 846d15da41ec76248d4f9e9d5c9ab1b8 |
|
BLAKE2b-256 | a773165fd1aa44033b5b28970d3b8a370907a065e4e45f7f1570221f16726bd7 |
Close
Hashes for piqtree2-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3d478df37c8554bfc6269ae4bee059165135f507756753ac8a06abc40adbd62 |
|
MD5 | fb6e8d55958a9394fda8b22cdefb31d0 |
|
BLAKE2b-256 | 4fe2dc6f29e1d02e88b74c68e6b25297782ad36ac4402b3fd46d0e8f9ad5c98b |
Close
Hashes for piqtree2-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22281ede0c961d84769083842f53d24b81ebca7c10e4c864c76844ecd760982c |
|
MD5 | c4761820f9e3d18dbcdcf5c53256af71 |
|
BLAKE2b-256 | fce8c89193136824d8a6af908c6e28f2a2dd121967f80deda2053faa92b9f451 |
Close
Hashes for piqtree2-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb60e26c190abdd928dd499bb7c9bc07e2b026d792e44f42481799b2c7b3fe6b |
|
MD5 | 7aa3a44aabcea7b439e935b349d6141f |
|
BLAKE2b-256 | f31f40d25c903679ea315af4325ae27c87c1114f294aefd6cda818e2bbcf686e |
Close
Hashes for piqtree2-0.2.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bb72e3a8c7c5e0bfc979d344cf0652411b0233d018b7f997078385790556304 |
|
MD5 | 98bc53012f06f2fca34f2684ec03a4a9 |
|
BLAKE2b-256 | b03699865c22b17c2ed83ce81798705b0c251ab02e882c9341ac8133983a9b17 |
Close
Hashes for piqtree2-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30d14e790074c304e9a6addb8426b87ce13632fab881d7e0d3c569f61e00ed92 |
|
MD5 | 4787fd51d7e91d06f7d95643092bfaac |
|
BLAKE2b-256 | 6d718d55a0d8434368c02638c75760fe6770c3803765ceb25bb528823047a63b |