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);
79 my @nodes = sort { $a->id cmp $b->id }
80 grep { defined $_->id} $tree->get_nodes();
82 ok($nodes[2]->id, 'SINFRUP002');
83 ok($nodes[1]->id, 'SINFRUP001');
84 ok($nodes[0]->id, 'ENSP000002');
86 ok($nodes[2]->branch_length,'0.07854');
87 ok($nodes[1]->branch_length,'0.08462');
88 ok($nodes[0]->branch_length,'0.20141');
90 $inputfilename = Bio::Root::IO->catfile("t","data","protpars.phy");
91 my $protdist_factory = Bio::Tools::Run::Phylo::Phylip::ProtDist->new();
92 $protdist_factory->quiet(1);
94 my ($matrix) = $protdist_factory->create_distance_matrix($inputfilename);
96 $tree_factory->outgroup('ENSP000003');
97 ($tree) = $tree_factory->create_tree($matrix);
99 @nodes = sort { defined $a->id &&
101 $a->id cmp $b->id } $tree->get_nodes();
102 ok ($nodes[1]->id, 'ENSP000003',"failed creating tree by neighbor");