New INSTALL.WIN doc (from wiki)
[bioperl-live.git] / t / RefSeq.t
blobce0701489069a587e0b4adce516e685cd24574bb
1 # This is -*-Perl-*- code
2 ## Bioperl Test Harness Script for Modules
3 ##
4 # $Id$
6 # Before `make install' is performed this script should be runnable with
7 # `make test'. After `make install' it should work as `perl test.t'
9 use strict;
10 use vars qw($NUMTESTS $DEBUG);
11 $DEBUG = $ENV{'BIOPERLDEBUG'} || 0;
12 my $error;
14 BEGIN { 
15         # to handle systems with no installed Test module
16         # we include the t dir (where a copy of Test.pm is located)
17         # as a fallback
18         eval { require Test; };
19         $error = 0;
20         if( $@ ) {
21                 use lib 't';
22         }
23         use Test;
25         $NUMTESTS = 13;
26         plan tests => $NUMTESTS;
27         eval { require IO::String; 
28                          require LWP::UserAgent; 
29                          require HTTP::Request::Common;
30                  };
31         if( $@ ) {
32                 for( $Test::ntest..$NUMTESTS ) {
33                         skip("IO::String,LWP::UserAgent, or HTTP::Request::Common not installed. This means the Bio::DB::* modules are not usable. Skipping tests",1);
34                 }
35                 $error = 1;
36         }
39 END {
40         for ( $Test::ntest..$NUMTESTS ) {
41                 skip("Unable to complete RefSeq tests - set env variable BIOPERLDEBUG to test",1);
42         }
45 if( $error ==  1 ) {
46     exit(0);
49 require  Bio::DB::RefSeq;
50 require  Bio::DB::GenBank;
51 require  Bio::DB::EMBL;
53 my $testnum;
54 my $verbose = 0;
56 ## End of black magic.
58 ## Insert additional test code below but remember to change
59 ## the print "1..x\n" in the BEGIN block to reflect the
60 ## total number of tests that will be run. 
62 my ($db,$seq,$db2,$seq2,$seqio);
63 # get a single seq
65 $seq = $seqio = undef;
67 #test redirection from GenBank and EMBL
68 $verbose = -1;
69 #GenBank
70 ok $db = new Bio::DB::GenBank('-verbose'=>$verbose) ;     
71 #EMBL
72 ok $db2 = new Bio::DB::EMBL('-verbose'=>$verbose) ;     
74 eval {
75     $seq = $db->get_Seq_by_acc('NT_006732');
76     $seq2 = $db2->get_Seq_by_acc('NT_006732');
78 ok $@;
80 exit unless $DEBUG;
81 eval {
82     ok($seq = $db->get_Seq_by_acc('NM_006732'));
83     ok($seq && $seq->length eq 3775);
84     ok $seq2 = $db2->get_Seq_by_acc('NM_006732');
85     ok($seq2 && $seq2->length eq 3775);
88 if ($@) {
89     if( $DEBUG ) {
90         print STDERR "Warning: Couldn't connect to RefSeq with Bio::DB::RefSeq.pm!\n" . $@;
91     }
92     exit(0);
97 $verbose = 0;
99 eval { 
100     ok defined($db = new Bio::DB::RefSeq(-verbose=>$verbose)); 
101     ok(defined($seq = $db->get_Seq_by_acc('NM_006732')));
102     ok( $seq->length, 3775);
103     ok defined ($db->request_format('fasta'));
104     ok(defined($seq = $db->get_Seq_by_acc('NM_006732')));
105     ok( $seq->length, 3775); 
108 if ($@) {
109     if( $DEBUG ) {
110         print STDERR "Warning: Couldn't connect to RefSeq with Bio::DB::RefSeq.pm!\n" . $@;
111     }
112     exit(0);