[Bioperl-l] Bio::FeatureIO::gff bug?
Chris Fields
cjfields at uiuc.edu
Fri Sep 28 16:04:08 UTC 2007
On Sep 28, 2007, at 10:36 AM, Hilmar Lapp wrote:
> You do have a point here. From a design perspective, it feels odd
> if instantiating an object can fail with an I/O exception. But in
> reality that's how it's done all the time, from Bio::SeqIO to
> java.io.*, if I'm not mistaken. I also agree that asking a
> conditional that we know will be false every time except once
> violates the sense of elegance.
I agree with the lack of elegance from a design perspective on both
counts, but when have we ever been worried about that? ;>
In general I don't think SeqIO classes generates actual output (like
the GFF header information) in the constructor, they just initialize
IO and other state data. It makes sense to fail in this case if an
error pops up. Regardless, one could argue ad infinitum that either
proposed fix has its benefits/deficiencies, however both will work,
so I'm happy with either.
chris
> So upon second consideration, I think I agree with you. And a GFF3
> file with zero features in it should still be a valid GFF3 file,
> i.e., have the mandatory headers.
>
> Does that make sense?
>
> -hilmar
>
> On Sep 25, 2007, at 6:00 AM, Sendu Bala wrote:
>
>> Hilmar Lapp wrote:
>>> On Sep 24, 2007, at 9:35 AM, Chris Fields wrote:
>>>> I think that'll work fine. The other option would be call a
>>>> print_gff_header() function within write_feature() with the
>>>> intent to
>>>> print the header only once, using a flag or similar:
>>>>
>>>> if (!$self->header_printed) {
>>>> $self->print_gff_header;
>>>> $self->header_printed(1);
>>>> }
>> >
>>> I'd lean toward this or a similar approach too. Writing stuff out
>>> in the constructor doesn't feel like the best design.
>>
>> I'd argue that the alternative is just inefficient with no
>> compensating benefit. You have something that must only be done
>> once, and a method (_initialize) that is only called once. The
>> constructor is used to set up the file, getting it into a state
>> ready to add features. This involves opening it for writing with
>> the correct filename and setting the desired GFF version. Why
>> wouldn't it also output what ever else was necessary it initialize
>> the file?
>>
>> Also, what do we expect should happen when we use Bioperl to
>> create a GFF file and don't write any features to it? Should it be
>> an empty file, or should it contain whatever GFF information the
>> user had managed to supply (the version)?
>
> --
> ===========================================================
> : Hilmar Lapp -:- Durham, NC -:- hlapp at gmx dot net :
> ===========================================================
>
>
>
>
>
Christopher Fields
Postdoctoral Researcher
Lab of Dr. Robert Switzer
Dept of Biochemistry
University of Illinois Urbana-Champaign
More information about the Bioperl-l
mailing list