[Bioperl-l] Find distances between LCA's and the other nodes from a tree
Dave Messina
David.Messina at sbc.su.se
Mon Oct 3 09:17:47 UTC 2011
Hi Ross,
Bio::Tree::Node is a NodeI object. It inherits — or, more accurately,
implements — all of the methods in NodeI.
Admittedly, it's a little obscure. The modules ending in 'I' — the 'I'
stands for Interface — are never meant to be called directly. Rather, they
define the methods that other modules, which are called directly, like
Bio::Tree::Node, must have in order to be compliant with the
Bio::Tree::NodeI interface. If you look at the code for NodeI, you'll that
there are only a very few methods actually coded in there; most of them are
simply empty placeholders.
You can read more about this here:
http://www.bioperl.org/wiki/Advanced_BioPerl#Bioperl_Interface_design
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?
Dave
On Mon, Oct 3, 2011 at 06:19, Ross KK Leung <ross at cuhk.edu.hk> wrote:
> The LCA obtained by get_lca from TreeFunctionsI is not a NodeI object. And
> from NodeI documentation, I cannot identify a way to make a Node object to
> a
> NodeI object. By the same token, methods like is_monophyletic or
> is_paraphyletic are also unable to work on LCA's. Web search does not
> return
> any examples about the manipulation of the LCA. Any hints would be highly
> appreciated so I can continue to dig out the remaining on my own.
>
>
>
> use Bio::TreeIO;
>
> use Bio::Tree::TreeFunctionsI;
>
>
>
> $tab = "\t"; $nl = "\n";
>
> my ($testtree) = @ARGV; #or by the following _DATA_
>
> my $treein = Bio::TreeIO->new( -file => $testtree, -format => 'newick' );
>
> while( my $tree = $treein->next_tree ){
>
> %dist_matrix = ();
>
>
>
> my @leaves = $tree->get_leaf_nodes;
>
> foreach my $leaf1( @leaves ){
>
> my $id1 = $leaf1->id;
>
> foreach my $leaf2( @leaves ){
>
> my $id2 = $leaf2->id;
>
> if ($id1 eq $id2) {
>
> $dist_matrix{$id1}->{$id2} = 0;
>
> next;
>
> }
>
> my $distance = $tree->distance( -nodes => [$leaf1,
> $leaf2] );
>
> if ($id1 eq "A" and $id2 eq "B") {
>
> my $lca = $tree->get_lca(-nodes => [$leaf1,
> $leaf2] );
>
> }
>
> print "$leaf1:LCA:$lca:ACL:$leaf2"; <STDIN>;
>
> #print $lca->id; <STDIN>;
>
> my $distance2 = $tree->distance( -nodes => [$lca,
> $leaf2] );
>
> print $distance2; <STDIN>;
>
>
>
> $dist_matrix{$id1}->{$id2} = $distance;
>
> }
>
> }
>
> }
>
>
>
> #_DATA_
>
>
> ((((((A:1.00000000,B:1.00000000):1.00000000,C:1.00000000):0.00000000,D:0.000
>
> 00000):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.000000
> 00);
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>
More information about the Bioperl-l
mailing list