[Bioperl-l] BioSeq method errors with BioSQL sequences

Barry Moore barry.moore at genetics.utah.edu
Thu Nov 11 18:34:49 EST 2004

I have code that I have used to grab details from a Bio::Seq object like 

my $locus = $seq->display_name;
my $length = $seq->length;
my $mol_type = $seq->molecule;
my $division = $seq->division;

This works great when called on Bio::Seq created like this:

use Bio::DB::RefSeq;
$db = new Bio::DB::RefSeq;
$seq = $db->get_Seq_by_id('NM_006732');

But I recently switched the to using a local database and getting my 
sequence objects like this:

my $db_adaptor = Bio::DB::BioDB->new(
        -database => 'biosql',
        -user     => 'postgres',
        -dbname   => 'some_db',
        -host     => 'localhost',
        -driver   => 'Pg',
my $tmp_seq = Bio::Seq->new(-accession_number => "$NM_006732",
                            -namespace        => "$ncbi");
my $seqfact = Bio::Seq::SeqFactory->new(-type => "Bio::Seq");
my $adp = $db_adaptor->get_object_adaptor($tmp_seq);
my $seq = $adp->find_by_unique_key($tmp_seq, -obj_factory => $seqfact);

The new seq object seems to behave very nicely under most circumstances 
but it will not execute some methods like these:

my $mol_type = $seq->molecule;
my $division = $seq->division;

I get an error like this:

Can't locate object method "division" via package "Bio::Seq" at 
/usr/local/share/perl/5.6.1/Bio/DB/Persistent/PersistentObject.pm line 
541, <IN> line 1.

I tried to track down where the problem occured and found that in 
AUTOLOAD for Bio/DB/Persistent/PersistentObject.pm on line 534 and error 
was being thrown.

534:        $self->throw("Can't locate object method \"$meth\" via 
package ".
535:                     ref($self))
536:            unless $obj && ($obj ne $self);

Checking ref $obj and ref $self gives Bio::Seq and 
Bio::DB::Persistent::Seq respectively.  That seems to me to indicate 
that the 'unless' above should be satisfied - $obj exist and is not 
equal to $self therefore don't throw.  Running $seq->display_name 
generates the same values for $obj and $self, but it works.  Methods 
molecule and division throw errors.  Any suggestions?



Barry Moore
Dept. of Human Genetics
University of Utah
Salt Lake City, UT

More information about the Bioperl-l mailing list