[Bioperl-l] Find distances between LCA's and the other nodes	from a tree
    Ross KK Leung 
    ross at cuhk.edu.hk
       
    Mon Oct  3 10:28:38 UTC 2011
    
    
  
Dave wrote:
>You can read more about this here: http://www.bioperl.org/wiki/Advanced_BioPerl#Bioperl_Interface_design
Thanks for this reference, it is very good for me to understand better the architecture of Bioperl.
 
>So, if I understand your question correctly, you should be able to use all of the NodeI methods l on the LCA nodes. However, and here's where I'm a bit confused, is_monophyletic is something you'd call on a Tree object, not on a Node object, right?
But the following codes will generate errors because lca cannot be identified.
 
my $treein = Bio::TreeIO->new( -file => $testtree, -format => 'newick' );
while( my $tree = $treein->next_tree ){
       my @leaves = $tree->get_leaf_nodes;
       foreach my $leaf1( @leaves ){
               my $id1 = $leaf1->id;
               foreach my $leaf2( @leaves ){
                       my $id2 = $leaf2->id;
                          my $distance = $tree->distance( -nodes => [$leaf1,$leaf2] );
                       if ($id1 eq "A" and $id2 eq "B") {
                               my $lca = $tree->get_lca(-nodes => [$leaf1,$leaf2] );
                       }
                        print $lca->id; <STDIN>;
                       my $distance2 = $tree->distance( -nodes => [$lca,$leaf2] );
                       print $distance2; <STDIN>;
               }
       }
}
_DATA_
((((((A:1.00000000,B:1.00000000):1.00000000,C:1.00000000):0.00000000,D:0.00000000):1.00000000,(E:0.00000000,(F:2.00000000,G:1.00000000):0.00000000):0.00
000000):2.00000000,(H:3.00000000,(I:2.00000000,(J:1.00000000,(K:2.00000000,(L:2.00000000,M:2.00000000):0.00000000):0.00000000):0.00000000):0.00000000):0
.00000000):1.00000000,(N:0.00000000,((O:0.00000000,P:0.00000000):1.00000000,(Q:2.00000000,(R:2.66666667,S:3.66666667):3.66666667):0.00000000):1.00000000
):3.00000000,(T:0.00000000,(U:0.00000000,V:0.00000000):1.00000000):16.00000000);
 
My ultimate goal is just to conveniently derive the information that nodes M and L share the same LCA O for the following tree.
 
         +---I
         |
     +---M
     |   |
     |   +---H
     |
+---O
|   |
|   |   +---G
|   |   |
|   +---L
|       |
|       +---F
A
|       +---E
|       |
|   +---K
|   |   |
|   |   +---D
|   |
+---N
     |
     |   +---C
     |   |
     +---J
         |
         +---B
 
 
 
    
    
More information about the Bioperl-l
mailing list