[Biopython] getting the parent of a Clade

Michael Thon mike.thon at gmail.com
Tue Nov 2 09:58:46 UTC 2010


Hi Eric 
> 
> Do you or anyone else want to try plugging that all_parents function into your code to see if it helps significantly? If it does, I could add it as a Tree/Clade method in the next Biopython release.
> 


I can try it - I have a few 1000 trees to parse so any differences in performance should be more obvious.  

But first, I realized that I should have explained the problem I'm solving in more detail, to see if I'm approaching it the right way.  I need to visit every node in the tree, and then compare the node to its parent and do some calculations.  I'm doing this by writing a recursion that starts with tree.clade and then calls itself twice with clade.clade[0] and clade.clades[1] .  then within the function I need to get the parent clade and do the calculations.  

def crunch_clade(tree, clade):
	compute_data(clade, get_parent(tree, clade)
	crunch_clade(tree, clade.clades[0])
	crunch_clade(tree, clade.clades[1])

Is there a better way to do it?  Like maybe starting with the terminal clades?

Mike





More information about the Biopython mailing list