tests pass, find the right nodes more explicitly
[bioperl-run.git] / t / Exonerate.t
blob9f60c671a210d361abdd440f9c7d12242b1669c9
1 # -*-Perl-*-
2 ## Bioperl Test Harness Script for Modules
5 use strict;
6 BEGIN {
7     eval { require Test; };
8     if( $@ ) {
9         use lib 't';
10     }
11     use Test;
12     use vars qw($NTESTS);
13     $NTESTS = 88;
14     plan tests => $NTESTS;
16 use Bio::Tools::Run::Alignment::Exonerate;
17 use Bio::Root::IO;
19 END {
20     for ( $Test::ntest..$NTESTS ) {
21         skip("exonerate program not found. Skipping. (Be sure you have installed Exonerate)",1);
22     }
25 ok(1);
26 my $verbose = $ENV{BIOPERLDEBUG} || -1;
28 my $query= Bio::Root::IO->catfile("t","data","exonerate_cdna.fa");
29 my $target= Bio::Root::IO->catfile("t","data","exonerate_genomic.fa");
30 my $targetrev= Bio::Root::IO->catfile("t","data","exonerate_genomic_rev.fa");
32 my $run = Bio::Tools::Run::Alignment::Exonerate->new(-verbose  => $verbose,
33                                                      arguments=>'--model est2genome --bestn 1');
34 exit(0) unless( $run->executable );
36 ok $run->isa('Bio::Tools::Run::Alignment::Exonerate');
38 my $searchio= $run->run($query,$target);
39 ok $searchio->isa("Bio::SearchIO");
40 my @expect = ( [qw(29   268     4 242)],# target-start t-end query-start q-end
41                [qw(526  646   243 363)],
42                [qw(964 1056   364 456)],
43                [qw(1770 1923  457 610)],
44                [qw(2250 2479  611 840 )],
45                [qw(2565 2687  841 963)],
46                [qw(2769 3074  964 1279)] );
47 RESULT: while(my $result = $searchio->next_result){
48   while( my $hit = $result->next_hit ) {
49 #      ok($hit->start('hit'), 29);
50 #      ok($hit->end('hit'), 3074);
51       my $i = 0;
52     while( my $hsp = $hit->next_hsp ) { 
53         ok ($hsp->hit->strand, 1);
54         ok ($hsp->query->strand, 1);
55         ok ($hsp->hit->start,$expect[$i]->[0]);
56         ok ($hsp->hit->end,$expect[$i]->[1]);
57         ok ($hsp->query->start,$expect[$i]->[2]);
58         ok ($hsp->query->end,$expect[$i]->[3]); 
59         $i++;
60         if( $verbose > 0 ) {
61             warn("TARGET:", $hsp->hit->location->to_FTstring, "\n");
62             warn("QUERY: ",$hsp->query->location->to_FTstring, "\n");
63         }
64     }
65       last; # only show a single HIT
66   }
67   last;
71 $searchio= $run->run($query,$targetrev);
72 ok $searchio->isa("Bio::SearchIO");
73 my @expectrev = ( [qw(28   333   964 1279)],# target-start t-end query-start q-end
74                   [qw(415  537   841 963)],
75                   [qw(623 852    611 840)],
76                   [qw(1179 1332  457 610)],
77                   [qw(2046 2138  364  456)],
78                   [qw(2456 2576  243 363)],
79                   [qw(2834 3073  4 242)] );
80 RESULT: while(my $result = $searchio->next_result){
81     while( my $hit = $result->next_hit ) {
82       my $i = 0;
83     while( my $hsp = $hit->next_hsp ) { 
84         ok ($hsp->hit->strand, 1);
85         ok ($hsp->query->strand, -1);
86         ok ($hsp->hit->start,$expectrev[$i]->[0]);
87         ok ($hsp->hit->end,$expectrev[$i]->[1]);
88         ok ($hsp->query->start,$expectrev[$i]->[2]);
89         ok ($hsp->query->end,$expectrev[$i]->[3]);      
90         $i++;
91         if( $verbose > 0 ) {
92             warn("TARGET:", $hsp->hit->location->to_FTstring, "\n");
93             warn("QUERY: ",$hsp->query->location->to_FTstring, "\n");
94         }
95     }
96       last; # only show a single HIT
97   }
98   last;