2 ## Bioperl Test Harness Script for Modules
7 $DEBUG = $ENV{'BIOPERLDEBUG'} || 0;
9 eval { require Test; };
16 plan tests => $NTESTS;
19 use Bio::Tools::Run::Phylo::Phylip::ProtDist;
20 use Bio::Tools::Run::Phylo::Phylip::Neighbor;
22 for ( $Test::ntest..$NTESTS ) {
23 skip("Neighbor not found. Skipping.",1);
28 my @params = ('type' =>'UPGMA',
35 my $tree_factory = Bio::Tools::Run::Phylo::Phylip::Neighbor->new(@params);
36 unless ($tree_factory->executable) {
37 warn("neighbor program not found. Skipping tests $Test::ntest to $NTESTS.\n") if( $DEBUG);
40 ok $tree_factory->isa('Bio::Tools::Run::Phylo::Phylip::Neighbor');
43 $tree_factory->type($type);
44 my $new_type = $tree_factory->type();
45 ok $new_type, "NEIGHBOR", " couldn't set factory parameter";
48 $tree_factory->outgroup($outgroup);
49 my $new_outgroup = $tree_factory->outgroup();
50 ok $new_outgroup, 1, " couldn't set factory parameter";
53 $tree_factory->lowtri($lowtri);
54 my $new_lowtri = $tree_factory->lowtri();
55 ok $new_lowtri, 0, " couldn't set factory parameter";
58 $tree_factory->upptri($upptri);
59 my $new_upptri = $tree_factory->upptri();
60 ok $new_upptri, 0, " couldn't set factory parameter";
63 $tree_factory->subrep($subrep);
64 my $new_subrep = $tree_factory->subrep();
65 ok $new_subrep,0, " couldn't set factory parameter";
68 $tree_factory->jumble($jumble);
69 my $new_jumble = $tree_factory->jumble();
70 ok $new_jumble, 1, " couldn't set factory parameter";
73 $tree_factory->quiet($bequiet); # Suppress protpars messages to terminal
75 my $inputfilename = Bio::Root::IO->catfile("t","data","neighbor.dist");
78 ($tree) = $tree_factory->create_tree($inputfilename);
80 my ($tip1) = $tree->find_node('SINFRUP002');
82 ok($tip1->id, 'SINFRUP002');
84 my ($other) = grep { $_->id ne $tip1->id } $tip1->ancestor->each_Descendent;
86 ok($other->id, 'ENSP000002');
87 ok($tip1->branch_length, '0.07854');
88 ok($other->branch_length,'0.20141');
90 my ($hum) = $tree->find_node('SINFRUP001');
91 ok($hum->branch_length,'0.08462');
93 $inputfilename = Bio::Root::IO->catfile("t","data","protpars.phy");
94 my $protdist_factory = Bio::Tools::Run::Phylo::Phylip::ProtDist->new();
95 $protdist_factory->quiet(1);
97 my ($matrix) = $protdist_factory->create_distance_matrix($inputfilename);
99 $tree_factory->outgroup('ENSP000003');
100 ($tree) = $tree_factory->create_tree($matrix);
102 my @nodes = sort { defined $a->id &&
104 $a->id cmp $b->id } $tree->get_nodes();
105 ok ($nodes[1]->id, 'ENSP000003',"failed creating tree by neighbor");