/
EMBLTest.t
89 lines (76 loc) · 2.16 KB
/
EMBLTest.t
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
83
84
85
86
87
88
89
# -*-Perl-*-
use strict;
use vars qw($NUMTESTS $DEBUG $EMBLNAME $IORURL $error);
BEGIN {
# to handle systems with no installed Test module
# we include the t dir (where a copy of Test.pm is located)
# as a fallback
eval { require Test; };
$error = 0;
$DEBUG = 0;
$EMBLNAME ='EMBL';
$IORURL ='http://corba.ebi.ac.uk/IOR/EmblBiocorba_v0_2.IOR';
if( $@ ) {
use lib 't';
}
use Test;
$NUMTESTS = 5;
plan tests => $NUMTESTS;
eval { require 'HTTP/Request.pm';
require 'LWP/UserAgent.pm';
};
if( $@ ) {
print STDERR "LWP or HTTP::Request is not properly installed. Skipping test...\n";
for( 1..$NUMTESTS ) {
skip(1,1);
}
$error = 1;
}
}
if( $error == 1 ){
exit(0);
}
use CORBA::ORBit idl => [ 'biocorba.idl' ];
use Bio::CorbaClient::Seq;
use HTTP::Request;
use LWP::UserAgent;
# init
my $orb = CORBA::ORB_init("orbit-local-orb");
my $response = undef;
eval {
my $request = new HTTP::Request(GET => $IORURL);
my $agent = new LWP::UserAgent;
$response = $agent->request($request);
};
if( $@ || ! ref $response ||
! $response->is_success ) {
print STDERR "$@" if ( $DEBUG );
for( $Test::ntest..$NUMTESTS ) { skip(1,1) }
exit(0);
}
my $ior=$response->content();
chomp($ior);
my $bioenv = $orb->string_to_object($ior);
ok($bioenv);
my %params = ( 'accessnumber' => 'AC003953');
#######################################################################
# I had to comment the line below to avoid the exception.
my $dblist = $bioenv->get_SeqDB_names();
#######################################################################
foreach my $dbname ( @$dblist ) {
print "dbname is $dbname\n" if( $DEBUG );
}
my $database = $bioenv->get_SeqDB_by_name($EMBLNAME,0);
ok($database);
# should porbably catch exceptions
my $corbaseq = $database->get_Seq($params{'accessnumber'},0);
ok($corbaseq);
my $bioseq = new Bio::CorbaClient::Seq('-corbaref' => $corbaseq );
ok($bioseq);
my @features = $bioseq->all_SeqFeatures();
ok(@features, 53);
if( $DEBUG ) {
foreach my $feature ( @features ) {
print $feature->primary_tag , ' ', $feature->start, "..", $feature->end, "\n";
}
}