Skip to content

Commit

Permalink
RemoteBlast_rpsblast.t: Fixed a few number of skipped tests,
Browse files Browse the repository at this point in the history
and cleaned format and indentation
  • Loading branch information
fjossandon committed Apr 30, 2014
1 parent 1f8b4a1 commit ece219a
Showing 1 changed file with 61 additions and 59 deletions.
120 changes: 61 additions & 59 deletions 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
Expand All @@ -14,90 +14,92 @@ 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');
}

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);
}
}

Expand Down

0 comments on commit ece219a

Please sign in to comment.