-
Notifications
You must be signed in to change notification settings - Fork 1
Reading Trees
The tree
class definition found in the tree
module offers a way to store metadata and to encapsulate tree solutions in the solution search space.
Reading trees is only natively supported from a Newick string, which means that reading trees from files is not currently supported. However, it can still be done if you have a method to read a tree from a file and if you can convert that to a Newick string.
The basic syntax for reading a Newick string is as follows.
from pylogeny.tree import tree # import tree class definition
t = tree("A(B,C);") # instantiate with this Newick string
If we wanted the framework to also "check" this Newick string and perform some processing on the string, we can set the check
variable to True
. This reroots the tree to a consistent unambiguous form (reroot to the lowest-order leaf lexicographically) that ensures the tree is recognized between duplicate topologies. This new Newick string is stored in the object but not returned.
t = tree("A(B,C);",check=True)
If we wanted to see this Newick string, we can simply access this field from the object.
newNewick = t.getNewick()
Similarly, we could always print the tree object to print it as a Newick string.
print t