tag fourth (and hopefully last) alpha
[bioperl-live.git] / branch-1-6 / t / SearchIO / waba.t
blob72f02ef6844ac68a9716485a79b0ef995c2097a1
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: WABA.t 11525 2007-06-27 10:16:38Z sendu $
4 use strict;
6 BEGIN { 
7     use lib '.';
8     use Bio::Root::Test;
9     
10     test_begin(-tests => 64);
11         
12     use_ok('Bio::SearchIO');
15 my $wabain = Bio::SearchIO->new(
16     -format => 'waba',
17     -file   => test_input_file('test.waba')
20 isa_ok($wabain, 'Bio::SearchIO') ;
22 # These won't look the same as the WABA file because Jim's code is 0 based
23 # while we (bioperl) are 1 based.
24 my @results = (
25     [
26         'U57623',
27         'pair1_hs.fa',
28         'pair1_mm.fa',
29         [
30             'U02884',
31             3,
32             [qw(3833 34 2972 1 243 3688 1 40.9)],
33             [qw(4211 3022 6914 1 3705 6848 1 43.7)],
34             [qw(2218 7004 9171 1 6892 8712 1 50.3)],
35         ],
36     ],
37     [
38         'X57152', 'pair9_hs.fa',
39         'pair9_mm.fa', [ 'X80685', 1, [qw(7572 4 5845 1 632 7368 1 46.8)], ],
40     ]
43 while ( my $wabar = $wabain->next_result ) {
44     my @r = @{ shift @results };
45     is( $wabar->query_name,     shift @r, 'query_name'     );
46     is( $wabar->query_database, shift @r, 'query database' );
47     is( $wabar->database_name,  shift @r, 'database name'  );
49     while ( my $wabah = $wabar->next_hit ) {
50         my (@h) = @{ shift @r };
51         is( $wabah->name, shift @h, 'name' );
52         is( $wabah->hsps(), shift @h, 'hsps' );
54         while ( my $wabahsp = $wabah->next_hsp ) {
55             my (@hsp) = @{ shift @h };
56             is( $wabahsp->length('total'),        shift @hsp , 'total length');
57             is( $wabahsp->query->start,           shift @hsp , 'start'       );
58             is( $wabahsp->query->end,             shift @hsp , 'end'         );
59             is( $wabahsp->strand('query'),        shift @hsp , 'strand'      );
60             is( $wabahsp->start('hit'),           shift @hsp , 'start'       );
61             is( $wabahsp->end('subject'),         shift @hsp , 'end'         );
62             is( $wabahsp->subject->strand,        shift @hsp, 'strand'       );
63             is( length( $wabahsp->query_string ), $wabahsp->length('total') , 'query string');
64             is( length( $wabahsp->hit_string ),   $wabahsp->length('total') , 'hit_string'  );
65             is( length( $wabahsp->hmmstate_string ),
66                 $wabahsp->length('total') , 'hmmstate string');
67             my $hs = $wabahsp->hit_string;
68             is( $wabahsp->gaps('hit'), $hs =~ tr/\-// );
69             my $qs = $wabahsp->query_string;
70             is( $wabahsp->gaps('query'), $qs =~ tr/\-// );
71             is( sprintf( "%.1f", $wabahsp->percent_identity ), shift @hsp );
72         }
73     }