2 ## Bioperl Test Harness Script for Modules
7 $DEBUG = test_debug() || -1;
11 test_begin(-tests => 14);
12 use_ok('Bio::Tools::Run::Phylo::Phylip::ProtDist');
13 use_ok('Bio::Tools::Run::Alignment::Clustalw');
24 'freq' =>'0.25,0.5,0.125,0.125');
26 my $dist_factory = Bio::Tools::Run::Phylo::Phylip::ProtDist->new(@params);
29 test_skip(-requires_executable => $dist_factory,
32 isa_ok $dist_factory,'Bio::Tools::Run::Phylo::Phylip::ProtDist';
35 $dist_factory->model($model);
37 my $new_model= $dist_factory->model();
38 is $new_model , 'KIMURA', "set factory parameter";
41 $dist_factory->gencode($gencode);
43 my $new_gencode= $dist_factory->gencode();
44 is $new_gencode, 'M', "set factory parameter";
47 $dist_factory->category($category);
49 my $new_category= $dist_factory->category();
50 is $new_category, "H", "set factory parameter";
53 $dist_factory->probchange($probchange);
55 my $new_probchange= $dist_factory->probchange();
56 is $new_probchange, 0.4, "set factory parameter";
59 $dist_factory->trans($trans);
61 my $new_trans= $dist_factory->trans();
62 is $new_trans, 5, "set factory parameter";
64 my $freq= "0.25,0.5,0.125,0.125";
65 $dist_factory->freq($freq);
67 my $new_freq= $dist_factory->freq();
68 is $new_freq, "0.25,0.5,0.125,0.125", "set factory parameter";
71 $dist_factory->quiet($bequiet); # Suppress protpars messages to terminal
73 my $inputfilename = test_input_file("protpars.phy");
76 $dist_factory->verbose($verbose);
77 ($matrix) = $dist_factory->create_distance_matrix($inputfilename);
79 is(sprintf("%.3f", $matrix->get_entry('ENSP000003','SINFRUP001')),0.277);
81 $inputfilename = test_input_file("cysprot.fa");
82 @params = ('ktuple' => 2, 'matrix' => 'BLOSUM',
83 -verbose => $verbose);
84 my $align_factory = Bio::Tools::Run::Alignment::Clustalw->new(@params);
87 test_skip(-requires_executable => $align_factory,
90 my $aln = $align_factory->align($inputfilename);
91 ($matrix) = $dist_factory->create_distance_matrix($aln);
93 is (int($matrix->get_entry('ALEU_HORVU','ALEU_HORVU')),0,
94 "creating distance matrix");
95 ok(sprintf("%.2f",$matrix->get_entry('CATL_HUMAN','CYS1_DICDI'),'1.30', "creating distance matrix"));
97 # Test name preservation and restoration:
98 $inputfilename = test_input_file("longnames.aln");
99 $aln = Bio::AlignIO->new(-file=>$inputfilename, -format=>'clustalw')->next_aln;
100 my ($aln_safe, $ref_name) =$aln->set_displayname_safe(3);
101 ($matrix) = $dist_factory->create_distance_matrix($aln_safe);
102 is (int($matrix->get_entry('S03','S03')),0, "failed creating matrix on safe names");
103 ok(sprintf("%.4f",$matrix->get_entry('S01','S02'),'0.0205', "failed creating distance matrix"));