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

Ross KK Leung ross at cuhk.edu.hk
Wed Oct 5 01:10:33 UTC 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