Skip to main content

Phylogenetic tools and methods involving splits and matrix rank

Project description


Coverage Status

Python package which implements split- and rank-based tools for inferring phylogenies, such as flattenings and subflattenings.


The latest version of SplitP can be installed via the command pip install splitp


Import splitp and the associated helper functions

import splitp as sp
from splitp import tree_helper_functions as hf

Define trees and work with splits

splits = list(hf.all_splits(4))     # [01|23, 02|13, 03|12]
tree = sp.NXTree('((0,1),(2,3));')	
true_splits = tree.true_splits()    # 01|23

Let site patterns evolve under any submodel of the general markov model.

JC_subs_matrix = tree.build_JC_matrix(branch_length:=0.05)
pattern_probs = tree.get_pattern_probabilities()
>             0         1
      0    AAAA  0.185844
      1    AAAC  0.003262
      ..    ...       ...
      254  TTTG  0.003262
      255  TTTT  0.185844

Simulate sequence alignments from pattern distributions

pattern_frequencies = tree.draw_from_multinomial(pattern_probs, 100)
>         0    1
    0  AAAA  0.22
    1  AAAC  0.01
    ..  ...   ...
    2  CCGC  0.03
    3  TTTT  0.14

Reconstruct trees using split based methods including flattenings:

F1 = tree.flattening('01|23', pattern_frequencies)
F2 = tree.flattening('02|13', pattern_frequencies)
print(tree.split_score(F1) < tree.split_score(F2))    # True

Or subflattenings:

SF = tree.signed_sum_subflattening('01|23', pattern_probs)
print(tree.split_score(SF))   # 0.0

For more functionality please see the documentation at

Please see for information on contributing to this project.

Project details

Download files

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

Files for splitp, version 0.1.7
Filename, size File type Python version Upload date Hashes
Filename, size splitp-0.1.7-py3-none-any.whl (829.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size splitp-0.1.7.tar.gz (827.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page