2 ## Bioperl Test Harness Script for Modules
10 test_begin(-tests => 17);
11 use_ok('Bio::Tools::Run::Phylo::Phylip::ProtDist');
12 use_ok('Bio::Tools::Run::Phylo::Phylip::Neighbor');
16 my @params = ('type' =>'UPGMA',
23 my $tree_factory = Bio::Tools::Run::Phylo::Phylip::Neighbor->new(@params);
26 test_skip(-requires_executable => $tree_factory,
28 isa_ok $tree_factory,'Bio::Tools::Run::Phylo::Phylip::Neighbor';
31 $tree_factory->type($type);
32 my $new_type = $tree_factory->type();
33 is $new_type, "NEIGHBOR", " couldn't set factory parameter";
36 $tree_factory->outgroup($outgroup);
37 my $new_outgroup = $tree_factory->outgroup();
38 is $new_outgroup, 1, " couldn't set factory parameter";
41 $tree_factory->lowtri($lowtri);
42 my $new_lowtri = $tree_factory->lowtri();
43 is $new_lowtri, 0, " couldn't set factory parameter";
46 $tree_factory->upptri($upptri);
47 my $new_upptri = $tree_factory->upptri();
48 is $new_upptri, 0, " couldn't set factory parameter";
51 $tree_factory->subrep($subrep);
52 my $new_subrep = $tree_factory->subrep();
53 is $new_subrep,0, " couldn't set factory parameter";
56 $tree_factory->jumble($jumble);
57 my $new_jumble = $tree_factory->jumble();
58 is $new_jumble, 1, " couldn't set factory parameter";
61 $tree_factory->quiet($bequiet); # Suppress protpars messages to terminal
63 my $inputfilename = test_input_file("neighbor.dist");
66 ($tree) = $tree_factory->create_tree($inputfilename);
68 my ($tip1) = $tree->find_node('SINFRUP002');
70 is($tip1->id, 'SINFRUP002');
72 my ($other) = grep { $_->id ne $tip1->id } $tip1->ancestor->each_Descendent;
74 is($other->id, 'ENSP000002');
75 is($tip1->branch_length, '0.07854');
76 is($other->branch_length,'0.20141');
78 my ($hum) = $tree->find_node('SINFRUP001');
79 is($hum->branch_length,'0.08462');
81 $inputfilename = test_input_file("protpars.phy");
82 my $protdist_factory = Bio::Tools::Run::Phylo::Phylip::ProtDist->new();
83 $protdist_factory->quiet(1);
85 my ($matrix) = $protdist_factory->create_distance_matrix($inputfilename);
87 $tree_factory->outgroup('ENSP000003');
88 ($tree) = $tree_factory->create_tree($matrix);
90 my @nodes = sort { defined $a->id &&
92 $a->id cmp $b->id } $tree->get_nodes();
93 is ($nodes[1]->id, 'ENSP000003',"failed creating tree by neighbor");
95 # Test name preservation and restoration:
96 $inputfilename = test_input_file("longnames.aln");
97 my $aln = Bio::AlignIO->new(-file=>$inputfilename, -format=>'clustalw')->next_aln;
98 my ($aln_safe, $ref_name) =$aln->set_displayname_safe(3);
99 $protdist_factory = Bio::Tools::Run::Phylo::Phylip::ProtDist->new();
100 ($matrix) = $protdist_factory->create_distance_matrix($aln_safe);
101 $tree_factory->outgroup(undef);
102 ($tree) = $tree_factory->create_tree($matrix);
103 @nodes = sort { defined $a->id &&
105 $a->id cmp $b->id } $tree->get_nodes();
106 is ($nodes[12]->id, 'S01',"failed to assign serial names");
107 foreach my $nd (@nodes){
108 $nd->id($ref_name->{$nd->id_output}) if $nd->is_Leaf;
110 is ($nodes[12]->id, 'Spar_21273',"failed to restore original names");