1 Nov 2010 06:41
Re: [Biopython] getting the parent of a Clade
Michael Thon <mike.thon <at> gmail.com>
2010-11-01 05:41:41 GMT
2010-11-01 05:41:41 GMT
On Oct 31, 2010, at 8:23 PM, Eric Talevich wrote: > > > On Sun, Oct 31, 2010 at 1:57 PM, Eric Talevich <eric.talevich <at> gmail.com> wrote: > On Sun, Oct 31, 2010 at 12:03 PM, Michael Thon <mike.thon <at> gmail.com> wrote: > I have a Clade object and I need to access its parent clade. I thought that clade.root should do this but this seems to contain a reference to itself: > > (Pdb) main_clade == main_clade.root > True > > Is there some other way? > Thanks > Mike > > > Hi Mike, > > You can do this, assuming you have the original tree object (call it "tree"): > > parent = tree.get_path(main_clade)[-2] > > This is an O(n) operation on the tree, so if you need to do it repeatedly on a large tree, it's faster to call tree.get_path(clade) once outside the loop and then reuse the resulting list. > > Is the operation you're doing here part of something you'd like to see implemented as a tree method? > >(Continue reading)
RSS Feed