-
Notifications
You must be signed in to change notification settings - Fork 1
Heuristics
Performing a heuristic search of the combinatorial space comprised by a phylogenetic landscape can be done with relative ease using this library. Not only can the heuristic's steps be later analysed, the resulting space that is explored can also be later viewed and investigated for its properties. The heuristic
module has a number of already defined approximate methods to discover the global maximum of the space, and with understanding of the object hierarchy, one can create their own.
As an example, one could perform a greedy hill-climbing heuristic on the search space by comparing the trees' parsimony scores. To do this, they would instantiate a parsimonyGreedy
object from the heuristic
module and provide an existing landscape and tree in that landscape to start the climb at. The minimal code to achieve a search from the first tree of a landscape would be:
from pylogeny.alignment import alignment
from pylogeny.landscape import landscape
from pylogeny.heuristic import parsimonyGreedy
# Construct a landscape.
ali = alignment("al.fasta")
ls = landscape(ali,starting_tree=ali.getApproxMLTree(),root=True)
# Perform the heuristic.
h = parsimonyGreedy(ls,ls.getRootNode())
h.explore()
We have applied a heuristic to the landscape which has populated it with new trees. Nothing is returned here. In order to investigate what new trees have been added, we can query the heuristic object. Furthermore, we can access these new trees from the landscape object.
newTrees = h.getPath() # list of tree names
for name in newTrees:
foo(ls.getTree(name)) # do something with the tree