Move HMMER related modules, tests, and programs to new distribution.
[bioperl-live.git] / t / LocalDB / Index / Blast.t
bloba3fac5eaef0d0f8baf69a96dc5dbd1465f80a80e
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN {
7         use lib '.';
8         use Bio::Root::Test;
9         
10         test_begin(-tests => 26,
11                                   -requires_module => 'IO::String');
12     
13         use_ok('Cwd');
14         use_ok('Bio::SearchIO');
15         use_ok('Bio::Index::Blast');
18 # BLASTP
20 my $index = Bio::Index::Blast->new(-filename => 'Wibbl',
21                                                                                           -write_flag => 1);
22 ok($index);
24 $index->make_index(test_input_file('multi_blast.bls'));
25 ($index->dbm_package eq 'SDBM_File') ? 
26         (ok(-e "Wibbl.pag" && -e "Wibbl.dir")) :
27         (ok(-e "Wibbl"));
29 foreach my $id ( qw(CATH_RAT PAPA_CARPA) ) {
30         my $fh = $index->get_stream($id);
31         ok($fh);
32         ok( ! eof($fh) );
33         my $report = Bio::SearchIO->new(-noclose => 1,
34                                    -format  => 'blast',
35                                    -fh      => $fh);
36         my $result = $report->next_result;
37         like($result->query_name, qr/$id/);
38         ok( $result->next_hit);
39         
40         like( $index->fetch_report($id)->query_name, qr/$id/);
42 # ActivePerl will not allow deletion if the tie-hash is still active
43 $index->DESTROY;
44 unlink qw( Wibbl Wibbl.pag Wibbl.dir );
46 # RPS-BLAST
48 $index = Bio::Index::Blast->new(-filename => 'Wibbl.index',
49                                                                                   -write_flag => 1);
50 ok($index);
52 $index->make_index(test_input_file('rpsblast.bls'));
54 foreach my $id ( qw(orf20 orf40) ) {
55         my $fh = $index->get_stream($id);
56         ok($fh);
57         ok( ! eof($fh) );
58         my $report = Bio::SearchIO->new(-noclose => 1,
59                                    -format  => 'blast',
60                                    -fh      => $fh);
61         my $result = $report->next_result;
62         like($result->query_name, qr/$id/);
63         ok( $result->next_hit);
64         
65         like( $index->fetch_report($id)->query_name, qr/$id/);
67 # ActivePerl will not allow deletion if the tie-hash is still active
68 $index->DESTROY;
69 unlink qw( Wibbl.index Wibbl.index.pag Wibbl.index.dir );