Bioperl-guts: Re: Bioperl:Bio:Tools:Blast-> parse - failing on the first report in stream

Bradford Powell powellb@med.unc.edu
Wed, 04 Aug 1999 23:43:34 -0400


Michael B. Thornton wrote:
> 
> Hi All,
> 
> I have just started to use the bioperl package, in jest for now, but very
> soon in anger.
> I would eventually like to take lots of blast reports streaming in on stdin
> and do things to them.  To that
> end I have a very simple perl script, pretty much lifted from the Blast.pm
> docs plus stuff
> reccommended by Steve Chervitz on this board.  When I feed a stream of blast
> reports to my script (below)
> I get a fatal exception, *only*  for the first blast report.  The exception
> is as follows:
 <Error removed for space reasons>

Michael (and list),

This is actually the same problem as bug #74, which I did not completely
understand when I submitted it, but I think I have a better grasp on it
now. It is either a bug in IOManager.pm, or the example blast_seq.pl,
because they don't get along.

The problem is that IOManager::read sets $/ (the input record separator)
to something other than '\n'. In the case of this instance, and in the
case of blast_seq.pl, it gets set to "\n>" (to delimit fasta records).
The sticky point is that -exec_func is a callback that gets called from
within IOManager::read, and thus inheirits the local $/. At least that's
what I think is happening. It is actually documented, though hard to
find, by nature of the fact that IOManager is used indirectly. From
IOManager.pm:

           :    -REC_SEP => record separator to be used
           :                when reading in raw data. If none is
supplied,
           :                the default record separator is used ($/).
           :                $/ is localized to this method but be
careful if
           :                you do any additional file reading in
functions
           :                called by this method (see the -FUNC
parameter).
           :                Such methods will use the value of $/ set
           :                by read() (if a -REC_SEP is supplied).

A temporary work-around is to have your process_blast function reset the
value of $/, possibly by making the first line of the function.

	local $/ = '\n';

I think this will solve the problem.

In the longer run, I think this is a confusing issue, and perhaps
IOManager::read should keep its $/ to itself, perhaps by storing the
original value in a temp var and reseting it before calling -exec_func,
then putting it right back to -REC_SEP upon returning. Does this seem
reasonable? Can anyone think of a cleaner way to do this? At the least I
think this 'feature' would be documented more clearly in Blast.pm, where
the -exec_func is defined.

-- Bradford Powell
-- bradford_powell@med.unc.edu
=========== 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-guts.html
====================================================================