Fix tests; need to look at Analysis::soap::results()
[bioperl-run.git] / t / Molphy.t
blob6927189cf0af0efeb1ce996fc6b2d76455b1c8d9
1 # This is -*-Perl-*- code
2 ## Bioperl Test Harness Script for Modules
3 ##
4 # $Id$
6 # Before `make install' is performed this script should be runnable with
7 # `make test'. After `make install' it should work as `perl test.t'
9 use strict;
10 use vars qw($NUMTESTS);
12 my $error;
13 my $serror;
15 BEGIN { 
16     # to handle systems with no installed Test module
17     # we include the t dir (where a copy of Test.pm is located)
18     # as a fallback
19     eval { require Test; };
20     if( $@ ) {
21         use lib 't';
22     }
23     use Test;
24     
25     $NUMTESTS = 7;
26     plan tests => $NUMTESTS;
28     unless (eval "require IO::String; 1;") {
29             print STDERR ("IO::String not installed. Skipping tests $Test::ntest to $NUMTESTS.\n");
30             for ($Test::ntest..$NUMTESTS){
31                 skip(1,1);
32             }
33             exit(0);
34     }
37 my $verbose = $ENV{'BIOPERLDEBUG'};
39 END { unlink('protml.eps'); }
40 ## End of black magic.
42 ## Insert additional test code below but remember to change
43 ## the print "1..x\n" in the BEGIN block to reflect the
44 ## total number of tests that will be run. 
46 use Bio::Tools::Phylo::Molphy; # PAML parser
47 use Bio::Tools::Run::Phylo::Molphy::ProtML;
48 use Bio::AlignIO;
50 END {     
51     for ( $Test::ntest..$NUMTESTS) {
52         skip("Molphy not found. Skipping.",1);
53     }
57 my %args = ( 'models' => 'jtt', 
58              'search' => 'quick', 
59              "other" => [ '-information', '-w']); 
60 my $protml = new Bio::Tools::Run::Phylo::Molphy::ProtML(-verbose => $verbose,
61                                                         -flags => \%args);
62 unless ($protml->executable){
63   warn("Molphy package not installed. Skipping tests $Test::ntest to $NUMTESTS.\n");
64 exit(0) ;
67 my $in = new Bio::AlignIO(-format => 'clustalw',
68                           -file   => Bio::Root::IO->catfile('t','data',
69                                                             'cel-cbr-fam.aln'));
70 my $aln = $in->next_aln;
71 $protml->alignment($aln);
73 my ($rc,$results) = $protml->run();
74 ok($rc,1);
75 my $r = $results->next_result;
76 ok($r);
77 my @trees;
78 while( my $t = $r->next_tree ) { 
79     push @trees, $t;
81 ok(@trees,1);
82 ok($r->model, 'JTT');
83 ok($r->search_space,50);
84 ok($trees[0]->score, -453.1);
85 ok($protml->error_string !~ /Error/); # we don't expect any errors;