File: GenPept.t

package info (click to toggle)
libbio-db-ncbihelper-perl 1.7.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 332 kB
  • sloc: perl: 1,319; makefile: 5
file content (82 lines) | stat: -rw-r--r-- 2,606 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# -*-Perl-*- Test Harness script for Bioperl
# $Id$

use strict;

BEGIN {
	use Test::RequiresInternet;
	use Test::Most tests => 21;
	use_ok('Bio::DB::GenPept');
}

my %expected_lengths = (
    'AAC06201'  => 353,
    'AAD15290'  => 136,
    'P31383'    => 635,
    '2AAA_YEAST' => 635
);

my %params;

if (defined $ENV{BIOPERLEMAIL}) {
    $params{'-email'} = $ENV{BIOPERLEMAIL};
    $params{'-delay'} = 2;
}

$params{'-verbose'} = $ENV{BIOPERLDEBUG};

my ($gb, $seq, $seqio);

#
# Bio::DB::GenPept
#
ok $gb = Bio::DB::GenPept->new(%params);
SKIP: {
    eval {$seqio = $gb->get_seq_stream(-uids => [2981015, 1621261, 195055], -mode => 'batch');};
    skip "Couldn't connect to complete GenPept tests. Skipping those tests", 8 if $@;
    my %result = ('AAC06201' => 353, 'CAB02640' => 193, 'AAD15290' => 136);
    my $ct = 0;
    while ($seq = $seqio->next_seq) {
		$ct++;
		my $acc = $seq->accession;
        ok exists $result{ $acc };
        is $seq->length, $result{ $acc };
		delete $result{$acc};
    }
    skip('No seqs returned', 8) if !$ct;
	is $ct, 3;
    is %result, 0;
}

$seq = $seqio = undef;

ok $gb = Bio::DB::GenPept->new(%params);
SKIP: {
    eval {$seq = $gb->get_Seq_by_id('195055');};
    skip "Couldn't connect to Genbank with Bio::DB::GenPept.pm. Skipping those tests: $@", 10 if $@;
    is $seq->length, $expected_lengths{$seq->display_id}, $seq->display_id;
    eval {$seq = $gb->get_Seq_by_acc('AAC06201');};
    skip "Couldn't connect to Genbank with Bio::DB::GenPept.pm. Skipping those tests $@", 9 if $@;
    is $seq->length, $expected_lengths{$seq->display_id}, $seq->display_id;
    eval {$seqio = $gb->get_Stream_by_id([qw(AAC06201 195055)]);};
    skip "Couldn't connect to Genbank with Bio::DB::GenPept.pm. Skipping those tests: $@", 8 if $@;
    my $done = 0;
    while( my $s = $seqio->next_seq ) {
        is $s->length, $expected_lengths{$s->display_id}, $s->display_id;
        $done++;
    }
    skip('No seqs returned', 8) if !$done;
    is $done, 2;
    # swissprot genpept parsing
    eval {$seq = $gb->get_Seq_by_acc('P31383');};
    skip "Couldn't connect to Genbank with Bio::DB::GenPept.pm. Skipping those tests: $@", 5 if $@;
    is $seq->length, $expected_lengths{$seq->display_id}, $seq->display_id;

    # test dbsource stuff
    # small chance this might change but hopefully not
    my @annot = $seq->annotation->get_Annotations('dblink');
    cmp_ok(scalar(@annot), '>', 31);
    is $annot[0]->database, 'UniProtKB';
    is $annot[0]->primary_id, '2AAA_YEAST';
    is (($seq->annotation->get_Annotations('swissprot_dates'))[0]->value, 'Jul 1, 1993');
}