2 ## Bioperl Test Harness Script for Modules
10 test_begin(-tests => 11);
11 use_ok('Bio::Tools::Run::Phylo::Phylip::ProtPars');
14 my @params = ('threshold'=>10,'jumble'=>'17,10',outgroup=>2,'idlength'=>10);
15 my $tree_factory = Bio::Tools::Run::Phylo::Phylip::ProtPars->new(@params);
16 isa_ok $tree_factory,'Bio::Tools::Run::Phylo::Phylip::ProtPars';
19 test_skip(-requires_executable => $tree_factory,
20 -requires_module => 'Bio::Tools::Run::Alignment::Clustalw',
22 use_ok('Bio::Tools::Run::Alignment::Clustalw');
25 $tree_factory->threshold($threshold);
27 my $new_threshold= $tree_factory->threshold();
28 is $new_threshold, 5, "set factory parameter";
31 $tree_factory->outgroup($outgroup);
33 my $new_outgroup= $tree_factory->outgroup();
34 is $new_outgroup, 3, "set factory parameter";
37 $tree_factory->jumble($jumble);
39 my $new_jumble= $tree_factory->jumble();
40 is $new_jumble, "7,5", "set factory parameter";
43 $tree_factory->quiet($bequiet); # Suppress protpars messages to terminal
45 my $inputfilename = test_input_file("protpars.phy");
48 $tree = $tree_factory->create_tree($inputfilename);
50 # have to sort the since there is polytomy here.
51 my @nodes = sort { $a->id cmp $b->id } grep { $_->id } $tree->get_nodes();
52 is ($nodes[2]->id, 'SINFRUP002',
53 "creating tree by protpars");
55 $inputfilename = test_input_file("cysprot1a.fa");
56 @params = ('ktuple' => 2, 'matrix' => 'BLOSUM',
58 my $align_factory = Bio::Tools::Run::Alignment::Clustalw->new(@params);
61 test_skip(-requires_executable => $align_factory,
64 my $aln = $align_factory->align($inputfilename);
66 $tree = $tree_factory->create_tree($aln);
68 @nodes = sort { defined $a->id && defined $b->id && $a->id cmp $b->id } $tree->get_nodes();
69 is (scalar(@nodes),5, "creating tree by protpars");
71 # test name preservation and restoration:
72 @params = ('threshold'=>10,'jumble'=>'7,5',outgroup=>2,'idlength'=>10);
73 $tree_factory = Bio::Tools::Run::Phylo::Phylip::ProtPars->new(@params);
74 $tree_factory->quiet($bequiet); # Suppress protpars messages to terminal
75 $inputfilename = test_input_file("longnames.aln");
76 my $aln2 = Bio::AlignIO->new(-file=>$inputfilename, -format=>'clustalw')->next_aln;
77 my ($aln_safe, $ref_name) = $aln2->set_displayname_safe(3);
78 my $tree2 = $tree_factory->create_tree($aln_safe);
79 @nodes = sort { $a->id cmp $b->id } $tree2->get_nodes();
80 is (scalar(@nodes),27,
81 "creating tree by protpars");
82 is ($nodes[12]->id, 'S01',"assign serial names");
83 foreach my $nd (@nodes){
84 $nd->id($ref_name->{$nd->id_output}) if $nd->is_Leaf;
86 is ($nodes[12]->id, 'Spar_21273',"restore original names");