[Bioperl-l] SeqIO fixing: detecting if a filehandle is open for writing

Hilmar Lapp hlapp at gmx.net
Thu Aug 5 09:55:05 EDT 2004

Quite frankly IMNSHO if you open a file for reading and then - 
unsuccessfully - try to write to the file this is not a bioperl error, 
or perl error for that matter, but a programming error. Perl will be no 
more verbose if you do this ... at least as far as I'm aware.

I.e., the documentation should be that if you do an operation to a file 
or SeqIO handle for which you did not open it in the first place then 
the behavior is undefined.


On Thursday, August 5, 2004, at 02:04  PM, Peter van Heusden wrote:

> I'm busy preparing patches to catch the different failure modes of 
> SeqIO's constructor, but I'm stuck with one particular case. What if I 
> open a filehandle for reading, and then pass that filehandle to 
> SeqIO's constructor, and then call write_seq() on the SeqIO object. 
> I.e. like this:
> use IO::File;
> use Bio::SeqIO;
> use Bio::PrimarySeq;
> my $fh = IO::File->new("myfile.fasta") || die "open failed: $!\n";
> my $seqio = Bio::SeqIO->new(-fh => $fh, -format => 'fasta');
> my $seq = new Bio::PrimarySeq(id => 'MYID', seq => 'GATTACCA');
> $seqio->write_seq($seq);
> The current result is that write_seq() silently fails. I'm trying to 
> deal with all misleading error messages & late failures at the moment, 
> but I feel we're going to be left with some cases that can't be 
> avoided in the end.
> Peter
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
Hilmar Lapp                            email: lapp at gnf.org
GNF, San Diego, Ca. 92121              phone: +1-858-812-1757

More information about the Bioperl-l mailing list