-
Notifications
You must be signed in to change notification settings - Fork 1
Rearrangements
Alex Safatli edited this page Apr 29, 2015
·
1 revision
A common task when traversing the solution search space for phylogenetic trees is to rearrange trees such that one topology becomes another by moving a subtree to another part of that tree.
This can be facilitated by the framework with use of the rearrangement module. This page will outline how to perform all SPR rearrangements on a tree that we have loaded in memory.
from pylogeny.tree import tree
t = tree((A,(B,(C,D)),((E,(F,(G,H))),((I,J),(K,(L,M)))));",check=True)
topo = t.toTopology() # converts a tree to a rich object of branches and nodes
What we need to do first is transform a tree object into a topology object that allows us to investigate a tree by its branches and nodes. When this is done, we can now initiate SPR movements by calling an appropriately defined method.
rearrList = topo.allSPR() # a list of rearrangement objects
for rearr in rearrList:
move = rearr.doMove() # perform the rearrangement and get a topology object
print move # prints the Newick string for this topology
foo(move) # do something with this topology