New INSTALL.WIN doc (from wiki)
[bioperl-live.git] / t / SeqHound_DB.t
blob898fb42e6cbb38c0fb313aa19f33da4685b281e7
1 # This is -*-Perl-*- code
2 ## Bioperl Test Harness Script for Modules
3 ##
4 # This test file is adapted from EMBL_DB.t
6 # Before `make install' is performed this script should be runnable with
7 # `make test'. After `make install' it should work as `perl SeqHound_DB.t'
9 use strict;
10 use vars qw($NUMTESTS $DEBUG);
11 $DEBUG = $ENV{'BIOPERLDEBUG'} || 0;
13 my $error;
15 BEGIN {
16         use Test;
18         $NUMTESTS = 14;
19         plan tests => $NUMTESTS;
20         eval { require IO::String;
21                          require LWP::UserAgent;
22                  };
23         if( $@ ) {
24                 for( $Test::ntest..$NUMTESTS ) {
25                         skip("IO::String or LWP::UserAgent not installed. This means the Bio::DB::* modules are not usable. Skipping tests",1);
26                 }
27                 $error = 1;
28         }
30 END {
31         foreach ( $Test::ntest..$NUMTESTS) {
32                 skip('Unable to run all of the SeqHound_DB tests',1);
33         }
34         unlink $Bio::DB::SeqHound::LOGFILENAME if -f $Bio::DB::SeqHound::LOGFILENAME;
37 if( $error ) {
38     exit(0);
41 use Bio::DB::SeqHound;
43 my $verbose = -1;
45 ## End of black magic.
47 ## Insert additional test code below but remember to change
48 ## the print "1..x\n" in the BEGIN block to reflect the
49 ## total number of tests that will be run. 
51 my ($db,$seq,$seqio);
52 # get a single seq
54 $seq = $seqio = undef;
56 eval { 
57     $db = new Bio::DB::SeqHound(-verbose=>$verbose);
58     ok(defined($seq = $db->get_Seq_by_acc('J00522')));
59     ok( $seq->length, 408); 
60     ok defined ($db->request_format('fasta'));
61     ok(defined($seq = $db->get_Seq_by_acc('NP_862707')));
62     ok( $seq->accession, 'NP_862707');
63     ok( $seq->length, 227); 
64     ok( defined($db = new Bio::DB::SeqHound(-verbose=>$verbose, 
65                                         -retrievaltype => 'tempfile')));
66     ok(defined($seqio = $db->get_Stream_by_id(['BTACHRE'])));
67     undef $db; # testing to see if we can remove db
68     ok( defined($seq = $seqio->next_seq()));
69     ok( $seq->length, 1621);
72 if ($@) {
73     if( $DEBUG ) {
74         warn "Warning: Couldn't connect to SeqHound with Bio::DB::SeqHound.pm!\n$@";
75     }
76     foreach ( $Test::ntest..$NUMTESTS) { 
77          skip('Skip could not connect to seqhound',1);
78      }
79     exit(0);
82 $seq = $seqio = undef;
84 eval {
85     $db = Bio::DB::SeqHound->new(-verbose => $verbose,
86                             -retrievaltype => 'tempfile',
87                             -format => 'genbank'
88                             ); 
89     ok( defined($seqio = $db->get_Stream_by_acc(['J00522', 'AF303112', 'J02231'])));
90         ok($seqio->next_seq->length, 408);
91     ok($seqio->next_seq->length, 1611);
92     ok($seqio->next_seq->length, 200);
95 if ($@) {
96     if( $DEBUG ) {
97         warn "Batch access test failed.\nError: $@\n";
98     }
99     foreach ( $Test::ntest..$NUMTESTS ) { skip('could not connect to seqhound',1); }