~ubuntu-branches/ubuntu/precise/bioperl/precise

« back to all changes in this revision

Viewing changes to t/RemoteDB/GenPept.t

  • Committer: Bazaar Package Importer
  • Author(s): Ilya Barygin
  • Date: 2010-01-27 22:48:22 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100127224822-ebot4qbrjxcv38au
Tags: 1.6.1-1ubuntu1
* Merge from Debian testing, remaining changes:
  - disable tests, they produce a FTBFS trying to access the network 
    during run.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*-Perl-*- Test Harness script for Bioperl
 
2
# $Id: GenPept.t 16089 2009-09-15 21:34:07Z cjfields $
 
3
 
 
4
use strict;
 
5
 
 
6
BEGIN {
 
7
        use lib '.';
 
8
        use Bio::Root::Test;
 
9
        
 
10
        test_begin(-tests => 21,
 
11
                           -requires_modules => [qw(IO::String
 
12
                                                                            LWP::UserAgent
 
13
                                                                                HTTP::Request::Common)],
 
14
                           -requires_networking => 1);
 
15
        
 
16
        use_ok('Bio::DB::GenPept');
 
17
}
 
18
 
 
19
my %expected_lengths = (
 
20
    'AAC06201'  => 353,
 
21
    'AAD15290'  => 136,
 
22
    'P31383'    => 635,
 
23
);
 
24
 
 
25
my ($gb, $seq, $seqio);
 
26
 
 
27
#
 
28
# Bio::DB::GenPept
 
29
#
 
30
ok $gb = Bio::DB::GenPept->new();
 
31
SKIP: {
 
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);
 
35
    my $ct = 0;
 
36
    while ($seq = $seqio->next_seq) {
 
37
                $ct++;
 
38
                my $acc = $seq->accession;
 
39
        ok exists $result{ $acc };
 
40
        is $seq->length, $result{ $acc };
 
41
                delete $result{$acc};
 
42
    }
 
43
    skip('No seqs returned', 8) if !$ct;
 
44
        is $ct, 3;
 
45
    is %result, 0;
 
46
}
 
47
 
 
48
$seq = $seqio = undef;
 
49
 
 
50
ok $gb = Bio::DB::GenPept->new('-delay' => 0);
 
51
SKIP: { 
 
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 $@;
 
60
    my $done = 0;
 
61
    while( my $s = $seqio->next_seq ) {
 
62
        is $s->length, $expected_lengths{$s->display_id}, $s->display_id;
 
63
        $done++;
 
64
    }
 
65
    skip('No seqs returned', 8) if !$done;
 
66
    is $done, 2;
 
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;
 
71
    
 
72
    # test dbsource stuff
 
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');
 
79
}
 
80