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
21 -requires_networking => 1);
23 use_ok('Bio::Tools::Run::RemoteBlast');
27 my $inputfilename = test_input_file('ecolitst.fa');
28 ok( -e $inputfilename);
31 = Bio::Tools::Run::RemoteBlast->new(-verbose => test_debug(),
33 -data => 'cdsearch/cdd',
34 -readmethod => 'blasttable',
37 $remote_rpsblast->retrieve_parameter('ALIGNMENT_VIEW', 'Tabular');
39 # This is the key to getting job run using rpsblast:
40 $Bio::Tools::Run::RemoteBlast::HEADER{'SERVICE'} = 'rpsblast';
47 $status = $remote_rpsblast->submit_blast($inputfilename);
50 ok($status,'rpsblast blasttable submitted');
51 skip("Error accessing remote BLAST interface: $@", 4) if $@;
53 my @rids = $remote_rpsblast->each_rid;
54 is(@rids, 1, 'should only be one RID');
55 skip("Wrong number of RIDs: ".scalar(@rids), 3) if @rids != 1;
57 diag("Retrieving $rids[0]...\n") if $v;
59 while (defined($rc = $remote_rpsblast->retrieve_blast($rids[0]))) {
62 skip("need a better solution for when 'Server failed to return any data'",2);
65 diag("Retrieval attempt: $attempt\n") if $v;
66 $attempt++ < 10 ? next : last;
72 $remote_rpsblast->remove_rid($rids[0]);
75 ok(1,'retrieve_blast succeeded');
76 $remote_rpsblast->remove_rid($rids[0]);
78 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';