Hello folks , i am using the newick module
http://www.daimi.au.dk/~mailund/newick.html.I am just learning to use it and
i have a question about it.

from  newick.tree import parse_tree
from  newick.tree import add_parent_links
from  newick.tree import add_distance_from_root

import sys

t = parse_tree('((A:2,B:3):1,C:6);')

print t

deltas = add_distance_from_root(t)

now when i do this i can get the output like this


(('A' : 2.0, 'B' : 3.0) : 1.0, 'C' : 6.0)
None

This is the code of the add_distance_from_root(0

def add_distance_from_root(tree):
    '''Extend all nodes with the distance (branch length) from the root'''
    tree.distance_from_root = 0.0       # 'tree' is the root...

    class V(TreeVisitor):
        def pre_visit_edge(self,src,b,l,dst):
            if l is None: l = 0
            dst.distance_from_root = src.distance_from_root - l

    tree.dfs_traverse(V())

>From here it is clear that the function does not return anything but i wanna
get the value of the distance from root.How can i get this?

Thanks

Aditya
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to