[Bioperl-l] Pushing towards 1.0

Hilmar Lapp hlapp@gmx.net
Sun, 16 Dec 2001 15:00:57 -0800


Ewan Birney wrote:
> 
> One minor point - I don't think even that separating out the Factories
> help real extensibility.

I'm not 100% sure we're talking about the same thing. What
basically my concern is that the class of objects built is
hard-wired, which prevents extensibility. E.g., all SeqIO parsers
have a statement similar to

    my $seq = Bio::Seq->new(...some initialization stuff...);
    return $seq;

in the next_seq() (or called) method. Recently we introduced
RichSeq so that now the Genbank/Embl/SP parsers deviate, but not
in principal:

    my $seq = Bio::Seq::RichSeq->new(...whatever...);

Now suppose that I want a seq object with a certain functionality
that only 5 other people in the world may want to share. The
options I'm left with is a) hack Bio::Seq.pm in my local bioperl
copy, b) hack Bio::SeqIO::Genbank.pm in my local copy, c) clone
the Bio::Seq object into my own MyStuff::MySeq instance, d)
copy-and-paste my own Bio::Seq.pm. None of those is nice in
OO-style.

With a factory this becomes the following:

	my $seq = $self->seq_factory()->create_seq();
        # initialization as arguments to the call before or
afterwards method-by-method

In order to get your module in, you pass your own factory (which
has to implement a create_seq() method):

	my $seqio = Bio::SeqIO->new(...whatever...);
	$seqio->seq_factory($my_seq_factory);

and that's it. (Of course you also need to write MyStuff::MySeq.pm
which e.g. inherits everything from Bio::Seq and only adds your
special methods. MyStuff::MySeqFactory would create MyStuff::MySeq
instances.)

Recently someone emailed me with a request for a is_single()
method in Exon.pm. I don't want to implement this because you end
up with a nightmare in having to manage an exon's context within
the exon object instead of the container. Now, extending Exon.pm
yourself is easy enough, but if you use e.g. the Genscan parser,
that one has the exon class to be instantiated hard-wired, so
yours won't be used. With a factory, people simply have to write
their own factory (which has to be kept simple enough), and extend
the class they find too limited, and that's it.

The $location->coordinate_policy expemplifies this, too. You can
plug whatever policy makes you happy about interpreting fuzzy
locations to point locations.

Is this the same you meant?

	-hilmar
-- 
-----------------------------------------------------------------
Hilmar Lapp                              email: hilmarl@yahoo.com
San Diego, Ca. 92130                     phone: +1 858 812 1757
-----------------------------------------------------------------