1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 36,
11 -requires_modules => [qw(IO::String LWP::UserAgent)],
12 -requires_networking => 1);
14 use_ok('Bio::DB::BioFetch');
17 my $verbose = test_debug();
19 my $dbwarn = "Warning: Couldn't connect to EMBL with Bio::DB::EMBL.pm!\n";
21 my ($db,$db2,$seq,$seqio);
25 ok defined($db = Bio::DB::BioFetch->new(-verbose => $verbose));
29 $seq = $db->get_Seq_by_acc('NM_006732'); # RefSeq VERSION
31 skip($dbwarn, 4) if $@;
32 isa_ok($seq, 'Bio::SeqI');
33 is($seq->accession_number,'NM_006732');
34 is($seq->accession_number,'NM_006732');
35 is( $seq->length, 3776);
42 $seq = $db->get_Seq_by_acc('J02231');
44 skip($dbwarn, 3) if $@;
45 isa_ok($seq, 'Bio::SeqI');
46 is($seq->id, 'J02231');
47 is($seq->length, 200);
52 $seqio = $db->get_Stream_by_id(['BUM']);
54 skip($dbwarn, 3) if $@;
55 undef $db; # testing to see if we can remove gb
56 $seq = $seqio->next_seq();
57 isa_ok($seqio, 'Bio::SeqIO');
58 isa_ok($seq, 'Bio::SeqI');
59 is( $seq->length, 200);
64 ok $db2 = Bio::DB::BioFetch->new(-db => 'swissprot');
66 $seq = $db2->get_Seq_by_id('YNB3_YEAST');
68 skip($dbwarn, 5) if $@;
69 isa_ok($seq, 'Bio::SeqI');
70 is($seq->length, 125);
71 is($seq->division, 'YEAST');
72 $db2->request_format('fasta');
74 $seq = $db2->get_Seq_by_acc('P43780');
76 skip($dbwarn, 2) if $@;
77 isa_ok($seq, 'Bio::SeqI');
81 $seq = $seqio = undef;
84 ok $db = Bio::DB::BioFetch->new(-retrievaltype => 'tempfile',
90 $seqio = $db->get_Stream_by_id('J00522 AF303112 J02231');
92 skip($dbwarn, 7) if $@;
94 # don't assume anything about the order of the sequences
95 while ( my $s = $seqio->next_seq ) {
96 isa_ok($s, 'Bio::SeqI');
97 my ($type,$x,$name) = split(/\|/,$s->display_id);
98 $seqs{$x} = $s->length;
100 isa_ok($seqio, 'Bio::SeqIO');
101 is($seqs{'J00522'},408);
102 is($seqs{'AF303112'},1611);
103 is($seqs{'J02231'},200);
107 ok $db = Bio::DB::BioFetch->new(-db => 'embl', -verbose => $verbose ? $verbose : -1);
109 # check contig warning (WebDBSeqI)
111 $seq = $db->get_Seq_by_acc('NT_006732');
113 like($@, qr{contigs are whole chromosome files}, 'contig warning');
115 $seq = $db->get_Seq_by_acc('NM_006732');
117 skip($dbwarn, 3) if $@;
118 isa_ok($seq, 'Bio::SeqI');
119 is($seq->length,3776);
124 ok $db = Bio::DB::BioFetch->new(-db => 'unisave',
125 -verbose => $verbose);
127 $seq = $db->get_Seq_by_acc('LAM1_MOUSE');
129 skip($dbwarn, 3) if $@;
130 isa_ok($seq, 'Bio::SeqI');
131 is($seq->display_id, 'LAM1_MOUSE');
132 is($seq->accession, 'P14733');
133 is($seq->length, 587);