1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 21,
11 -requires_modules => [qw(IO::String
13 HTTP::Request::Common)],
14 -requires_networking => 1);
16 use_ok('Bio::DB::Query::GenBank');
17 use_ok('Bio::DB::GenBank');
20 my %expected_lengths = (
30 my ($gb, $seq, $seqio, $seqin, $query);
33 ok $query = Bio::DB::Query::GenBank->new('-db' => 'nucleotide',
34 '-query' => 'Onchocerca volvulus[Organism]',
35 '-mindate' => '2002/1/1',
36 '-maxdate' => '2002/12/31'), 'Bio::DB::Query::GenBank';
38 cmp_ok $query->count, '>', 0;
39 my @ids = $query->ids;
41 is @ids, $query->count;
42 ok $gb = Bio::DB::GenBank->new('-delay' => 0);
43 eval {$seqio = $gb->get_Stream_by_query($query);};
44 skip "Couldn't connect to complete GenBank query tests. Skipping those tests", 5 if $@;
46 while (my $s = $seqio->next_seq) {
47 is $s->length, $expected_lengths{$s->display_id}, $s->display_id;
48 undef $gb; # test the case where the db is gone,
49 # but the pipeline should remain until seqio goes away
52 skip('No seqs returned', 5) if !$done;
56 $seq = $seqio = undef;
58 # test query facility (again)
59 ok $query = Bio::DB::Query::GenBank->new('-db' => 'nucleotide',
60 '-ids' => [qw(J00522 AF303112 2981014)]);
62 cmp_ok $query->count, '>', 0;
63 my @ids = $query->ids;
65 is @ids, $query->count;
66 $gb = Bio::DB::GenBank->new('-delay' => 0);
67 eval {$seqio = $gb->get_Stream_by_query($query);};
68 skip "Couldn't connect to complete GenBank query tests. Skipping those tests: $@", 4 if $@;
70 while (my $s = $seqio->next_seq) {
71 is $s->length, $expected_lengths{$s->display_id}, $s->display_id;
74 skip('No seqs returned', 4) if !$done;
76 $seqio->close(); # the key to preventing errors during make test, no idea why
79 $seq = $seqio = undef;
81 # and yet again, for bug 2133
82 $query = Bio::DB::Query::GenBank->new('-query' => 'AF303112',
83 '-ids' => [qw(J00522 AF303112 2981014)]);
84 is $query->query, 'J00522[PACC]|AF303112[PACC]|2981014[UID]';