added bio::ext support
[bioperl-live.git] / t / Blast.t
blob3717aa412e0220ecbf13ccebccfbbd052600474a
1 ## Bioperl Test Harness Script for Modules
2 ## $Id$
4 # Before `make install' is performed this script should be runnable with
5 # `make test'. After `make install' it should work as `perl test.t'
7 #-----------------------------------------------------------------------
8 # Test script for Bio::Tools::Blast.pm
9 # Steve A. Chervitz, sac@genome.stanford.edu
10 # Fairly rudimentary. Only tests parsing code.
11 # Strategy for this test was borrowed from L. Stein's BoulderIO package.
13 ## perl test harness expects the following output syntax only!
14 ## 1..3
15 ## ok 1  [not ok 1 (if test fails)]
16 ## 2..3
17 ## ok 2  [not ok 2 (if test fails)]
18 ## 3..3
19 ## ok 3  [not ok 3 (if test fails)]
21 ## etc. etc. etc. (continue on for each tested function in the .t file)
22 #-----------------------------------------------------------------------
24 BEGIN { 
25     $| = 1; print "1..29\n"; 
26     $testout = "blast.t.out";  # output from this script.
27     $expectedout = 't/expected.blast.out';
28     unlink $testout;
29     $^W = 0; 
31 END {
32 #   print "not ok 1\n" unless $loaded;
33 #   unlink $testout;  # commented out since you may want to check it...
36 use lib '../';
37 use Bio::Tools::Blast;
39 sub test ($$;$) {
40     my($num, $true,$msg) = @_;
41     print($true ? "ok $num\n" : "not ok $num $msg\n");
43 my($s,@s);
45 open (OUT,">$testout");
47 test 1, $blast = Bio::Tools::Blast->new(-file   =>'t/blast.report',
48                                         -signif => 1e-5,
49                                         -parse  => 1,
50                                         -stats  => 1,
51                                         -check_all_hits => 1,
52                                         );
53 test 2, $blast->display();
54 test 3, $blast->is_signif;
55 test 4, $blast->signif eq '1.0e-05', "Signif: ".$blast->signif;
56 test 5, $blast->num_hits == 4;
57 test 6, $blast->length == 504;
58 test 7, $blast->program eq 'TBLASTN';
59 test 8, $blast->query eq 'gi|1401126';
60 test 9, $blast->hit->name eq 'U49928/HSU49928';
61 test 10, $blast->hit->length == 3096;
63 @hits  = $blast->hits;
65 test 11, $hits[0]->expect eq '0.0';
66 test 12, $hits[1]->expect eq '4e-07';
67 test 13, $hits[2]->expect eq '1e-05';
68 test 14, $hits[1]->frac_identical eq '0.25';
69 test 15, $hits[1]->hsp->frac_conserved eq '0.43';
70 test 16, $hits[1]->hsp->score == 137;
71 test 17, $hits[1]->hsp->bits eq '57.8';
73 # Sequence index testing.
74 test 18, @inds = $hits[1]->hsp->seq_inds('query', 'iden', 1);
75 test 19, $inds[0] eq '66-68';
77 # Output testing.
78 test 20, print OUT $blast->table_labels;
79 test 21, print OUT $blast->table;
80 print OUT "\n\n";
81 test 22, print OUT $blast->table_labels_tiled;
82 test 23, print OUT $blast->table_tiled;
83 print OUT "\n\n";
84 close OUT;
86 test 24, -s $blast->file;
87 test 25, $cfile = $blast->compress_file;
88 test 26, -s $cfile and -B $cfile, "Can't compress Blast file";
89 test 27, $ufile = $blast->uncompress_file;
90 test 28, -s $ufile and -T $ufile, "Can't uncompress Blast file";
92 print "checking expected output...\n";
94 test 29, system('diff', $testout, $expectedout) == 0, 
95     "diff $testout $expectedout";