[Bioperl-l] Problems with revcom and translate in PrimarySeqI
Hilmar Lapp
lapp@gnf.org
Mon, 11 Dec 2000 16:17:43 -0800
Jason Stajich wrote:
>
> Yes, this was a problem I fixed in my local copy of the code, but did not
> propigate out because I am confused.
>
> Do we want to have a generic new routine in RootI which can be overriden
> by classes that need special attention (Bio::SeqIO::* classes
> explicitly describe new otherwise they will get the new from the class
> they are extends - Bio::SeqIO)? I am fine with a generic 'new' in RootI,
> but there has been a little bit back and forth on this.
>
> What did we finally decide was the Right way?
>
I don't know, to be honest. I've still not seen an agreed-upon template.
For me initialization chaining is still hard to imagine without chaining to
the inherited method, and how do you know that you will stay inheriting
right from RootI. So the safest way would then be that RootI::new() becomes
the routine creating the object, all other just poke with the hash.
E.g.:
package Bio::Root::RootI;
sub new {
my ($class, @args) = @_;
my $obj = bless {}, ref($class) || $class;
return $obj;
}
package SomePkg::ClassA;
use Bio::Root::RootI;
@ISA = (Bio::Root::RootI);
sub new {
my ($class, @args) = @_;
my $obj = $class->SUPER::new(@_);
# do our own initialization
# $obj->{'somekey'} = "blabla"; ...
return $obj;
}
package SomePkg::ClassB;
use SomePkg::ClassA;
@ISA = (SomePkg::ClassA);
sub new {
my ($class, @args) = @_;
my $obj = $class->SUPER::new(@_);
# do our own initialization
# ...
return $obj;
}
This should work (it actually does on my machine) whether or not new() is
called on a class or an object. We don't even need can_call_new(). Am I
missing something? Too complicated or too simple?
Hilmar
--
-------------------------------------------------------------
Hilmar Lapp email: lapp@gnf.org
GNF, San Diego, Ca. 92121 phone: +1-858-812-1757
-------------------------------------------------------------