1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: SearchIO.t 14995 2008-11-16 06:20:00Z cjfields $
10 test_begin(-tests => 154);
12 use_ok('Bio::SearchIO');
13 use_ok('Bio::Search::SearchUtils');
16 my ($searchio, $result,$iter,$hit,$hsp);
18 # test blasttable output
19 my @eqset = qw( c200-vs-yeast.BLASTN.m9);
20 $searchio = Bio::SearchIO->new(-file => test_input_file('c200-vs-yeast.BLASTN'),
22 $result = $searchio->next_result;
23 isa_ok($result,'Bio::Search::Result::ResultI');
24 my %ref = &Bio::Search::SearchUtils::result2hash($result);
25 is( scalar keys %ref, 67);
26 $searchio = Bio::SearchIO->new(-file => test_input_file('c200-vs-yeast.BLASTN.m8'),
27 -program_name => 'BLASTN',
28 -format => 'blasttable');
29 $result = $searchio->next_result;
30 my %tester = &Bio::Search::SearchUtils::result2hash($result);
31 is( scalar keys %tester, 67);
32 foreach my $key ( sort keys %ref ) {
33 is($tester{$key}, $ref{$key},$key);
36 # test WU-BLAST blasttable output
37 $searchio = Bio::SearchIO->new(-file => test_input_file('test1.wublastp'),
39 $result = $searchio->next_result;
40 isa_ok($result,'Bio::Search::Result::ResultI');
41 my %wuref = &Bio::Search::SearchUtils::result2hash($result);
42 is( scalar keys %wuref, 31);
43 $searchio = Bio::SearchIO->new(-file => test_input_file('test1.blasttab3'),
44 -program_name => 'BLASTP',
45 -format => 'blasttable');
46 $result = $searchio->next_result;
47 my %wutester = &Bio::Search::SearchUtils::result2hash($result);
48 is( scalar keys %wutester, 31);
49 foreach my $key ( sort keys %ref ) {
50 is($wutester{$key}, $wuref{$key},$key);
53 # BLAST 2.2.18+ tabular output (has 13 columns instead of 12)
54 $searchio = Bio::SearchIO->new(-format => 'blasttable',
55 -file => test_input_file('2008.blasttable'));
57 while(my $res = $searchio->next_result) {
58 is($res->query_name, 'gi|1786183|gb|AAC73113.1|');
59 is($res->algorithm, 'BLASTP');
60 is($res->algorithm_version, '2.2.18+');
61 my $hit = $res->next_hit;
62 is($hit->name, 'gi|34395933|sp|P00561.2|AK1H_ECOLI');
63 $hit = $res->next_hit;
64 my $hsp = $hit->next_hsp;
66 is($hsp->evalue, '2e-91');
67 is($hsp->start('hit'), 16);
68 is($hsp->end('hit'), 805);
69 is($hsp->start('query'), 5);
70 is($hsp->end('query'), 812);
71 is($hsp->length, 821);