1
# -*-Perl-*- Test Harness script for Bioperl
2
# $Id: GenPept.t 16089 2009-09-15 21:34:07Z cjfields $
10
test_begin(-tests => 21,
11
-requires_modules => [qw(IO::String
13
HTTP::Request::Common)],
14
-requires_networking => 1);
16
use_ok('Bio::DB::GenPept');
19
my %expected_lengths = (
25
my ($gb, $seq, $seqio);
30
ok $gb = Bio::DB::GenPept->new();
32
eval {$seqio = $gb->get_seq_stream(-uids => [2981015, 1621261, 195055], -mode => 'batch');};
33
skip "Couldn't connect to complete GenPept tests. Skipping those tests", 8 if $@;
34
my %result = ('AAC06201' => 353, 'CAB02640' => 193, 'AAD15290' => 136);
36
while ($seq = $seqio->next_seq) {
38
my $acc = $seq->accession;
39
ok exists $result{ $acc };
40
is $seq->length, $result{ $acc };
43
skip('No seqs returned', 8) if !$ct;
48
$seq = $seqio = undef;
50
ok $gb = Bio::DB::GenPept->new('-delay' => 0);
52
eval {$seq = $gb->get_Seq_by_id('195055');};
53
skip "Couldn't connect to Genbank with Bio::DB::GenPept.pm. Skipping those tests", 10 if $@;
54
is $seq->length, $expected_lengths{$seq->display_id}, $seq->display_id;
55
eval {$seq = $gb->get_Seq_by_acc('AAC06201');};
56
skip "Couldn't connect to Genbank with Bio::DB::GenPept.pm. Skipping those tests", 9 if $@;
57
is $seq->length, $expected_lengths{$seq->display_id}, $seq->display_id;
58
eval {$seqio = $gb->get_Stream_by_id([qw(AAC06201 195055)]);};
59
skip "Couldn't connect to Genbank with Bio::DB::GenPept.pm. Skipping those tests", 8 if $@;
61
while( my $s = $seqio->next_seq ) {
62
is $s->length, $expected_lengths{$s->display_id}, $s->display_id;
65
skip('No seqs returned', 8) if !$done;
67
# swissprot genpept parsing
68
eval {$seq = $gb->get_Seq_by_acc('2AAA_YEAST');};
69
skip "Couldn't connect to Genbank with Bio::DB::GenPept.pm. Skipping those tests", 5 if $@;
70
is $seq->length, $expected_lengths{$seq->display_id}, $seq->display_id;
73
# small chance this might change but hopefully not
74
my @annot = $seq->annotation->get_Annotations('dblink');
75
cmp_ok(scalar(@annot), '>', 31);
76
is $annot[0]->database, 'UniProtKB';
77
is $annot[0]->primary_id, '2AAA_YEAST';
78
is (($seq->annotation->get_Annotations('swissprot_dates'))[0]->value, 'Jul 1, 1993');