Merge pull request #40 from hettling/fast-bootstrap
[bioperl-run.git] / t / LVB.t
blob8ba3775f7ec687124ec9ecff0ff16cd518f53735
1 # -*-Perl-*-
2 ## Bioperl Test Harness Script for Modules
4 use vars qw($DEBUG );
5 $DEBUG = test_debug();
7 use strict;
8 BEGIN {
9     use Bio::Root::Test;
10     test_begin(-tests => 19);
11         use_ok('Bio::Tools::Run::Phylo::LVB');
12         use_ok('Bio::AlignIO');
15 my $tree_factory = Bio::Tools::Run::Phylo::LVB->new();
16 isa_ok $tree_factory, 'Bio::Tools::Run::Phylo::LVB';
18 SKIP: {
19         test_skip(-requires_executable => $tree_factory,
20                           -tests => 16);
22         my $default_format = "interleaved";
23         my $format = $tree_factory->format;
24         is $format, $default_format, "default is wrong for format parameter";
25         $format = "sequential";
26         $tree_factory->format($format);
27         my $new_format = $tree_factory->format();
28         is $new_format, $format, "couldn't set format parameter";
29         $format = "interleaved";
30         $tree_factory->format($format);
31         $new_format = $tree_factory->format();
32         is $new_format, $format, "couldn't reset format parameter";
33         
34         my $default_gaps = "unknown";
35         my $gaps = $tree_factory->gaps;
36         is $gaps, $default_gaps, "default is wrong for gaps parameter";
37         $gaps = "fifthstate";
38         $tree_factory->gaps($gaps);
39         my $new_gaps = $tree_factory->gaps();
40         is $new_gaps, $gaps, "couldn't set gaps parameter";
41         $gaps = "unknown";
42         $tree_factory->gaps($gaps);
43         $new_gaps = $tree_factory->gaps();
44         is $new_gaps, $gaps, "couldn't reset gaps parameter";
45         
46         my $default_seed = "";
47         my $seed = $tree_factory->seed;
48         is $seed, $default_seed, "default is wrong for seed parameter";
49         $seed = "96901";
50         $tree_factory->seed($seed);
51         my $new_seed = $tree_factory->seed();
52         is $new_seed, $seed, "couldn't set seed parameter";
53         
54         my $default_duration = "slow";
55         my $duration = $tree_factory->duration;
56         is $duration, $default_duration, "default is wrong for duration parameter";
57         $duration = "fast";
58         $tree_factory->duration($duration);
59         my $new_duration = $tree_factory->duration();
60         is $new_duration, $duration, "couldn't set duration parameter";
61         $duration = "slow";
62         $tree_factory->duration($duration);
63         $new_duration = $tree_factory->duration();
64         is $new_duration, $duration, "couldn't reset duration parameter";
65         
66         my $default_bootstraps = 0;
67         my $bootstraps = $tree_factory->bootstraps;
68         is $bootstraps, $default_bootstraps, "default is wrong for bootstraps parameter";
69         $bootstraps = "10000";
70         $tree_factory->bootstraps($bootstraps);
71         my $new_bootstraps = $tree_factory->bootstraps();
72         is $new_bootstraps, $bootstraps, "couldn't set bootstraps parameter";
73         $bootstraps = 0;
74         $tree_factory->bootstraps($bootstraps);
75         $new_bootstraps = $tree_factory->bootstraps();
76         $new_bootstraps = $tree_factory->bootstraps();
77         is $new_bootstraps, $bootstraps, "couldn't reset seed parameter";
78         
79         my $bequiet = 1;
80         $tree_factory->quiet($bequiet);  # Suppress LVB messages to terminal 
81         
82         my @trees;
83         
84         # TEST 17
85         $tree_factory->format("sequential");
86         my $inputfilename = test_input_file("lvb_sequential.phy");
87         @trees = $tree_factory->create_tree($inputfilename);
88         is scalar(@trees), 3, "create_tree failed to create array of trees from file";
89         
90         # TEST 18
91         $inputfilename = test_input_file("lvb.fa");
92         my $align_in = Bio::AlignIO->new(-file => $inputfilename, -format => "fasta");
93         my $align_obj = $align_in->next_aln;
94         @trees = $tree_factory->run($align_obj);
95         is scalar(@trees), 3, "run failed to create array of trees from object";
96         
97         $tree_factory->gaps("fifthstate");
98         @trees = $tree_factory->run($align_obj);
99         is scalar(@trees), 1, "run failed to create tree with fifthstate on";
100         
101         $tree_factory->bootstraps(7);
102         @trees = $tree_factory->run($align_obj);
103         my $enough_trees = "no";
104         $enough_trees = "yes" if scalar(@trees) >= 7;
105         is $enough_trees, "yes", "run failed to create enough bootstrap trees";