From 5eca8a04e75e74553afb792eb8bc2199fd7ff4ca Mon Sep 17 00:00:00 2001 From: "Francisco J. Ossandon" Date: Wed, 30 Apr 2014 18:58:35 -0400 Subject: [PATCH] RemoteBlast_rpsblast.t: Fixed a few number of skipped tests, and cleaned format and indentation --- t/Tools/Run/RemoteBlast_rpsblast.t | 120 +++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 59 deletions(-) diff --git a/t/Tools/Run/RemoteBlast_rpsblast.t b/t/Tools/Run/RemoteBlast_rpsblast.t index 3676abec9..f4f66832a 100644 --- a/t/Tools/Run/RemoteBlast_rpsblast.t +++ b/t/Tools/Run/RemoteBlast_rpsblast.t @@ -1,5 +1,5 @@ # -*-Perl-*- Test Harness script for Bioperl -# $Id$ +# $Id$ # malcolm_cook@stowers.org: this test is in a separate file from # RemoteBlast.t (on which it is modelled) since there is some sort of @@ -14,8 +14,10 @@ BEGIN { use lib '.'; use Bio::Root::Test; - test_begin(-tests => 7, - -requires_modules => [qw(IO::String LWP LWP::UserAgent)], + test_begin(-tests => 7, + -requires_modules => [qw(IO::String + LWP + LWP::UserAgent)], -requires_networking => 1); use_ok('Bio::Tools::Run::RemoteBlast'); @@ -23,81 +25,81 @@ BEGIN { my $v = test_debug(); my $inputfilename = test_input_file('ecolitst.fa'); -ok( -e $inputfilename); - -my $remote_rpsblast = Bio::Tools::Run::RemoteBlast->new - ('-verbose' => test_debug(), - '-prog' => 'blastp', - '-data' => 'cdsearch/cdd', - '-readmethod' => 'blasttable', - '-expect' => '1e-10', - ); +ok( -e $inputfilename); +my $remote_rpsblast + = Bio::Tools::Run::RemoteBlast->new(-verbose => test_debug(), + -prog => 'blastp', + -data => 'cdsearch/cdd', + -readmethod => 'blasttable', + -expect => '1e-10', + ); $remote_rpsblast->retrieve_parameter('ALIGNMENT_VIEW', 'Tabular'); # This is the key to getting job run using rpsblast: -$Bio::Tools::Run::RemoteBlast::HEADER{'SERVICE'} = 'rpsblast'; +$Bio::Tools::Run::RemoteBlast::HEADER{'SERVICE'} = 'rpsblast'; my $attempt = 1; SKIP: { my $status; eval{ - $status = $remote_rpsblast->submit_blast($inputfilename); + $status = $remote_rpsblast->submit_blast($inputfilename); }; - + ok($status,'rpsblast blasttable submitted'); - - skip("Error accessing remote BLAST interface: $@", 3) if $@; - + skip("Error accessing remote BLAST interface: $@", 4) if $@; + my @rids = $remote_rpsblast->each_rid; is(@rids, 1, 'should only be one RID'); - skip("Wrong number of RIDs: ".scalar(@rids), 2) if @rids != 1; - - print STDERR "waiting [$rids[0]]..." if( $v > 0 ); + skip("Wrong number of RIDs: ".scalar(@rids), 3) if @rids != 1; + + diag("Retrieving $rids[0]...\n") if $v; my $rc; while (defined($rc = $remote_rpsblast->retrieve_blast($rids[0]))) { - if ( !ref($rc) ) { - if ( $rc < 0 ) { - skip("need a better solution for when 'Server failed to return any data'",2); - } - sleep 5; - print STDERR "Retrieval attempt: $attempt\n" if ( $v > 0 ); - $attempt++ < 10 ? next : last; - } else { - last - } + if ( !ref($rc) ) { + if ( $rc < 0 ) { + skip("need a better solution for when 'Server failed to return any data'",2); + } + sleep 5; + diag("Retrieval attempt: $attempt\n") if $v; + $attempt++ < 10 ? next : last; + } + else { + last; + } } $remote_rpsblast->remove_rid($rids[0]); - + if ($rc) { - ok(1,'retrieve_blast succeeded'); - $remote_rpsblast->remove_rid($rids[0]); - my $count = 0; - isa_ok($rc, 'Bio::SearchIO'); - while (my $result = $rc->next_result) { - while ( my $hit = $result->next_hit ) { - $count++; - next unless ( $v > 0); - print "sbjct name is ", $hit->name, "\n"; - while ( my $hsp = $hit->next_hsp ) { - print "score is ", $hsp->bits, "\n"; - } - } - } - cmp_ok($count, '>=', 45, 'HSPs returned'); - } elsif ($attempt > 10) { - # have a test fail here (there should not be repeated failed attempts to - # get reports) - - ok(0,'Exceeded maximum attempts on server to retrieve report'); - skip("Timeout, did not return report after ".($attempt - 1)." attempts", 2); - } else { - # have a test fail here (whatever is returned should be eval as true and - # be a SearchIO) - - ok(0,"Other problem on remote server, no report returned: $rc"); - skip('Possible remote server problems', 1); + ok(1,'retrieve_blast succeeded'); + $remote_rpsblast->remove_rid($rids[0]); + my $count = 0; + isa_ok($rc, 'Bio::SearchIO'); + while (my $result = $rc->next_result) { + while ( my $hit = $result->next_hit ) { + $count++; + next unless ( $v > 0); + print "sbjct name is ", $hit->name, "\n"; + while ( my $hsp = $hit->next_hsp ) { + print "score is ", $hsp->bits, "\n"; + } + } + } + cmp_ok($count, '>=', 45, 'HSPs returned'); + } + elsif ($attempt > 10) { + # have a test fail here (there should not be repeated failed attempts to + # get reports) + ok(0,'Exceeded maximum attempts on server to retrieve report'); + diag("Timeout, did not return report after ".($attempt - 1)." attempts"); + skip('Remote server timeout problems', 2); + } + else { + # have a test fail here (whatever is returned should be eval as true and + # be a SearchIO) + ok(0,"Other problem on remote server, no report returned: $rc"); + skip('Possible remote server problems', 2); } } -- 2.11.4.GIT