Bioperl: Accessing sequences via Bio::DB::SeqI
Ewan Birney
birney@ebi.ac.uk
Mon, 1 May 2000 21:02:39 +0100 (BST)
On Mon, 1 May 2000, Mark Dalphin wrote:
> Thanks for the reply, Ewan. I have a further naive quetion about the use of the
> modules:
>
> Following on from my earlier letter, I see now that Bio::DB::GenBank.pm ISA
> RandomAccessI.pm and that SeqI.pm ISA a RandomAccessI.pm. And I understand your
> design in making SeqI.pm a superset of RandomAccessI.pm.
>
> Where I am stuck is in "Why is RandomAccessI.pm ISA RootI.pm?" One needs to
> eventiually inherit from a concrete class, I would think. In that case, I would
> think that RandomAccessI.pm ISA Bio::Root::Object.pm would make more sense. Then one
> could write:
This is complex, so I appreciate your confusion. The RootI inheritance is
correct. The interfaces should not mandate a particular implementation.
The thing to keep in mind is that one might have a _radically_ different
implementation behind an interface. The best example I know are C structs
bound in via XS, providing hyper-fast bioperl "objects" without being
implemented at all in Perl. It is very cute. (and works ...)
This means that every interface should now inheriet from either another
interface or RootI. By inherieting from RootI we can be sure that
->throw, ->warn will work wherever you are in bioperl.
I have not done this transition yet for all interfaces. There is alot of
cruft to refactor out there (the _abstractDeath method calls in some of
our earlier interfaces can be translated to ->throw).
For concrete classes, such as GenBank, written as "vanilla bioperl" you
should inheriet from the interface (which should inheriet from RootI) and
from Bio::Root::Object for the base implementation. (or some other
concrete class for a base implementation).
This should be described at the end of biodesign.pod. If you would like to
update that to make it clearer that would be great - documentation should
generally be written (or at leasted reviewed) by someone who didn't
program it.
>
> package Bio::DB::SeqStore;
> use Bio::DB::RandomAccessI.pm
> @ISA = qw(Bio::DB::RandomAccessI); # I am a concrete example derived from this
> abstract class
>
> Now I can directly inherit 'new()' from the Bio::Root::Object, via the RandomAccessI
>
> On the other hand, if RandomAccessI.pm ISA Bio::Root:RootI, then I need to _also_
> add to the ISA Bio::Root::Object. Doesn't this defeat the purpose of inheriting
> here? (I see that this is what GenBank.pm does).
>
This as expected. You should get used to thinking about two separate
inheritance hierarchies for each object --->
The 'type' inheritance via 'interface' (I) classes
The implementation base class (for vanilla bioperl, from
Bio::Root::Object).
Of course, the implementation base class might have a type inherietance
as well - so you have to be careful.
> Mark
>
> --
> Mark Dalphin email: mdalphin@amgen.com
> Mail Stop: 29-2-A phone: +1-805-447-4951 (work)
> One Amgen Center Drive +1-805-375-0680 (home)
> Thousand Oaks, CA 91320 fax: +1-805-499-9955 (work)
>
>
>
-----------------------------------------------------------------
Ewan Birney. Mobile: +44 (0)7970 151230, Work: +44 1223 494420
<birney@ebi.ac.uk>.
-----------------------------------------------------------------
=========== Bioperl Project Mailing List Message Footer =======
Project URL: http://bio.perl.org/
For info about how to (un)subscribe, where messages are archived, etc:
http://www.techfak.uni-bielefeld.de/bcd/Perl/Bio/vsns-bcd-perl.html
====================================================================