[Bioperl-l] Can't locate object method "is_compatible" via package"Bio::Tree::Tree"

viping vipingjo at gmail.com
Thu Jan 17 13:23:14 UTC 2008


I got latest  code modified by Sendu Bala vi SVN. It works well while "input.tre" and "t.pl" are in the same directory. Thank you, Sendu Bala.  

This is output:
Subroutine new redefined at i:/Perl/site/lib/Bio\Tree\Tree.pm line 96.
Subroutine nodelete redefined at i:/Perl/site/lib/Bio\Tree\Tree.pm line 145.
Subroutine get_nodes redefined at i:/Perl/site/lib/Bio\Tree\Tree.pm line 162.
Subroutine get_root_node redefined at i:/Perl/site/lib/Bio\Tree\Tree.pm line 196.
Subroutine set_root_node redefined at i:/Perl/site/lib/Bio\Tree\Tree.pm line 211.
Subroutine total_branch_length redefined at i:/Perl/site/lib/Bio\Tree\Tree.pm line 235.
Subroutine id redefined at i:/Perl/site/lib/Bio\Tree\Tree.pm line 257.
Subroutine score redefined at i:/Perl/site/lib/Bio\Tree\Tree.pm line 278.
Subroutine cleanup_tree redefined at i:/Perl/site/lib/Bio\Tree\Tree.pm line 314.
Subroutine new redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 100.
Subroutine add_Descendent redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 152.
Subroutine each_Descendent redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 190.
Subroutine remove_Descendent redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 252.
Subroutine remove_all_Descendents redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 300.
Subroutine ancestor redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 334.
Subroutine branch_length redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 375.
Subroutine bootstrap redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 399.
Subroutine description redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 420.
Subroutine id redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 449.
Subroutine internal_id redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 491.
Subroutine _creation_id redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 505.
Subroutine is_Leaf redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 526.
Subroutine height redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 552.
Subroutine invalidate_height redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 577.
Subroutine add_tag_value redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 597.
Subroutine remove_tag redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 617.
Subroutine remove_all_tags redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 637.
Subroutine get_all_tags redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 653.
Subroutine get_tag_values redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 669.
Subroutine has_tag redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 685.
Subroutine node_cleanup redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 690.
Subroutine reverse_edge redefined at i:/Perl/site/lib/Bio\Tree\Node.pm line 717.
incompatible trees
label G cluster G cluster G K
cluster A B C properly intersects cluster A B H
cluster A B C properly intersects cluster A B E G H I J K
cluster A B C D properly intersects cluster A B H
cluster A B C D properly intersects cluster A B E G H I J K
cluster E F G properly intersects cluster G K
cluster E F G properly intersects cluster G I J K
cluster E F G properly intersects cluster A B E G H I J K
cluster A B C D E F G properly intersects cluster A B H
cluster A B C D E F G properly intersects cluster G K
cluster A B C D E F G properly intersects cluster G I J K
cluster A B C D E F G properly intersects cluster A B E G H I J K

#this is latest code:
  use Bio::Tree::Compatible;
  use Bio::TreeIO;
  my $input = Bio::TreeIO->new('-format' => 'newick',
                               '-file'   => 'input.tre');
  my $t1 = $input->next_tree;
  my $t2 = $input->next_tree;

  my ($incompat, $ilabels, $inodes) = Bio::Tree::Compatible::is_compatible($t1,$t2);
  if ($incompat) {
    my %cluster1 = %{ Bio::Tree::Compatible::cluster_representation($t1) };
    my %cluster2 = %{ Bio::Tree::Compatible::cluster_representation($t2) };
    print "incompatible trees\n";
    if (scalar(@$ilabels)) {
      foreach my $label (@$ilabels) {
        my $node1 = $t1->find_node(-id => $label);
        my $node2 = $t2->find_node(-id => $label);
        my @c1 = sort @{ $cluster1{$node1} };
        my @c2 = sort @{ $cluster2{$node2} };
        print "label $label";
        print " cluster"; map { print " ",$_ } @c1;
        print " cluster"; map { print " ",$_ } @c2; print "\n";
      }
    }
    if (scalar(@$inodes)) {
      while (@$inodes) {
        my $node1 = shift @$inodes;
        my $node2 = shift @$inodes;
        my @c1 = sort @{ $cluster1{$node1} };
        my @c2 = sort @{ $cluster2{$node2} };
        print "cluster"; map { print " ",$_ } @c1;
        print " properly intersects cluster";
        map { print " ",$_ } @c2; print "\n";
      }
    }
  } else {
    print "compatible trees\n";
  }


------------------				 
viping
2008-01-17

-------------------------------------------------------------
From: Sendu Bala
Date: 2008-01-17 19:19:30
To: viping
Cc: bioperl-l
Subject: Re: [Bioperl-l] Can't locate object method "is_compatible" via package"Bio::Tree::Tree"

viping wrote:
> Hi Everyone,
> 
> I'm using ActivePerl-5.8.8.822-MSWin32-x86-280952 + bioperl-1.5.2 + 
> Windows XP SP2. When running example codes(attched below as t.pl) 
> within Bio\Tree\Compatible.pm , I got this error:
> 
> Can't locate object method "is_compatible" via package 
> "Bio::Tree::Tree"
> 
> I replaced "$t1->is_compatible($t2)" with "is_compatible 
> Bio::Tree::Compatible ($t1,$t2)",

Yup, you had the right idea; unfortunately the synopsis code for
Bio::Tree::Compatible is wrong.
I've now fixed it in svn.


> the error changed: Can't locate object method "get_nodes" via package
>  "Bio::Tree::Compatible" at i:/Perl/site/lib/Bio/Tree/Compatible.pm 
> line 252, <GEN1> line 1.

I didn't get quite that error; instead I had an issue with TreeIO: for
whatever reason it is only returning one tree from your input file (ie.
$t2 is undefined).

I therefore got "Can't call method "get_nodes" on an undefined value [...]"

Can someone look into/confirm that?




More information about the Bioperl-l mailing list