1 # -*-Perl-*- Test Harness script for Bioperl
9 test_begin(-tests => 36,
10 -requires_modules => [qw(IO::String
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::BioFetch!\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(['AEE33958']);
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 cmp_ok( $seq->length, '>=', 1);
64 ok $db2 = Bio::DB::BioFetch->new(-db => 'swissprot');
65 test_skip(-tests => 5, -requires_module => 'Data::Stag');
67 $seq = $db2->get_Seq_by_id('YNB3_YEAST');
69 skip($dbwarn, 5) if $@;
70 isa_ok($seq, 'Bio::SeqI');
71 is($seq->length, 125);
72 is($seq->division, 'YEAST');
73 $db2->request_format('fasta');
75 $seq = $db2->get_Seq_by_acc('P43780');
77 skip($dbwarn, 2) if $@;
78 isa_ok($seq, 'Bio::SeqI');
82 $seq = $seqio = undef;
85 ok $db = Bio::DB::BioFetch->new(-retrievaltype => 'tempfile',
91 $seqio = $db->get_Stream_by_id('J00522 AF303112 J02231');
93 skip($dbwarn, 7) if $@;
95 # don't assume anything about the order of the sequences
96 while ( my $s = $seqio->next_seq ) {
97 isa_ok($s, 'Bio::SeqI');
98 my ($type,$x,$name) = split(/\|/,$s->display_id);
99 $seqs{$x} = $s->length;
101 isa_ok($seqio, 'Bio::SeqIO');
102 is($seqs{'J00522'},408);
103 is($seqs{'AF303112'},1611);
104 is($seqs{'J02231'},200);
108 ok $db = Bio::DB::BioFetch->new(-db => 'embl',
109 -verbose => $verbose ? $verbose : -1);
111 # check contig warning (WebDBSeqI)
113 $seq = $db->get_Seq_by_acc('NT_006732');
115 like($@, qr{contigs are whole chromosome files}, 'contig warning');
117 $seq = $db->get_Seq_by_acc('NM_006732');
119 skip($dbwarn, 2) if $@;
120 isa_ok($seq, 'Bio::SeqI');
121 is($seq->length,3776);
126 ok $db = Bio::DB::BioFetch->new(-db => 'unisave',
127 -verbose => $verbose ? $verbose : -1);
129 $seq = $db->get_Seq_by_acc('P14733');
131 skip($dbwarn, 4) if $@;
132 isa_ok($seq, 'Bio::SeqI');
133 is($seq->display_id, 'LMNB1_MOUSE');
134 is($seq->accession, 'P14733');
135 is($seq->length, 588);