Bio-Tools-Run-RemoteBlast
view release on metacpan or search on metacpan
t/release-RemoteBlast_rpsblast.t view on Meta::CPAN
);
$remote_rpsblast->retrieve_parameter('ALIGNMENT_VIEW', 'Tabular');
# This is the key to getting job run using rpsblast:
$Bio::Tools::Run::RemoteBlast::HEADER{'SERVICE'} = 'rpsblast';
my $attempt = 1;
SKIP: {
my $status;
eval{
$status = $remote_rpsblast->submit_blast($inputfilename);
};
ok($status,'rpsblast blasttable submitted');
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), 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;
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');
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);
}
}
# To be a good citizen, we should restore the default NCBI service
# ('plain') for future tests
$Bio::Tools::Run::RemoteBlast::HEADER{'SERVICE'} = 'plain';
( run in 2.923 seconds using v1.01-cache-2.11-cpan-437f7b0c052 )