[Bioperl-l] Problems with revcom and translate in PrimarySeqI

David Block dblock@gene.pbi.nrc.ca
Mon, 11 Dec 2000 14:06:57 -0600 (CST)

I've been working with the main trunk - I know, I know, but I'm a big boy,
I can handle it.

I get tons of errors when trying to either revcom or translate a
PrimarySeq.  It seems that can_call_new=1 for PrimarySeq objects, but new
is not implemented properly, because it simply defaults to RootI's
new.  That expects a class as first argument, but gets an object instance,
which screws it up, since the class is now

This leads to the error:

Can't locate object method "_initialize" via package
"Bio::PrimarySeq=HASH(0x11392918)" at
/home/dave/bioperl/bioperl-live/Bio/Root/RootI.pm line 79.

Two possible fixes - RootI could check to see if $class being sent to it
is a reference, and if so, make $class the class of $class (now that was
clear), or
Bio::PrimarySeq could return 0 for can_call_new, which would lead to
proper behaviour in this case (I think).

Code for the first fix (due to Damian Conway, OOPerl):
sub new {
    my ($caller, @arg) = @_;
    my $caller_is_obj = ref($caller);
    my $class = $caller_is_obj || $caller;
    my $self = bless {}, $class;

This is what we do in Workbench, and it works fine.
David Block
Plant Biotechnology Institute
National Research Council of Canada
Saskatoon, Saskatchewan