sync with main trunk
[bioperl-live.git] / t / SearchIO / exonerate.t
blob3912f66b5d80a6f1c9977bdd47bc7a4f882534f2
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: SearchIO_exonerate.t 11525 2007-06-27 10:16:38Z sendu $
4 use strict;
6 BEGIN {
7     use lib '.';
8     use Bio::Root::Test;
10     test_begin( -tests => 49 );
12     use_ok('Bio::SearchIO');
15 my ( $searchio, $result, $hit, $hsp );
17 $searchio = Bio::SearchIO->new(
18     -file   => test_input_file('testdat.exonerate'),
19     -format => 'exonerate'
21 my @data = (
22     [
23         qw(ln27 416 Contig124 939
24           293 416 -1
25           1   124 1
27           107 292 -1
28           178 363 1
30           66 106 -1
31           899 939 1
32           )
33     ],
34     [
35         qw(ln74 644 Contig275 1296
36           601 644 -1
37           901 944 1
39           436 600 -1
40           998 1162    1
42           386 435 -1
43           1247 1296 1
45           )
46     ]
49 my $val;
51 while ( my $r = $searchio->next_result ) {
52     my $d = shift @data;
53     is( $r->query_name, shift @$d );
54   SKIP: {
55         $val = shift @$d;
56         skip( 'no query length available in default output', 1 );
57         is( $r->query_length, $val );
58     }
60     my $h = $r->next_hit;
61     is( $h->name, shift @$d );
62   SKIP: {
63         $val = shift @$d;
64         skip( 'no hit length available in default output', 1 );
65         is( $h->length, $val );
66     }
67     while ( my $hsp = $h->next_hsp ) {
68         is( $hsp->query->start,  shift @$d );
69         is( $hsp->query->end,    shift @$d );
70         is( $hsp->query->strand, shift @$d );
72         is( $hsp->hit->start,  shift @$d );
73         is( $hsp->hit->end,    shift @$d );
74         is( $hsp->hit->strand, shift @$d );
75     }
78 # bug 2346
80 my @cts = (7, 1);
82 $searchio = Bio::SearchIO->new(
83    -format => 'exonerate',
84    -file   => test_input_file('exonerate.output.works'),
86 parse($searchio);
88 $searchio = Bio::SearchIO->new(
89    -format => 'exonerate',
90    -file   => test_input_file('exonerate.output.dontwork'),
92 parse($searchio);
94 sub parse {
95     my ($searchio) = @_;
96     while( my $r = $searchio->next_result ) {
97         my $hsp_ct = 0;
98         while(my $hit = $r->next_hit){
99             while(my $hsp = $hit->next_hsp){
100                 $hsp_ct++;
101             }
102         }
103         ok($r->query_name, "query_name");
104         is($hsp_ct, shift @cts);
105     }