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

Bradford Powell
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
> 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, or the example,
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, 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

           :    -REC_SEP => record separator to be used
           :                when reading in raw data. If none is
           :                the default record separator is used ($/).
           :                $/ is localized to this method but be
careful if
           :                you do any additional file reading in
           :                called by this method (see the -FUNC
           :                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, where
the -exec_func is defined.

-- Bradford Powell
=========== Bioperl Project Mailing List Message Footer =======
Project URL:
For info about how to (un)subscribe, where messages are archived, etc: