Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Hash references moving between modules

by derby (Abbot)
on Jan 10, 2003 at 17:59 UTC ( [id://225885]=note: print w/replies, xml ) Need Help??


in reply to Hash references moving between modules

For starters, I don't understand both Bio:DB::Das::Chado and Bio::DB::Das::Chado::Segment being subclasses of Bio::Root::Root ... but besides that I also don't think this line is doing what you want:

return $self->Bio::DB::Das::Chado::Segment->new($name,$self,$start,$end);

shouldn't that just be:

return Bio::DB::Das::Chado::Segment->new($name,$self,$start,$end);

Other than that, are you sure your sql is returning results? If your sql fails, $cvterm_id will never be converted to a hash reference (it will stay a plain scalar) and your code downstream will fail. You probably want something like this to protect the code downstream (or you could check if you have a hash downline):

my $cvterm_id = {} ; # this scalar is a hashref while (my $hashref = $sth->fetchrow_hashref) { $$cvterm_id{$$hashref{termname}} = $$hashref{cvterm_id}; }

Then at least %termhash will be a hash but quite possibly an empty one if the sql fails.

-derby

Replies are listed 'Best First'.
Re: Re: Hash references moving between modules
by scain (Curate) on Jan 10, 2003 at 18:18 UTC
    Ack, that is what I get for trying to simplify too much. First, Bio::Root::Root is the main class from which most BioPerl objects inherit.

    The first line you mention didn't really look like that in my code, it was

    return $self->_segclass->new($name,$self,$start,$end);
    Where _segclass is a private method that returns the string 'Bio::DB::Das::Chado::Segment'. I was trying to hard to trim things down and simplified one thing to make it wrong.

    It is a good point that I should be checking for returned results. In this case, I know that they are from previous debugging. Nevertheless, I will add the = {}; because that is a good idea.

    Thanks,

    Scott
    Project coordinator of the Generic Model Organism Database Project

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://225885]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-23 16:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found