fix subversion tags
[bioperl-live.git] / t / EMBL_DB.t
blobcd9856294559a022800e64befe965fbb8c48c7dc
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 => 16,
11                            -requires_modules => [qw(IO::String HTTP::Request::Common)],
12                            -requires_networking => 1);
13         
14         use_ok('Bio::DB::EMBL');
17 my $verbose = test_debug();
19 my ($db,$seq,$seqio);
20 # get a single seq
22 $seq = $seqio = undef;
24 SKIP: { 
25     ok defined($db = Bio::DB::EMBL->new(-verbose=>$verbose)); 
26     ok(defined($seq = $db->get_Seq_by_acc('J00522')));
27     is( $seq->length, 408); 
28     ok defined ($db->request_format('fasta'));
29         
30     eval {ok(defined($seq = $db->get_Seq_by_acc('J02231')))};
31         skip('could not connect to embl',2) if $@;
32     is( $seq->id, 'embl|J02231|J02231');
33     is( $seq->length, 200); 
34     ok( defined($db = Bio::DB::EMBL->new(-verbose=>$verbose, 
35                                         -retrievaltype => 'tempfile')));
36     eval {ok(defined($seqio = $db->get_Stream_by_id(['BUM'])))};
37         skip('could not connect to embl',2) if $@;
38     undef $db; # testing to see if we can remove gb
39     ok( defined($seq = $seqio->next_seq()));
40     is( $seq->length, 200);
43 $seq = $seqio = undef;
45 SKIP: {
46     $db = Bio::DB::EMBL->new(-verbose => $verbose,
47                             -retrievaltype => 'tempfile',
48                             -format => 'fasta'
49                             ); 
50     eval{ok( defined($seqio = $db->get_Stream_by_acc(['J00522 AF303112 J02231'])))};
51         skip('could not connect to embl',3) if $@;
52     my %seqs;
53     # don't assume anything about the order of the sequences
54     while ( my $s = $seqio->next_seq ) {
55                 my ($type,$x,$name) = split(/\|/,$s->display_id);
56                 $seqs{$x} = $s->length;
57     }
58     is($seqs{'J00522'},408);
59     is($seqs{'AF303112'},1611);
60     is($seqs{'J02231'},200);