1 # -*-Perl-*- Test Harness script for Bioperl
4 # malcolm_cook@stowers.org: this test is in a separate file from
5 # RemoteBlast.t (on which it is modelled) since there is some sort of
6 # side-effecting between the multiple remote blasts that is causing
7 # this test to fail, if it comes last, or the other test to fail, if
8 # this one comes first. THIS IS A BUG EITHER IN REMOTE BLAST OR MY
9 # UNDERSTANDING, i.e. of how to initialize it.
17 test_begin(-tests => 7,
18 -requires_modules => [qw(IO::String
20 -requires_networking => 1);
22 use_ok('Bio::Tools::Run::RemoteBlast');
26 my $inputfilename = test_input_file('ecolitst.fa');
27 ok( -e $inputfilename);
30 = Bio::Tools::Run::RemoteBlast->new(-verbose => test_debug(),
33 -readmethod => 'blasttable',
36 $remote_rpsblast->retrieve_parameter('ALIGNMENT_VIEW', 'Tabular');
38 # This is the key to getting job run using rpsblast:
39 $Bio::Tools::Run::RemoteBlast::HEADER{'SERVICE'} = 'rpsblast';
46 $status = $remote_rpsblast->submit_blast($inputfilename);
49 ok($status,'rpsblast blasttable submitted');
50 skip("Error accessing remote BLAST interface: $@", 4) if $@;
52 my @rids = $remote_rpsblast->each_rid;
53 is(@rids, 1, 'should only be one RID');
54 skip("Wrong number of RIDs: ".scalar(@rids), 3) if @rids != 1;
56 diag("Retrieving $rids[0]...\n") if $v;
58 while (defined($rc = $remote_rpsblast->retrieve_blast($rids[0]))) {
61 skip("need a better solution for when 'Server failed to return any data'",2);
64 diag("Retrieval attempt: $attempt\n") if $v;
65 $attempt++ < 10 ? next : last;
71 $remote_rpsblast->remove_rid($rids[0]);
74 ok(1,'retrieve_blast succeeded');
75 $remote_rpsblast->remove_rid($rids[0]);
77 isa_ok($rc, 'Bio::SearchIO');
79 while (my $result = $rc->next_result) {
80 while ( my $hit = $result->next_hit ) {
82 next unless ( $v > 0);
83 print "sbjct name is ", $hit->name, "\n";
84 while ( my $hsp = $hit->next_hsp ) {
85 print "score is ", $hsp->bits, "\n";
89 cmp_ok($count, '>=', 45, 'HSPs returned');
91 elsif ($attempt > 10) {
92 # have a test fail here (there should not be repeated failed attempts to
94 ok(0,'Exceeded maximum attempts on server to retrieve report');
95 diag("Timeout, did not return report after ".($attempt - 1)." attempts");
96 skip('Remote server timeout problems', 2);
99 # have a test fail here (whatever is returned should be eval as true and
101 ok(0,"Other problem on remote server, no report returned: $rc");
102 skip('Possible remote server problems', 2);
106 # To be a good citizen, we should restore the default NCBI service
107 # ('plain') for future tests
108 $Bio::Tools::Run::RemoteBlast::HEADER{'SERVICE'} = 'plain';