[Bioperl-l] distances between leaf nodes

Jason Stajich jason at bioperl.org
Thu Mar 11 15:40:59 UTC 2010


You should only have TWO nodes in the array not all the leaves.

=head2 distance

  Title   : distance
  Usage   : distance(-nodes => \@nodes )
  Function: returns the distance between TWO given nodes
  Returns : numerical distance
  Args    : -nodes => arrayref of nodes to test
            or ($node1, $node2)

=cut


Jeffrey Detras wrote, On 3/4/10 10:17 PM:
> Hi,
>
> 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";
>           }
>   }
>
> Thanks,
> Jeff
>
>    
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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