2 ## Bioperl Test Harness Script for Modules
9 test_begin(-tests => 33);
11 use_ok('Bio::Tools::Run::Phylo::Gerp');
12 use_ok('Bio::AlignIO');
13 use_ok('Bio::TreeIO');
14 use_ok('Bio::Root::Utilities');
18 unlink(test_input_file('gerp', 'ENr111.mfa'));
21 # setup input files etc
22 my $alignfilename = test_input_file('gerp', 'ENr111.mfa.gz');
23 my $treefilename = test_input_file('gerp', 'ENr111.gerp.tree');
24 ok (-e $alignfilename, 'Found input alignment file');
25 ok (-e $treefilename, 'Found input tree file');
27 my $factory = Bio::Tools::Run::Phylo::Gerp->new(-verbose => -1,
29 isa_ok($factory, 'Bio::Tools::Run::Phylo::Gerp');
30 ok $factory->can('e'), 'has a created method not in args supplied to new';
31 is $factory->quiet, 1, 'quiet was set';
33 # test default factory values
34 is ($factory->program_dir, $ENV{'GERPDIR'}, 'program_dir returned correct default');
35 is ($factory->program_name(), 'gerpcol', 'Correct exe default name');
37 # test the program itself
39 test_skip(-requires_executable => $factory, -tests => 22);
41 my $util = Bio::Root::Utilities->new();
42 $alignfilename = $util->uncompress(-file => $alignfilename,
45 skip("Couldn't uncompress the alingment input file", 22) unless $alignfilename;
47 # using filename input
48 ok my $parser = $factory->run($alignfilename, $treefilename), 'got results using filename input';
50 while (my $result = $parser->next_result) {
51 push(@result1, $result);
53 ok close_enough(scalar(@result1), 121, 20), 'reasonable number of results using filename input';
55 # using SimpleAlign and Bio::Tree::Tree input
56 my $alignio = Bio::AlignIO->new(-file => $alignfilename);
57 my $aln = $alignio->next_aln;
58 my $treeio = Bio::TreeIO->new(-verbose => -1, -file => $treefilename);
59 my $tree = $treeio->next_tree;
60 ok $parser = $factory->run($aln, $tree), 'got results using object input';
62 while (my $result = $parser->next_result) {
63 push(@result2, $result);
65 ok close_enough(scalar(@result2), 121, 20), 'reasonable number of results using object input';
67 # spot-test the results
68 my @spot_results = ($result1[0], $result1[1], $result1[2]);
70 foreach my $expected ([294576, 294688, 56.5, 1.76552e-57],
71 [337735, 337898, 50.9, 3.19063e-57],
72 [285430, 285608, 44.3, 1.41149e-54]) {
73 my $feat = shift(@spot_results);
74 isa_ok $feat, 'Bio::SeqFeature::Annotated';
75 is $feat->source->value, 'GERP', 'correct source';
76 ok close_enough($feat->start, shift(@{$expected}), 10), 'feature start close enough';
77 ok close_enough($feat->end, shift(@{$expected}), 10), 'feature end close enough';
78 ok close_enough($feat->score, shift(@{$expected}), 5), 'feature score close enough';
79 my ($p_value) = $feat->get_Annotations('pvalue');
80 ok close_enough(ref $p_value ? $p_value->value : $p_value, shift(@{$expected}), 100e-57), 'feature pvalue close enough';
85 my ($actual, $expected, $variance) = @_;
86 return 1 if $actual == $expected;
88 if ($actual >= ($expected - $variance) &&
89 $actual <= ($expected + $variance)) {