Merge pull request #208 from bioperl/make_new_dependencies
[bioperl-live.git] / t / RemoteDB / SwissProt.t
blob3c538b295fd78ec0cb957b0de03b8f9ff0c37fbe
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN {
7     use lib '.';
8     use Bio::Root::Test;
10     test_begin(-tests               => 23,
11                -requires_modules    => [qw(IO::String
12                                            LWP::UserAgent
13                                            HTTP::Request::Common
14                                            Data::Stag)],
15                -requires_networking => 1);
17     use_ok('Bio::DB::SwissProt');
20 ok my $gb = Bio::DB::SwissProt->new(-retrievaltype => 'pipeline',
21                                     -delay         => 0);
23 my %expected_lengths = (
24                         'NDP_MOUSE'   => 131,
25                         'NDP_HUMAN'   => 133,
26                         'BOLA_HAEIN'  => 103,
27                         'YNB3_YEAST'  => 125,
28                         'O39869'      => 56,
29                         'DEGP_CHLTR'  => 497,
30                         'DEGPL_CHLTR' => 497
31                         );
33 my ($seq, $seqio);
35 SKIP: {
36     eval {$seq = $gb->get_Seq_by_id('YNB3_YEAST');};
37     skip "Couldn't connect to SwissProt with Bio::DB::SwissProt.pm. Skipping those tests", 14 if $@;
38     is $seq->length, $expected_lengths{$seq->display_id}, $seq->display_id;
39     is $seq->division, 'YEAST';
41     eval {$seq = $gb->get_Seq_by_acc('P43780');};
42     skip "Couldn't connect to SwissProt with Bio::DB::SwissProt.pm. Skipping those tests", 12 if $@;
43     is $seq->length, $expected_lengths{$seq->display_id}, $seq->display_id;
44     eval {$seq = $gb->get_Seq_by_acc('O39869');};
45     skip "Couldn't connect to SwissProt with Bio::DB::SwissProt.pm. Skipping those tests", 11 if $@;
46     is $seq->length, $expected_lengths{$seq->accession_number}, $seq->accession_number;
47     is $seq->accession_number, 'O39869';
48     is $seq->division, '9PICO';
50     # test for bug #958
51     eval {$seq = $gb->get_Seq_by_id('P18584');};
52     skip "Couldn't connect to SwissProt with Bio::DB::SwissProt.pm. Skipping those tests", 8 if $@;
53     ok exists $expected_lengths{$seq->display_id}, 'P18584';
54     is $seq->length, $expected_lengths{$seq->display_id}, $seq->display_id;
55     is $seq->division, 'CHLTR';
57     ok $gb = Bio::DB::SwissProt->new('-retrievaltype' => 'tempfile', '-delay' => 0);
58     eval {$seqio = $gb->get_Stream_by_id(['NDP_MOUSE', 'NDP_HUMAN']);};
59     skip "Couldn't connect to SwissProt with Bio::DB::SwissProt.pm. Skipping those tests", 4 if $@;
60     undef $gb; # testing to see if we can remove gb
61     ok $seq = $seqio->next_seq();
62     is $seq->length, $expected_lengths{$seq->display_id}, $seq->display_id;
63     ok $seq = $seqio->next_seq();
64     is $seq->length, $expected_lengths{$seq->display_id}, $seq->display_id;
67 # test idtracker() method
68 ok $gb = Bio::DB::SwissProt->new(-retrievaltype => 'pipeline',
69                                  -delay         => 0,
70                                  -verbose       => 2);
72 SKIP: {
73     my $map;
74     # check old ID
75     eval {$map = $gb->id_mapper(-from => 'ACC+ID',
76                                 -to   => 'ACC',
77                                 -ids  => [qw(MYOD1_PIG PYRC_YEAST)]
78                                 )};
79     skip("Problem with idtracker(), skipping these tests: $@", 6) if $@;
81     cmp_ok(@{$map->{MYOD1_PIG}}, '>=', 1);
82     is($map->{MYOD1_PIG}[0], 'P49811');
83     cmp_ok(@{$map->{PYRC_YEAST}}, '>=', 1);
84     is($map->{PYRC_YEAST}[0], 'P20051');
86     eval {$map = $gb->id_mapper(-from => 'ACC+ID',
87                                 -to   => 'EMBL',
88                                 -ids  => [qw(PYRC_YEAST)]
89                                 )};
90     skip("Problem with idtracker(), skipping these tests: $@", 2) if $@;
92     cmp_ok(@{$map->{PYRC_YEAST}}, '>=', 2);
93     like($map->{PYRC_YEAST}[0], qr/^[A-Z0-9]/);