Fix tests; need to look at Analysis::soap::results()
[bioperl-run.git] / t / LVB.t
blob6f0ac9d710857b36bc76447e1c58f88e9ece0a76
1 # -*-Perl-*-
2 ## Bioperl Test Harness Script for Modules
4 use vars qw($DEBUG );
5 $DEBUG = $ENV{'BIOPERLDEBUG'} || 0;
7 use strict;
8 BEGIN {
9     eval { require Test; };
10     if( $@ ) { 
11         use lib 't';
12     }
13     use Test;
14     use vars qw($NTESTS);
15     $NTESTS = 20;
16     plan tests => $NTESTS;
19 use Bio::Tools::Run::Phylo::LVB;
20 use Bio::AlignIO;
21 END {     
22     for ( $Test::ntest..$NTESTS ) {
23         skip("LVB not found. Skipping.",1);
24     }
27 ok(1);
28 my $tree_factory = Bio::Tools::Run::Phylo::LVB->new();
29 ok $tree_factory->isa('Bio::Tools::Run::Phylo::LVB');
31 unless($tree_factory->executable){
32     warn("LVB program not found. Skipping tests $Test::ntest to $NTESTS.\n");
33     exit 0;
36 my $default_format = "interleaved";
37 my $format = $tree_factory->format;
38 ok $format, $default_format, "default is wrong for format parameter";
39 $format = "sequential";
40 $tree_factory->format($format);
41 my $new_format = $tree_factory->format();
42 ok $new_format, $format, "couldn't set format parameter";
43 $format = "interleaved";
44 $tree_factory->format($format);
45 $new_format = $tree_factory->format();
46 ok $new_format, $format, "couldn't reset format parameter";
48 my $default_gaps = "unknown";
49 my $gaps = $tree_factory->gaps;
50 ok $gaps, $default_gaps, "default is wrong for gaps parameter";
51 $gaps = "fifthstate";
52 $tree_factory->gaps($gaps);
53 my $new_gaps = $tree_factory->gaps();
54 ok $new_gaps, $gaps, "couldn't set gaps parameter";
55 $gaps = "unknown";
56 $tree_factory->gaps($gaps);
57 $new_gaps = $tree_factory->gaps();
58 ok $new_gaps, $gaps, "couldn't reset gaps parameter";
60 my $default_seed = "";
61 my $seed = $tree_factory->seed;
62 ok $seed, $default_seed, "default is wrong for seed parameter";
63 $seed = "96901";
64 $tree_factory->seed($seed);
65 my $new_seed = $tree_factory->seed();
66 ok $new_seed, $seed, "couldn't set seed parameter";
68 my $default_duration = "slow";
69 my $duration = $tree_factory->duration;
70 ok $duration, $default_duration, "default is wrong for duration parameter";
71 $duration = "fast";
72 $tree_factory->duration($duration);
73 my $new_duration = $tree_factory->duration();
74 ok $new_duration, $duration, "couldn't set duration parameter";
75 $duration = "slow";
76 $tree_factory->duration($duration);
77 $new_duration = $tree_factory->duration();
78 ok $new_duration, $duration, "couldn't reset duration parameter";
80 my $default_bootstraps = 0;
81 my $bootstraps = $tree_factory->bootstraps;
82 ok $bootstraps, $default_bootstraps, "default is wrong for bootstraps parameter";
83 $bootstraps = "10000";
84 $tree_factory->bootstraps($bootstraps);
85 my $new_bootstraps = $tree_factory->bootstraps();
86 ok $new_bootstraps, $bootstraps, "couldn't set bootstraps parameter";
87 $bootstraps = 0;
88 $tree_factory->bootstraps($bootstraps);
89 $new_bootstraps = $tree_factory->bootstraps();
90 $new_bootstraps = $tree_factory->bootstraps();
91 ok $new_bootstraps, $bootstraps, "couldn't reset seed parameter";
93 my $bequiet = 1;
94 $tree_factory->quiet($bequiet);  # Suppress LVB messages to terminal 
96 my @trees;
98 # TEST 17
99 $tree_factory->format("sequential");
100 my $inputfilename = Bio::Root::IO->catfile("t","data","lvb_sequential.phy");
101 @trees = $tree_factory->create_tree($inputfilename);
102 ok scalar(@trees), 3, "create_tree failed to create array of trees from file";
104 # TEST 18
105 $inputfilename = Bio::Root::IO->catfile("t","data","lvb.fa");
106 my $align_in = Bio::AlignIO->new(-file => $inputfilename, -format => "fasta");
107 my $align_obj = $align_in->next_aln;
108 @trees = $tree_factory->run($align_obj);
109 ok scalar(@trees), 3, "run failed to create array of trees from object";
111 $tree_factory->gaps("fifthstate");
112 @trees = $tree_factory->run($align_obj);
113 ok scalar(@trees), 1, "run failed to create tree with fifthstate on";
115 $tree_factory->bootstraps(7);
116 @trees = $tree_factory->run($align_obj);
117 my $enough_trees = "no";
118 $enough_trees = "yes" if scalar(@trees) >= 7;
119 ok $enough_trees, "yes", "run failed to create enough bootstrap trees";