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');
23 'freq' =>'0.25,0.5,0.125,0.125');
25 my $dist_factory = Bio::Tools::Run::Phylo::Phylip::ProtDist->new(@params);
28 test_skip(-requires_executable => $dist_factory,
29 -requires_module => 'Bio::Tools::Run::Alignment::Clustalw',
32 use_ok('Bio::Tools::Run::Alignment::Clustalw');
33 isa_ok $dist_factory,'Bio::Tools::Run::Phylo::Phylip::ProtDist';
36 $dist_factory->model($model);
38 my $new_model= $dist_factory->model();
39 is $new_model , 'KIMURA', "set factory parameter";
42 $dist_factory->gencode($gencode);
44 my $new_gencode= $dist_factory->gencode();
45 is $new_gencode, 'M', "set factory parameter";
48 $dist_factory->category($category);
50 my $new_category= $dist_factory->category();
51 is $new_category, "H", "set factory parameter";
54 $dist_factory->probchange($probchange);
56 my $new_probchange= $dist_factory->probchange();
57 is $new_probchange, 0.4, "set factory parameter";
60 $dist_factory->trans($trans);
62 my $new_trans= $dist_factory->trans();
63 is $new_trans, 5, "set factory parameter";
65 my $freq= "0.25,0.5,0.125,0.125";
66 $dist_factory->freq($freq);
68 my $new_freq= $dist_factory->freq();
69 is $new_freq, "0.25,0.5,0.125,0.125", "set factory parameter";
72 $dist_factory->quiet($bequiet); # Suppress protpars messages to terminal
74 my $inputfilename = test_input_file("protpars.phy");
77 $dist_factory->verbose($verbose);
78 ($matrix) = $dist_factory->create_distance_matrix($inputfilename);
80 is(sprintf("%.3f", $matrix->get_entry('ENSP000003','SINFRUP001')),0.277);
82 $inputfilename = test_input_file("cysprot.fa");
83 @params = ('ktuple' => 2, 'matrix' => 'BLOSUM',
84 -verbose => $verbose);
85 my $align_factory = Bio::Tools::Run::Alignment::Clustalw->new(@params);
88 test_skip(-requires_executable => $align_factory,
91 my $aln = $align_factory->align($inputfilename);
92 ($matrix) = $dist_factory->create_distance_matrix($aln);
94 is (int($matrix->get_entry('ALEU_HORVU','ALEU_HORVU')),0,
95 "creating distance matrix");
96 ok(sprintf("%.2f",$matrix->get_entry('CATL_HUMAN','CYS1_DICDI'),'1.30', "creating distance matrix"));
98 # Test name preservation and restoration:
99 $inputfilename = test_input_file("longnames.aln");
100 $aln = Bio::AlignIO->new(-file=>$inputfilename, -format=>'clustalw')->next_aln;
101 my ($aln_safe, $ref_name) =$aln->set_displayname_safe(3);
102 ($matrix) = $dist_factory->create_distance_matrix($aln_safe);
103 is (int($matrix->get_entry('S03','S03')),0, "failed creating matrix on safe names");
104 ok(sprintf("%.4f",$matrix->get_entry('S01','S02'),'0.0205', "failed creating distance matrix"));