[bug 2262]
[bioperl-live.git] / t / SeqHound_DB.t
bloba953ae564a233dcfedfbb7dc75b32aa598c8f1ff
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN {
7         use lib 't/lib';
8     use BioperlTest;
9     
10     test_begin(-tests => 15,
11                            -requires_modules => [qw(IO::String LWP::UserAgent)],
12                            -requires_networking => 1);
13         
14         use_ok('Bio::DB::SeqHound');
17 END {
18         unlink $Bio::DB::SeqHound::LOGFILENAME if -f $Bio::DB::SeqHound::LOGFILENAME;
21 my $verbose = test_debug();
23 my ($db,$seq,$seqio);
24 # get a single seq
26 $seq = $seqio = undef;
28 SKIP: {
29     $db = Bio::DB::SeqHound->new(-verbose=>$verbose);
30     eval {ok(defined($seq = $db->get_Seq_by_acc('J00522')));};
31         skip('Could not connect to seqhound, skipping tests', 10) if $@;
32     is( $seq->length, 408); 
33     ok defined ($db->request_format('fasta'));
34     eval {ok(defined($seq = $db->get_Seq_by_acc('NP_862707')));};
35         skip('Could not connect to seqhound, skipping tests', 7) if $@;
36     is( $seq->accession, 'NP_862707');
37     is( $seq->length, 227); 
38     ok( defined($db = Bio::DB::SeqHound->new(-verbose=>$verbose, 
39                                         -retrievaltype => 'tempfile')));
40     eval {ok(defined($seqio = $db->get_Stream_by_id(['BTACHRE'])));};
41         skip('Could not connect to seqhound, skipping tests', 3) if $@;
42     undef $db; # testing to see if we can remove db
43     ok( defined($seq = $seqio->next_seq()));
44     is( $seq->length, 1621);
47 $seq = $seqio = undef;
49 SKIP: {
50     $db = Bio::DB::SeqHound->new(-verbose => $verbose,
51                             -retrievaltype => 'tempfile',
52                             -format => 'genbank'
53                             ); 
54     eval {ok( defined($seqio = $db->get_Stream_by_acc(['J00522', 'AF303112', 'J02231'])));};
55         skip('Could not connect to seqhound for batch test, skipping tests', 4) if $@;
56         is($seqio->next_seq->length, 408);
57     is($seqio->next_seq->length, 1611);
58     is($seqio->next_seq->length, 200);