Index: Bio/Tools/Run/RemoteBlast.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/Bio/Tools/Run/RemoteBlast.pm,v
retrieving revision 1.21
diff -a -u -r1.21 RemoteBlast.pm
--- Bio/Tools/Run/RemoteBlast.pm	17 Nov 2004 23:54:50 -0000	1.21
+++ Bio/Tools/Run/RemoteBlast.pm	1 Apr 2005 16:35:45 -0000
@@ -176,8 +176,8 @@
 	'OTHER_ADVANCED' => '.*',
 	'PERC_IDENT'	=> '\d\d+',			# Integer, 0-99 inclusive
 	'PHI_PATTERN'	=> '.*',
-	'PROGRAM'	=> 't?blast[pnx]',
-					# tblastp, tblastn, tblastx, blastp, blastn, blastx
+	'PROGRAM'	=> '(blastp|t?blast[nx])',
+					# tblastn, tblastx, blastp, blastn, blastx
 	'QUERY'		=> '.*',
 	'QUERY_FILE'	=> '.*',
 	'QUERY_BELIEVE_DEFLINE'	=> '(yes|no)',		# yes, no
@@ -216,24 +216,22 @@
 					  );
 
     # Default values go in here for PUT
-    %HEADER = (
-          'CMD'                          => 'Put',
+    %HEADER = ('CMD'                          => 'Put',
 	       'FORMAT_OBJECT'                => 'Alignment',
 	       'COMPOSITION_BASED_STATISTICS' => 'off', 
-	       'DATABASE'	    	              => 'nr',
-	       'EXPECT'			              => '1e-3', 
-	       'FILTER'			              => 'L', 
-	       'PROGRAM'		                 => 'blastp', 
-	       'SERVICE'		                 => 'plain' 
+	       'DATABASE'    	              => 'nr',
+	       'EXPECT'		              => '1e-3', 
+	       'FILTER'		              => 'L', 
+	       'PROGRAM'	              => 'blastp', 
+	       'SERVICE'	              => 'plain' 
 	       );
 
     # Default values go in here for GET
-    %RETRIEVALHEADER = (
-         'CMD'            => 'Get',
-			'ALIGNMENTS'	  => '50',
+    %RETRIEVALHEADER = ('CMD'            => 'Get',
+			'ALIGNMENTS'      => '50',
 			'ALIGNMENT_VIEW' => 'Pairwise',
-			'DESCRIPTIONS'	  => '100',
-			'FORMAT_TYPE'	  => 'Text'
+			'DESCRIPTIONS'	 => '100',
+			'FORMAT_TYPE'	 => 'Text'
 			);
 
     $RIDLINE = 'RID\s+=\s+(\S+)';
@@ -495,8 +493,8 @@
 	$header{'QUERY'} = ">".(defined $seq->display_id() ? $seq->display_id() : "").
 		" ".(defined $seq->desc() ? $seq->desc() : "")."\n".$seq->seq();
 	my $request = POST $URLBASE, [%header];
-	$self->warn($request->as_string) if ( $self->verbose > 0);
-	my $response = $self->ua->request( $request);
+	$self->warn($request->as_string) if ($self->verbose > 0);
+	my $response = $self->ua->request($request);
 
 	if( $response->is_success ) {
 	    my @subdata = split(/\n/, $response->content );
@@ -549,37 +547,46 @@
 	}
 	my $response = $self->ua->request($req, $tempfile);
 	if( $response->is_success ) {
-    	if( $self->verbose > 0 ) {
-			#print content of reply if verbose > 1
-			open(TMP, $tempfile) or $self->throw("cannot open $tempfile");
-			while(<TMP>) { print $_; }
-			close TMP;
-		}
-		## if proper reply 
-		my $size = -s $tempfile;
-		if( $size > 1000 ) {
+	    # read file until QBlastInfoEnd to pull out status
+	    my $status = '';
+	    my $junk = '';
+	    open(TMP, $tempfile) or $self->throw("cannot open $tempfile");
+	    while( defined (my $line = <TMP>) ) {
+		last if ($line =~ /QBlastInfoEnd/);
+		($junk, $status) = (split /=/, $line) if ($line =~ /waiting|ready/i); 
+	    }
+	    close TMP;
+
+	    if( $self->verbose > 0 ) {
+		#print content of reply if verbose > 1
+		open(TMP, $tempfile) or $self->throw("cannot open $tempfile");
+		while(<TMP>) { print $_; }
+		close TMP;
+	    }
+	    # Check job status
+	    if ( $status =~ /waiting/i ) {
+		return 0;
+	    } elsif ( $status =~ /ready/i ) {
 	    	my $blastobj;
-			if( $self->readmethod =~ /BPlite/ ) {
-				$blastobj = new Bio::Tools::BPlite(-file => $tempfile);
+		if( $self->readmethod =~ /BPlite/ ) {
+		    $blastobj = new Bio::Tools::BPlite(-file => $tempfile);
 	    	} else {
-				$blastobj = new Bio::SearchIO( -file     => $tempfile,
-														 -format => 'blast');
-			}
+		    $blastobj = new Bio::SearchIO( -file     => $tempfile,
+						   -format => 'blast');
+		}
 
-			## store filename in object ##
-			$self->file($tempfile);
+		## store filename in object ##
+		$self->file($tempfile);
 	    	return $blastobj;
-		} elsif( $size < 500 ) { # search had a problem
-			open(ERR, "<$tempfile") or $self->throw("cannot open file $tempfile"); 
-			$self->warn(join("", <ERR>));
-			close ERR;
+	    } else { # search had a problem
+		open(ERR, "<$tempfile") or $self->throw("cannot open file $tempfile"); 
+		$self->warn(join("", <ERR>));
+		close ERR;
 	    	return -1;
-		} else { # still working
-	    	return 0;
-		}
+	    }
 	} else {
-		$self->warn($response->error_as_HTML);
-		return -1;
+	    $self->warn($response->error_as_HTML);
+	    return -1;
 	}
 }
 
