[Bioperl-l] distances between leaf nodes

Jeffrey Detras jdetras at gmail.com
Fri Mar 5 01:17:40 EST 2010


I am new at using the Bio::TreeIO module specifically using the newick
format for a phylogenetic analysis. The sample_tree attached is
Newick-formatted tree. My objective is to get all the distances between all
the leaf nodes. I copied examples of the code from
http://www.bioperl.org/wiki/HOWTO:Trees but it does not tell me much (to my
knowledge) so that I understand how to assign the right array value for the
nodes/leaves. The message would say must provide 2 root nodes.

Here is what I have right now:

#!/usr/bin/perl -w
 use strict;

 my $treefile = 'sample_tree';
 use Bio::TreeIO;
 my $treeio = Bio::TreeIO->new(-format => 'newick',
                                 -file => $treefile);

 while (my $tree = $treeio->next_tree) {
         my @leaves = $tree->get_leaf_nodes;
         for (my $dist = $tree->distance(-nodes => \@leaves)){
                 print "Distance between trees is $dist\n";

-------------- next part --------------
A non-text attachment was scrubbed...
Name: sample_tree
Type: application/octet-stream
Size: 418 bytes
Desc: not available
URL: <http://lists.open-bio.org/pipermail/bioperl-l/attachments/20100305/9b1d5836/attachment.obj>

More information about the Bioperl-l mailing list