Supply TEMPLATE and SUFFIX for temporary query sequence files.
[bioperl-run.git] / t / Exonerate.t
blobeb17a95e6036b777a615a5f018814f2612c6bf96
1 # -*-Perl-*-
2 ## Bioperl Test Harness Script for Modules
5 use strict;
6 BEGIN {
7     use Bio::Root::Test;
8     test_begin(-tests => 89);
9         use_ok('Bio::Tools::Run::Alignment::Exonerate');
12 my $verbose = test_debug() || -1;
14 my $query= test_input_file("exonerate_cdna.fa");
15 my $target= test_input_file("exonerate_genomic.fa");
16 my $targetrev= test_input_file("exonerate_genomic_rev.fa");
18 my $run = Bio::Tools::Run::Alignment::Exonerate->new(-verbose  => $verbose,
19                                                      arguments=>'--model est2genome --bestn 1');
20 SKIP: {
21         test_skip(-requires_executable => $run, -tests => 88);
23         isa_ok $run, 'Bio::Tools::Run::Alignment::Exonerate';
24         ok $run->version;
25         
26         my $searchio= $run->run($query,$target);
27         isa_ok $searchio, "Bio::SearchIO";
28         my @expect = ( [qw(29   268     4 242)],# target-start t-end query-start q-end
29                            [qw(526  646   243 363)],
30                            [qw(964 1056   364 456)],
31                            [qw(1770 1923  457 610)],
32                            [qw(2250 2479  611 840 )],
33                            [qw(2565 2687  841 963)],
34                            [qw(2769 3074  964 1279)] );
35         RESULT: while(my $result = $searchio->next_result){
36           while( my $hit = $result->next_hit ) {
37         #      ok($hit->start('hit'), 29);
38         #      ok($hit->end('hit'), 3074);
39                   my $i = 0;
40                 while( my $hsp = $hit->next_hsp ) {     
41                 is ($hsp->hit->strand, 1);
42                 is ($hsp->query->strand, 1);
43                 is ($hsp->hit->start,$expect[$i]->[0]);
44                 is ($hsp->hit->end,$expect[$i]->[1]);
45                 is ($hsp->query->start,$expect[$i]->[2]);
46                 is ($hsp->query->end,$expect[$i]->[3]); 
47                 $i++;
48                 if( $verbose > 0 ) {
49                         warn("TARGET:", $hsp->hit->location->to_FTstring, "\n");
50                         warn("QUERY: ",$hsp->query->location->to_FTstring, "\n");
51                 }
52                 }
53                   last; # only show a single HIT
54           }
55           last;
56         }
57         
58         
59         $searchio= $run->run($query,$targetrev);
60         isa_ok $searchio,"Bio::SearchIO";
61         my @expectrev;
62         if ($run->version >= 2 ) { # latest 2.0.0 version
63                 @expectrev = ( # target-start t-end query-start q-end
64                            [qw(2834 3073  4 242)],
65                            [qw(2456 2576  243 363)],
66                            [qw(2046 2138  364 456)],
67                            [qw(1179 1332  457 610)],
68                            [qw(623 852    611 840)],
69                            [qw(415  537   841 963)],
70                            [qw(28   333   964 1279)]
71                 );
72         } else { # version 1.4.0 presumably
73                 @expectrev = ( # target-start t-end query-start q-end
74                            [qw(28   333   964 1279)],
75                            [qw(415  537   841 963)],
76                            [qw(623 852    611 840)],
77                            [qw(1179 1332  457 610)],
78                            [qw(2046 2138  364  456)],
79                            [qw(2456 2576  243 363)],
80                            [qw(2834 3073  4 242)]
81                 );
82         
83         }
84         RESULT: while(my $result = $searchio->next_result){
85                 while( my $hit = $result->next_hit ) {
86                   my $i = 0;
87                 while( my $hsp = $hit->next_hsp ) {     
88                 is ($hsp->hit->strand, -1);
89                 is ($hsp->query->strand, 1);
90                 is ($hsp->hit->start,$expectrev[$i]->[0]);
91                 is ($hsp->hit->end,$expectrev[$i]->[1]);
92                 is ($hsp->query->start,$expectrev[$i]->[2]);
93                 is ($hsp->query->end,$expectrev[$i]->[3]);      
94                 $i++;
95                 if( $verbose > 0 ) {
96                         warn("TARGET:", $hsp->hit->location->to_FTstring, "\n");
97                         warn("QUERY: ",$hsp->query->location->to_FTstring, "\n");
98                 }
99                 }
100                   last; # only show a single HIT
101           }
102           last;
103         }