[Bioperl-l] searchio scripts

Steve Chervitz steve_chervitz at affymetrix.com
Wed Feb 18 15:16:13 EST 2004


Good tip, Lincoln. But regardless, the change in IO::_readline's 
behavior means that any script that depended on its pre-1.303 
default-to-STDIN behavior is now broken. This could be a lot since the 
code in examples and scripts exploited this. I received three messages 
about it yesterday, so I fear there could be many others out there 
scratching their heads, especially considering that the 
default-to-STDIN behavior has been around since the early days of 
SeqIO. From the SeqIO docs:

>    $seqIO = Bio::SeqIO->new(-format => $format);
>   ....
> If neither a filehandle nor a filename is specified, then the module
> will read from the @ARGV array or STDIN, using the familiar <>
> semantics.

Relying on a default behavior of a dependent module (Root::IO) always 
troubled me. It seems a better design to make it explicit in your 
script where you expect your input to come from. Typing "-fh=>\*ARGV" 
or putting an @ARGV loop around your script is extra work, but I think 
it's a change for the better. (BTW, this situation also exposes a 
weakness in the test code which didn't test the default _readline 
behavior -- I guess doing this is difficult within the Perl test 
framework).

The issue remains: What to do about backwards compatibility? Some 
options:

1. Fix all of the scripts, examples, POD docs, bptutorial etc. to not 
rely on default STDIN/@ARGV reading behavior of _readline and release 
these as part of bioperl-1.4.1.

2. Revert _readline to it's old behavior and add a new method in IO.pm 
that has the new behavior (_readline2). Update any module/script that 
needs the new _readline behaviour to use _readline2.

#2 is the backward-compatible route, but uglier from a software 
engineering perspective. #1 breaks backward compatibility. Given the 
legacy of the old _readline behaviour, I'm favoring #2. Just seems more 
politic. We could still update the scripts and docs to discourage the 
old _readline behaviour. Thoughts?

Steve

On Feb 18, 2004, at 4:57 AM, Lincoln Stein wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Or do this:
>
> 	my $in = Bio::SearchIO->new(-format=>'blast',-fh=>\*ARGV);
> 	while (my $result = $in->next_result()) {
> 		...
> 	}
>
> That might even be easier.
>
> Lincoln
>
> On Wednesday 18 February 2004 12:27 pm, Steve Chervitz wrote:
>> Looks like there was a change in the Root::IO.pm module that
>> affects the way these scripts process command-line arguments. As of
>> bioperl-1.303, the SearchIO::blast module appears to be unable to
>> read data from STDIN or files listed in @ARGV. This affects the
>> scripts in examples/searchio and scripts/searchio.
>>
>> As a workaround, I'd recommend you iterate over @ARGV in your
>> script and initialize the SearchIO object using the -file option to
>> new(), as in:
>>
>> while (my $file = shift @ARGV) {
>>      my $in = Bio::SearchIO->new( -format => 'blast',
>>                                   -file => $file
>>                                 );
>>      while ( my $result = $in->next_result() ) {
>>          # process result...
>>      }
>> }
>>
>> As far as tracking down the cause, I've pinpointed the following
>> change in Bio::Root::IO::_readline():
>>
>>      my $fh = $self->_fh or return;   # revision 1.50
>> (bioperl-1.303)
>>
>> formerly this was:
>>
>>      my $fh = $self->_fh || \*ARGV;   # revision 1.49
>> (bioperl-1.302)
>>
>> This also appears to break SeqIO reading from STDIN. Try executing
>> this at the top-level distribution dir for the 1.302 and 1.303
>> releases:
>>
>>      perl -I. ./scripts/seq/translate_seq.PLS -format fasta <
>> t/data/dna1.fa
>>
>> According to Lincoln's commit log, the Root::IO::_readline() change
>> was necessary to get the GFF, SeqFeature, and Registry regression
>> tests working. I tested these tests with the 1.49 version of IO.pm
>> and the only one that was affected was SeqFeature.t. Specifically,
>> test #6 which calls SeqFeature::Generic::gff_string() hangs and
>> waits for input before proceeding. I'm not sure why this is...
>> (getting late).
>>
>> BTW, platforms tested: Perl 5.6.1 and 5.8.0 on Linux (RH9) and Perl
>> 5.8.1-RC3 on MacOS X (10.3.2).
>>
>> Steve
>>
>> On Feb 17, 2004, at 3:14 PM, Richard Rouse wrote:
>>> I recent installed bioperl-1.4 and am having problems with the
>>> blast report
>>> parsers in /examples/searchio/
>>>
>>>
>>> When I run:
>>> perl hitwriter.pl blastreport
>>> I get:
>>>
>>> Using SearchIO->new()
>>>
>>> 0 Blast report(s) processed.
>>> Output sent to file: >hitwriter.out
>>>
>>> I get the same result with rawwriter.pl, hspwriter.pl and
>>> custom_writer.pl
>>> although the htmlwriter.pl and the blast_example.pl work fine.
>>>
>>> Has anyone else encountered this problem and figured out how to
>>> fix it?
>>>
>>> Thanks,
>>>
>>> Richard
>>>
>>>
>>> _______________________________________________
>>> Bioperl-l mailing list
>>> Bioperl-l at portal.open-bio.org
>>> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>>
>> _______________________________________________
>> Bioperl-l mailing list
>> Bioperl-l at portal.open-bio.org
>> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>
> - --
> Lincoln D. Stein
> Cold Spring Harbor Laboratory
> 1 Bungtown Road
> Cold Spring Harbor, NY 11724
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)
>
> iD8DBQFAM2E00CIvUP7P+AkRAurTAJ9gwb4Os0M5uDWhlE40JphLRIAG+gCfQ5Ji
> zXHLGwtfDAB2Np2nKBZkuw0=
> =IsKs
> -----END PGP SIGNATURE-----
>



More information about the Bioperl-l mailing list