2 #$Id: HIV.t 232 2008-12-11 14:51:51Z maj $#
10 -requires_modules => [qw( XML::Simple HTTP::Request::Common)],
12 use_ok('Bio::DB::HIV');
13 use_ok('Bio::DB::WebDBSeqI');
14 use_ok('Bio::DB::HIV::HIVAnnotProcessor');
17 my $tobj= Bio::DB::HIV->new();
19 $tobj->ua->timeout(90);
22 isa_ok($tobj, 'Bio::DB::HIV');
25 isa_ok($tobj, 'Bio::Root::Root');
26 can_ok($tobj, qw( get_request postprocess_data ));
29 can_ok($tobj, qw( get_seq_stream get_Stream_by_acc get_Stream_by_query _request ));
32 can_ok($tobj, qw( lanl_base map_db make_search_if search_ _map_db_uri _make_search_if_uri _search_uri _session_id _sorry ));
35 ok($tobj->lanl_base, 'lanl_base set in default object');
36 ok($tobj->map_db, 'map_db set in default object');
37 ok($tobj->make_search_if, 'make_search_if set in default object');
38 ok($tobj->search_, 'search_ set in default object');
39 ok($tobj->url_base_address, 'url_base_address set in default object');
40 is(($tobj->request_format)[0], "fasta", 'default sequence request format (fasta)');
43 throws_ok { $tobj->get_request('mode'=>'version', 'uids'=>['K03455.1']) } qr/Bio::HIVSorry::Exception/, 'sorry till implemented';
45 throws_ok {$tobj->get_request('mode'=>'gi', 'uids'=>['1906382'])} qr/Bio::HIVSorry::Exception/, 'sorry till implemented';
48 my $badq = bless({}, "Not::A::Query");
49 throws_ok {$tobj->get_Stream_by_query($badq)} qr/HIVQuery required/, 'HIVQuery type exception check';
53 test_skip(-tests => 12,
54 -requires_networking => 1);
56 # WebDBSeqI compliance-
57 # (this requires network access, since request is built after establishing
58 # the LANL session...)
60 eval {$req = $tobj->get_request('mode'=>'single','uids'=>['17756'])};
63 skip("Network problems, skipping all tests: $@", 12)
65 isa_ok($req, 'HTTP::Request', 'Object returned from get_request');
66 # get_... functionality
68 ok($tobj->get_Seq_by_id('17756'), 'get HXB2 by LANL id');
69 ok($tobj->get_Seq_by_acc('K03455'), 'get HXB2 by GB accession');
73 skip("Network problems, skipping all tests: $@", 11)
77 ok($seqio = $tobj->get_Stream_by_id(['17756']), 'get HXB2 in a stream');
78 ok($seqio = $tobj->get_Stream_by_acc(['K03455']), 'get HXB2 in a stream by accession');
82 skip("Network problems, skipping all tests: $@", 9)
84 $hxb2 = $seqio->next_seq;
85 is($hxb2->primary_id, 'K03455', 'checking returned stream');
86 is($hxb2->alphabet,'dna', 'checking returned stream');
87 ok(!($hxb2->seq !~ /atgc/i), 'checking returned sequence');
91 throws_ok { $tobj->get_Seq_by_id('XXXXXX') } qr/no sequences found/i, 'bad id exception check';
92 # session id exception
93 $tobj->_session_id('555-1212');
94 throws_ok {$tobj->get_Seq_by_id('17756')} qr/request failed/, 'bad session exception check';
96 $tobj->_session_id('');
98 $tobj->url_base_address('http://socrates_jones_et_cie.us');
99 throws_ok {$tobj->get_Seq_by_id('17756')} qr/Connect failed/, 'bad url exception check';
100 # wrong url exception
101 $tobj->url_base_address('http://fortinbras.us');
102 throws_ok {$tobj->get_Seq_by_id('17756')} qr/Session not established/, 'wrong url exception check';
104 # check ..._by_query functions in HIVQuery.t