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 LWP LWP::UserAgent)],
19 -requires_networking => 1);
21 use_ok('Bio::Tools::Run::RemoteBlast');
25 my $inputfilename = test_input_file('ecolitst.fa');
26 ok( -e $inputfilename);
28 my $remote_rpsblast = Bio::Tools::Run::RemoteBlast->new
29 ('-verbose' => test_debug(),
31 '-data' => 'cdsearch/cdd',
32 '-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');
51 skip("Error accessing remote BLAST interface: $@", 3) 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), 2) if @rids != 1;
57 print STDERR "waiting [$rids[0]]..." if( $v > 0 );
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 print STDERR "Retrieval attempt: $attempt\n" if ( $v > 0 );
66 $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');
78 while (my $result = $rc->next_result) {
79 while ( my $hit = $result->next_hit ) {
81 next unless ( $v > 0);
82 print "sbjct name is ", $hit->name, "\n";
83 while ( my $hsp = $hit->next_hsp ) {
84 print "score is ", $hsp->bits, "\n";
88 cmp_ok($count, '>=', 45, 'HSPs returned');
89 } elsif ($attempt > 10) {
90 # have a test fail here (there should not be repeated failed attempts to
93 ok(0,'Exceeded maximum attempts on server to retrieve report');
94 skip("Timeout, did not return report after ".($attempt - 1)." attempts", 2);
96 # have a test fail here (whatever is returned should be eval as true and
99 ok(0,"Other problem on remote server, no report returned: $rc");
100 skip('Possible remote server problems', 1);
104 # To be a good citizen, we should restore the default NCBI service
105 # ('plain') for future tests
106 $Bio::Tools::Run::RemoteBlast::HEADER{'SERVICE'} = 'plain';