2 ## Bioperl Test Harness Script for Modules
11 test_begin(-tests => 11);
12 use_ok('Bio::Tools::Run::Phylo::Phylip::ProtPars');
13 use_ok('Bio::Tools::Run::Alignment::Clustalw');
16 my @params = ('threshold'=>10,'jumble'=>'17,10',outgroup=>2,'idlength'=>10);
17 my $tree_factory = Bio::Tools::Run::Phylo::Phylip::ProtPars->new(@params);
18 isa_ok $tree_factory,'Bio::Tools::Run::Phylo::Phylip::ProtPars';
21 test_skip(-requires_executable => $tree_factory,
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";
38 $tree_factory->jumble($jumble);
40 my $new_jumble= $tree_factory->jumble();
41 is $new_jumble, "7,5", "set factory parameter";
44 $tree_factory->quiet($bequiet); # Suppress protpars messages to terminal
46 my $inputfilename = test_input_file("protpars.phy");
49 $tree = $tree_factory->create_tree($inputfilename);
51 # have to sort the since there is polytomy here.
52 my @nodes = sort { $a->id cmp $b->id } grep { $_->id } $tree->get_nodes();
53 is ($nodes[2]->id, 'SINFRUP002',
54 "creating tree by protpars");
56 $inputfilename = test_input_file("cysprot1a.fa");
57 @params = ('ktuple' => 2, 'matrix' => 'BLOSUM',
59 my $align_factory = Bio::Tools::Run::Alignment::Clustalw->new(@params);
62 test_skip(-requires_executable => $align_factory,
65 my $aln = $align_factory->align($inputfilename);
67 $tree = $tree_factory->create_tree($aln);
69 @nodes = sort { defined $a->id && defined $b->id && $a->id cmp $b->id } $tree->get_nodes();
71 "creating tree by protpars");
73 # test name preservation and restoration:
74 @params = ('threshold'=>10,'jumble'=>'7,5',outgroup=>2,'idlength'=>10);
75 $tree_factory = Bio::Tools::Run::Phylo::Phylip::ProtPars->new(@params);
76 $tree_factory->quiet($bequiet); # Suppress protpars messages to terminal
77 $inputfilename = test_input_file("longnames.aln");
78 $aln = Bio::AlignIO->new(-file=>$inputfilename, -format=>'clustalw')->next_aln;
79 my ($aln_safe, $ref_name) =$aln->set_displayname_safe(3);
80 $tree = $tree_factory->create_tree($aln_safe);
81 @nodes = sort { $a->id cmp $b->id } $tree->get_nodes();
82 is (scalar(@nodes),27,
83 "creating tree by protpars");
84 is ($nodes[12]->id, 'S01',"assign serial names");
85 foreach my $nd (@nodes){
86 $nd->id($ref_name->{$nd->id_output}) if $nd->is_Leaf;
88 is ($nodes[12]->id, 'Spar_21273',"restore original names");