2 ## Bioperl Test Harness Script for Modules
10 test_begin(-tests => 11);
11 use_ok('Bio::Tools::Run::Phylo::Phylip::ProtPars');
12 use_ok('Bio::Tools::Run::Alignment::Clustalw');
15 my @params = ('threshold'=>10,'jumble'=>'17,10',outgroup=>2,'idlength'=>10);
16 my $tree_factory = Bio::Tools::Run::Phylo::Phylip::ProtPars->new(@params);
17 isa_ok $tree_factory,'Bio::Tools::Run::Phylo::Phylip::ProtPars';
20 test_skip(-requires_executable => $tree_factory,
24 $tree_factory->threshold($threshold);
26 my $new_threshold= $tree_factory->threshold();
27 is $new_threshold, 5, "set factory parameter";
30 $tree_factory->outgroup($outgroup);
32 my $new_outgroup= $tree_factory->outgroup();
33 is $new_outgroup, 3, "set factory parameter";
36 $tree_factory->jumble($jumble);
38 my $new_jumble= $tree_factory->jumble();
39 is $new_jumble, "7,5", "set factory parameter";
42 $tree_factory->quiet($bequiet); # Suppress protpars messages to terminal
44 my $inputfilename = test_input_file("protpars.phy");
47 $tree = $tree_factory->create_tree($inputfilename);
49 # have to sort the since there is polytomy here.
50 my @nodes = sort { $a->id cmp $b->id } grep { $_->id } $tree->get_nodes();
51 is ($nodes[2]->id, 'SINFRUP002',
52 "creating tree by protpars");
54 $inputfilename = test_input_file("cysprot1a.fa");
55 @params = ('ktuple' => 2, 'matrix' => 'BLOSUM',
57 my $align_factory = Bio::Tools::Run::Alignment::Clustalw->new(@params);
60 test_skip(-requires_executable => $align_factory,
63 my $aln = $align_factory->align($inputfilename);
65 $tree = $tree_factory->create_tree($aln);
67 @nodes = sort { defined $a->id && defined $b->id && $a->id cmp $b->id } $tree->get_nodes();
68 is (scalar(@nodes),5, "creating tree by protpars");
70 # test name preservation and restoration:
71 @params = ('threshold'=>10,'jumble'=>'7,5',outgroup=>2,'idlength'=>10);
72 $tree_factory = Bio::Tools::Run::Phylo::Phylip::ProtPars->new(@params);
73 $tree_factory->quiet($bequiet); # Suppress protpars messages to terminal
74 $inputfilename = test_input_file("longnames.aln");
75 my $aln2 = Bio::AlignIO->new(-file=>$inputfilename, -format=>'clustalw')->next_aln;
76 my ($aln_safe, $ref_name) = $aln2->set_displayname_safe(3);
77 my $tree2 = $tree_factory->create_tree($aln_safe);
78 @nodes = sort { $a->id cmp $b->id } $tree2->get_nodes();
79 is (scalar(@nodes),27,
80 "creating tree by protpars");
81 is ($nodes[12]->id, 'S01',"assign serial names");
82 foreach my $nd (@nodes){
83 $nd->id($ref_name->{$nd->id_output}) if $nd->is_Leaf;
85 is ($nodes[12]->id, 'Spar_21273',"restore original names");