New INSTALL.WIN doc (from wiki)
[bioperl-live.git] / t / Molphy.t
blob936abe3b0036349b805b9994704d26bd089bc574
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 $error);
12 BEGIN { 
13         # to handle systems with no installed Test module
14         # we include the t dir (where a copy of Test.pm is located)
15         # as a fallback
16         eval { require Test; };
17         $error = 0;
18         if( $@ ) {
19                 use lib 't';
20         }
21         use Test;
23         $NUMTESTS = 17;
24         plan tests => $NUMTESTS;
25         eval { require IO::String;
26                          require Bio::Tools::Phylo::Molphy;};
27         if( $@ ) {
28                 warn "No IO::String installed\n";
29                 $error = 1;
30         }
33 END { 
34         foreach ( $Test::ntest .. $NUMTESTS ) {
35                 skip("Unable to run the Molphy tests",1);
36         }
40 exit(0) if( $error );
42 my $testnum;
43 my $verbose = 0;
45 ## End of black magic.
47 ## Insert additional test code below but remember to change
48 ## the print "1..x\n" in the BEGIN block to reflect the
49 ## total number of tests that will be run. 
51 my $inmolphy = new Bio::Tools::Phylo::Molphy(-file => 't/data/lysozyme6.simple.protml');
52 ok($inmolphy);
53 my $r = $inmolphy->next_result;
54 ok($r);
55 ok($r->model, 'JTT');
56 ok($r->search_space,50);
57 my @trees;
58 while( my $t = $r->next_tree ) { 
59     push @trees, $t;
61 ok(@trees,5);
62  $inmolphy = new Bio::Tools::Phylo::Molphy(-file => 't/data/lysozyme6.protml');
63 ok($inmolphy);
64 $r = $inmolphy->next_result;
65 ok($r->model, 'JTT');
66 ok($r->search_space,50);
67 @trees = ();
68 while( my $t = $r->next_tree ) { 
69     push @trees, $t;
71 ok(@trees,5);
73 ok($trees[0]->score, -1047.8);
74 ok($trees[-1]->id, 9);
76 my $tpm = $r->transition_probability_matrix;
77 ok($tpm->{'Val'}->{'Val'}, -122884);
78 ok($tpm->{'Ala'}->{'Arg'}, 2710);
80 my $sub_mat = $r->substitution_matrix;
81 ok($sub_mat->{'Val'}->{'Tyr'}, 50);
82 ok($sub_mat->{'Arg'}->{'Ile'}, 72);
83 ok($sub_mat->{'Met'}->{'Met'}, '');
85 my %fmat = $r->residue_frequencies();
86 ok($fmat{'D'}->[0], 0.052);