Supply TEMPLATE and SUFFIX for temporary query sequence files.
[bioperl-run.git] / t / Hyphy.t
blobfd5ea00dd1f9c0c6ae0a505c16eb8ab4f317616b
1 # This is -*-Perl-*- code
2 ## Bioperl Test Harness Script for Modules
3 ##
4 # $Id$
6 use strict;
8 BEGIN {
9     use Bio::Root::Test;
10     test_begin(-tests => 10,
11                -requires_module =>'IO::String');
13     use_ok('Bio::Tools::Run::Phylo::Hyphy::SLAC');
14     use_ok('Bio::Tools::Run::Phylo::Hyphy::FEL');
15     use_ok('Bio::Tools::Run::Phylo::Hyphy::REL');
16     use_ok('Bio::Tools::Run::Phylo::Hyphy::Modeltest');
17     use_ok('Bio::Tools::Run::Phylo::Hyphy::BatchFile');
21 SKIP: {
22         my $rel = Bio::Tools::Run::Phylo::Hyphy::REL->new();
24         test_skip(-requires_executable => $rel,
25                   -tests => 5);
27         my $alignio = Bio::AlignIO->new(-format => 'fasta',
28                                         -file   => 't/data/hyphy1.fasta');
30         my $treeio = Bio::TreeIO->new(-format => 'newick',
31                                       -file   => 't/data/hyphy1.tree');
33         my $aln = $alignio->next_aln;
34         my $tree = $treeio->next_tree;
35         my $debug = test_debug();
36         my ($rc,$results);
38         $rel->alignment($aln);
39         $rel->tree($tree);
40         ($rc,$results) = $rel->run();
41         if (($rc == 0) && ($debug == 1)){
42             warn("ERROR in REL module $rc:" . $rel->error_string() . "\n");
43         }
44         ok ($rc != 0, "REL module");
46         my $fel = Bio::Tools::Run::Phylo::Hyphy::FEL->new();
47         $fel->alignment($aln);
48         $fel->tree($tree);
49         ($rc,$results) = $fel->run();
50         if (($rc == 0) && ($debug == 1)){
51             warn("ERROR in FEL module $rc:" . $fel->error_string() . "\n");
52         }
53         ok (defined($results->{'LRT'}), "FEL module");
55         my $modeltest = Bio::Tools::Run::Phylo::Hyphy::Modeltest->new();
56         $modeltest->alignment($aln);
57         $modeltest->tree($tree);
58         ($rc,$results) = $modeltest->run();
59         if (($rc == 0) && ($debug == 1)){
60             warn("ERROR in Modeltest module $rc:" . $modeltest->error_string() . "\n");
61         }
62         ok (defined($results->{'AIC'}), "Modeltest module");
64         my $bf_exec = Bio::Tools::Run::Phylo::Hyphy::BatchFile->new(
65                       -params => {'bf' => "ModelTest.bf",
66                                   'order' => [$aln, $tree, '4', 'AIC Test', ""]}
67                       );
68         $bf_exec->alignment($aln);
69         $bf_exec->tree($tree);
70         my ($tfh, $t) = $bf_exec->io->tempfile;
71         $bf_exec->set_parameter(5, $t);
72         $bf_exec->version();
73         ($rc,$results) = $bf_exec->run();
74         if (($rc == 0) && ($debug == 1)){
75             warn("ERROR in Batchfile module $rc:" . $bf_exec->error_string() . "\n");
76         }
77         ok ($rc != 0, "Batchfile module");
79         my $slac = Bio::Tools::Run::Phylo::Hyphy::SLAC->new();
80         $slac->alignment($aln);
81         $slac->tree($tree);
82         ($rc,$results) = $slac->run();
83         if (($rc == 0) && ($debug == 1)){
84             warn("ERROR in SLAC module $rc:" . $slac->error_string() . "\n");
85         }
86         ok (defined($results->{'Observed NS Changes'}), "SLAC module");