[Bioperl-l] Bioperl help needed!

Jason Stajich jason.stajich at duke.edu
Tue Nov 2 11:42:43 EST 2004

On Nov 2, 2004, at 11:18 AM, Zara Ghazoui wrote:

> What I would like to be able to do is the following:
> I need to iterate through all the nodes of tree A (with bootstrap 
> value >70) to see if each node, with its descedents (subtree) are 
> present in tree B.
Are you just checking to see if they are present in tree B or have the 
same relationships (in the same clade).   You can use methods like 
get_lca (see TreeFunctionsI) to get the least common ancestor of a set 
of nodes and see if

The $node->ancestor method lets you walk UP the tree to get ancestors 
(each node only has 1 ancestor) or $node->get_all_Descendents to get 
all descendents below a node, or just $node->each_Descendent to get 
just the Nodes in the level below.

Here is one way to start, but not really sure of the behavior you want.

# assuming you have stored the bootstrap value as an internal ID for 
the node
# like this where the A-B clade has 75% support
# ((A:0.100,B:0.200)75:0.150,C:0.300);

# get all the nodes, grep out for those which are NOT tips and have 
bootstrap support >= 70
for my $node ( grep { ! $_->is_Leaf() && $_->id >= 70 } 
$treeA->get_Nodes  ) {
   # note that this will touch the same nodes more than once
   my $all_present = 1;
   # grab all the tips from this clade
   for my $descendent ( grep { $_->is_Leaf} $node->get_all_Descendents ) 
     my $name = $descdendent->id;
     unless( grep { $_->is_Leaf && $_->id eq $name } $treeB->get_Nodes  
) {
        $all_present = 0;
        warn("Cannot find node $name in treeB\n");
     # do something whether or not we found all the child tips of $node 
in treeB
     # based on $all_present  variable.

> Hope this clarifies my first question!
> Zara
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
Jason Stajich
jason.stajich at duke.edu

More information about the Bioperl-l mailing list