1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 21,
11 -requires_modules => [qw(IO::String LWP LWP::UserAgent)],
12 -requires_networking => 1);
14 use_ok('Bio::Tools::Run::RemoteBlast');
23 my $remote_blast = Bio::Tools::Run::RemoteBlast->new('-verbose' => $v,
28 $remote_blast->submit_parameter('ENTREZ_QUERY', 'Escherichia coli[ORGN]');
29 my $inputfilename = test_input_file('ecolitst.fa');
30 ok( -e $inputfilename);
38 $status = $remote_blast->submit_blast($inputfilename);
41 ok($status,'BLAST text output submitted');
43 skip("Error accessing remote BLAST interface: $@", 3) if $@;
45 cmp_ok($remote_blast->get_rtoe, '>', 0, "Estimated retrieval time");
47 diag("Time remaining: ".$remote_blast->get_rtoe) if $v;
49 my @rids = $remote_blast->each_rid;
50 is(@rids, 1, 'should only be one RID');
51 skip("Wrong number of RIDs: ".scalar(@rids), 2) if @rids != 1;
53 diag("Retrieving $rids[0]...\n") if $v;
55 while (defined($rc = $remote_blast->retrieve_blast($rids[0]))) {
58 skip("need a better solution for when 'Server failed to return any data'",2);
61 diag("Retrieval attempt: $attempt\n") if $v;
62 $attempt++ < 10 ? next : last;
69 ok(1,'retrieve_blast succeeded');
70 $remote_blast->remove_rid($rids[0]);
72 isa_ok($rc, 'Bio::SearchIO');
73 while (my $result = $rc->next_result) {
74 while ( my $hit = $result->next_hit ) {
76 next unless ( $v > 0);
77 print "sbjct name is ", $hit->name, "\n";
78 while ( my $hsp = $hit->next_hsp ) {
79 print "score is ", $hsp->bits, "\n";
83 is($count, 3, 'HSPs returned');
84 } elsif ($attempt > 10) {
85 # have a test fail here (there should not be repeated failed attempts to
88 ok(0,'Exceeded maximum attempts on server to retrieve report');
89 diag("Timeout, did not return report after ".($attempt - 1)." attempts");
91 # have a test fail here (whatever is returned should be eval as true and
94 ok(0,"Other problem on remote server, no report returned: $rc");
95 skip('Possible remote server problems', 1);
102 my $remote_blast = Bio::Tools::Run::RemoteBlast->new
106 '-readmethod' => 'blasttable',
109 $remote_blast->submit_parameter('ENTREZ_QUERY', 'Escherichia coli[ORGN]');
111 $remote_blast->retrieve_parameter('ALIGNMENT_VIEW', 'Tabular');
113 my $inputfilename = test_input_file('ecolitst.fa');
118 $status = $remote_blast->submit_blast($inputfilename);
121 ok($status,'Tabular BLAST submitted');
123 skip("Error accessing remote BLAST interface: $@", 3) if $@;
125 cmp_ok($remote_blast->get_rtoe, '>', 0, "Estimated retrieval time");
126 diag("Time remaining: ".$remote_blast->get_rtoe) if $v;
128 my @rids = $remote_blast->each_rid;
129 is(@rids, 1, 'should only be one RID');
130 skip("Wrong number of RIDs: ".scalar(@rids), 2) if @rids != 1;
132 diag("waiting [$rids[0]]...") if $v;
134 while (defined($rc = $remote_blast->retrieve_blast($rids[0]))) {
137 skip("need a better solution for when 'Server failed to return any data'",2);
140 diag("Retrieval attempt: $attempt") if $v;
141 $attempt++ < 10 ? next : last;
148 ok(1,'retrieve_blast succeeded');
149 $remote_blast->remove_rid($rids[0]);
151 isa_ok($rc, 'Bio::SearchIO');
152 while (my $result = $rc->next_result) {
153 while ( my $hit = $result->next_hit ) {
155 next unless ( $v > 0);
156 print "sbjct name is ", $hit->name, "\n";
157 while ( my $hsp = $hit->next_hsp ) {
158 print "score is ", $hsp->bits, "\n";
162 is($count, 3, 'HSPs returned');
163 } elsif ($attempt > 10) {
164 # have a test fail here (there should not be repeated failed attempts to
167 ok(0,'Exceeded maximum attempts on server to retrieve report');
168 skip("Timeout, did not return report after ".($attempt - 1)." attempts", 1);
170 # have a test fail here (whatever is returned should be eval as true and
173 ok(0,"Other problem on remote server, no report returned: $rc");
174 skip('Possible remote server problems', 1);
179 test_skip(-tests => 5, -requires_module => 'Bio::SearchIO::blastxml');
181 my $remote_blast = Bio::Tools::Run::RemoteBlast->new('-prog' => $prog,
183 '-readmethod' => 'xml',
186 $remote_blast->submit_parameter('ENTREZ_QUERY',
187 'Escherichia coli[ORGN]');
189 $remote_blast->retrieve_parameter('FORMAT_TYPE', 'XML');
191 my $inputfilename = test_input_file('ecolitst.fa');
196 $status = $remote_blast->submit_blast($inputfilename);
199 ok($status,'XML BLAST submitted');
201 skip("Error accessing remote BLAST interface: $@", 3) if $@;
203 cmp_ok($remote_blast->get_rtoe, '>', 0, "Estimated retrieval time");
204 diag("Time remaining: ".$remote_blast->get_rtoe) if $v;
206 my @rids = $remote_blast->each_rid;
207 is(@rids, 1, 'should only be one RID');
208 skip("Wrong number of RIDs: ".scalar(@rids), 2) if @rids != 1;
210 diag("waiting [$rids[0]]...") if $v;
212 while (defined($rc = $remote_blast->retrieve_blast($rids[0]))) {
215 skip("need a better solution for when 'Server failed to return any data'",2);
218 diag("Retrieval attempt: $attempt") if $v;
219 $attempt++ < 10 ? next : last;
226 ok(1,'retrieve_blast succeeded');
227 $remote_blast->remove_rid($rids[0]);
229 isa_ok($rc, 'Bio::SearchIO');
230 while (my $result = $rc->next_result) {
231 while ( my $hit = $result->next_hit ) {
235 is($count, 3, 'HSPs returned');
236 } elsif ($attempt > 10) {
237 # have a test fail here (there should not be repeated failed attempts to
240 ok(0,'Exceeded maximum attempts on server to retrieve report');
241 diag("Timeout, did not return report after ".($attempt - 1)." attempts");
243 # have a test fail here (whatever is returned should be eval as true and
246 ok(0,"Other problem on remote server, no report returned: $rc");
247 diag('Possible remote server problems');