[Bioperl-l] Find distances between LCA's and the other nodes from a tree

Ross KK Leung ross at cuhk.edu.hk
Tue Oct 4 21:10:33 EDT 2011


-----Original Message-----
From: rutgeraldo at gmail.com [mailto:rutgeraldo at gmail.com] On Behalf Of Rutger
Vos
Sent: 2011Äê10ÔÂ5ÈÕ 8:42
To: Ross KK Leung
Cc: bioperl-l; Thomas Sharpton
Subject: Re: [Bioperl-l] Find distances between LCA's and the other nodes
from a tree

You should probably pre-compute the distances from each node to all
its ancestors (post-order traversal) and attach those values as hashes
to the internal nodes. Then, for any assigned node, you just traverse
from it to the root, look up those hashes along the way and compute
the distance from the assigned node to all others that way.

Thanks, Rutger. While there is a convenient function to help calculate the
distances between leaf nodes, I find it difficult for ancestors. After using
get_lca, it seems that bioperl has no data structures to help manipulate
these LCA's.




More information about the Bioperl-l mailing list