[Bioperl-l] distance

Adam Sjøgren adsj at novozymes.com
Tue May 18 10:21:25 UTC 2010


On Tue, 18 May 2010 02:49:29 -0700 (PDT), Bryan wrote:

> my @nodes = $tree->find_node(-fieldname => 'Homo_sapiens','Murinae');

I think you may have misunderstood the documentation of find_node(). You
are supposed to give the fieldname after the dash, so what you want is:

  my @nodes = $tree->find_node(-id => 'Homo_sapiens','Murinae');

- if the field you want to match on is 'id'.

Also, I don't think you can get find_node() to do 'OR'-searches , so
you'll need to do something like this:

= = =
  #!/usr/bin/perl

  use strict;
  use warnings;

  use Bio::TreeIO;

  my $input=Bio::TreeIO->new('-format' => 'newick',
                             '-file' => 'tree_mammalia_newick.txt');
  my $tree=$input->next_tree;

  my ($node1)=$tree->find_node(-id=>'Homo_sapiens'); # this (arbitrarily) picks the first match
  my ($node2)=$tree->find_node(-id=>'Murinae');      # -"-

  my $distance=$tree->distance(-nodes=>[$node1, $node2]);

  print "$distance\n";
= = =

It is much easier to help if you give an example of the input as well as
the script. I constructed this stand-in for your newick file to test on:

  (Homo_sapiens:1.1,B:2.2,(C:3.3,Murinae:4.4):5.5);


  Best regards,

    Adam

-- 
                                                          Adam Sjøgren
                                                    adsj at novozymes.com




More information about the Bioperl-l mailing list