Bioperl: Yet another question about parsing blast results.

carl@cimmed.com carl@cimmed.com
Tue, 16 Nov 1999 14:12:17 +0900


Hi!

First off, let me tell you i'm a newcomer to perl, so my question would
probably be solveable had I more experience.  Perl's quick to learn trivially,
but one rapidly enters regions that require a lot more!
Ok-i'm parsing multiple blast reports which are all put into a single text
file (one file=many blasts reports). The blast reports are
interspersed with many that have hits followed by many with no hits and so on.
Now, i've checked the archives, and that
helped me get going (ie-error trapping) but i still have a small problem, and
that is that the last valid blast report (ie-the last report in the file that
has a hit) seems to not be picked up by my program. The other reports all get
parsed and output. At hte risk of having done something embarrasing, i'll let
you all see me code:
#!/usr/bin/perl 
use Bio::Tools::Blast qw(:obj);
@errs = ();
eval {
$Blast->parse( 	-file=>$ARGV[0],
		-parse     => 1,
               	-exec_func => \&process_blast,
              );
};
if ($@)
{
     push @errs, $@;
     print "error, can't open file or parse a certain report";
}


sub process_blast 
{
        	my $blastObj = shift;
		eval{
	     	$hit = $blastObj->hit('best');   
		};
		if ($@)
		{
			print "************no hits************";
		}
		else
		{
		eval {
		printf "%s\t ", $hit->name;
		};
		print "\n";
		}
        	$blastObj->destroy;  
} 

It's probably simple, but i'm alone here, in a country and company that makes
resources (human ones with skill who can speak english!) difficult to flush out!

Carl
=========== Bioperl Project Mailing List Message Footer =======
Project URL: http://bio.perl.org/
For info about how to (un)subscribe, where messages are archived, etc:
http://www.techfak.uni-bielefeld.de/bcd/Perl/Bio/vsns-bcd-perl.html
====================================================================