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

Peter van Heusden pvh at egenetics.com
Thu Aug 5 09:04:20 EDT 2004

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');


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.


More information about the Bioperl-l mailing list