File: RemoteBlast.t

package info (click to toggle)
bioperl 1.0-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 10,784 kB
  • ctags: 4,962
  • sloc: perl: 70,732; xml: 3,279; lisp: 107; makefile: 53
file content (91 lines) | stat: -rw-r--r-- 2,084 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# -*-Perl-*- for my emacs

use strict;
use vars qw($NUMTESTS);
my $error;
BEGIN { 
    eval { require Test; };
    if( $@ ) {
	use lib 't';
    }
    use Test;
    $error = 0;
    $NUMTESTS = 6; 
    plan tests => 6;
    eval { require 'IO/String.pm' };
    if( $@ ) {
	print STDERR "IO::String not installed. This means the Bio::DB::* modules are not usable. Skipping tests.\n";
	for( 1..$NUMTESTS ) {
	    skip("IO::String not installed. This means the Bio::DB::* modules are not usable. Skipping tests",1);
	}
	$error = 1; 
    }
}

my $actually_submit = 0;

if( $error ==  1 ) {
    exit(0);
}

require Bio::Tools::Run::RemoteBlast;

require Bio::SeqIO;
require Bio::AlignIO;
require Bio::Seq;
require Bio::Root::IO;

ok(1);

my $prog = 'blastp';
my $db   = 'ecoli';
my $e_val= '1e-10';
my $v = 0;
my  $remote_blast = Bio::Tools::Run::RemoteBlast->new('-verbose' => $v,
						      '-prog' => $prog,
						      '-data' => $db,
						      '-expect' => $e_val,
						      );
my $inputfilename = Bio::Root::IO->catfile("t","data","ecolitst.fa");
ok( -e $inputfilename);

if( $actually_submit == 0 ) {
    print STDERR "Skipping submitting remote BLAST to avoid Time-out\n";
    foreach( $Test::ntest..$NUMTESTS) { 
       skip('Skip to avoid timeout',1);
    }
} else {

    my $r = $remote_blast->submit_blast($inputfilename);
    ok($r);
    print STDERR "waiting..." if( $v > 0 );
    while ( my @rids = $remote_blast->each_rid ) {
	foreach my $rid ( @rids ) {
	    my $rc = $remote_blast->retrieve_blast($rid);
	    if( !ref($rc) ) {
		if( $rc < 0 ) { 		
		    $remote_blast->remove_rid($rid);
		    ok(0);
		}
		print STDERR "." if ( $v > 0 );
		sleep 5;
	    } else { 
		ok(1);
		$remote_blast->remove_rid($rid);
		my $result = $rc->next_result;
		ok($result->database_name, qr/E. coli/);
		my $count = 0;
		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->score, "\n";
		    } 
		}
		ok($count, 3);
	    }
	}
    }
}