Bio::DB::BioSQL::mysql TermAdaptorDriver
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvs
Summary
Bio::DB::BioSQL::mysql::TermAdaptorDriver - DESCRIPTION of Object
Package variables
No package variables defined.
Included modules
Bio::DB::BioSQL::mysql::BasePersistenceAdaptorDriver
Inherit
Bio::DB::BioSQL::mysql::BasePersistenceAdaptorDriver
Synopsis
Give standard usage here
Description
Describe the object here
Methods
remove_synonymsDescriptionCode
store_synonymDescriptionCode
_build_sth
No description
Code
get_synonymsDescriptionCode
Methods description
remove_synonymscode    nextTop
 Title   : remove_synonyms
Usage :
Function: Removes all synonyms for an ontology term.
Example :
Returns : TRUE on success, and FALSE otherwise.
Args : The calling persistence adaptor.
The persistent term object for which to remove the synonyms (a Bio::DB::PersistentObjectI compliant object with defined primary key).
store_synonymcodeprevnextTop
 Title   : store_synonym
Usage :
Function: Stores a synonym for an ontology term.
Example :
Returns : TRUE on success, and FALSE otherwise.
Args : The calling persistence adaptor.
The persistent term object for which to store the synonym (a Bio::DB::PersistentObjectI compliant object with defined primary key). The synonym to store (a scalar).
get_synonymscodeprevnextTop
 Title   : get_synonyms
Usage :
Function: Retrieves the synonyms for an ontology term and adds them
the term's synonyms.
Example :
Returns : TRUE on success, and FALSE otherwise.
Args : The calling persistence adaptor.
The persistent term object for which to retrieve the synonyms (a Bio::DB::PersistentObjectI compliant object with defined primary key).
Methods code
remove_synonymsdescriptionprevnextTop
sub remove_synonyms {
    my ($self,$adp,$obj) = @_;

    # delete statement cached?
my $cachekey = "DELETE SYNONYMS"; my $sth = $adp->sth($cachekey); # if not we need to build it
if(! $sth) { # we need table name and foreign key
my $table = $self->table_name("TermSynonym"); my $fkname = $self->foreign_key_name($obj->obj); # build, prepare, and cache the SQL statement
$sth = $self->_build_sth($adp, $cachekey, "DELETE FROM $table WHERE $fkname = ?"); } # bind parameters and execute insert
my $dbgmsg = "executing with values (". $obj->primary_key().") (FK to ".ref($obj->obj).")"; $adp->debug("$cachekey: $dbgmsg\n"); my $rv = $sth->execute($obj->primary_key()); if(! $rv) { $self->warn("failed to remove term synonyms (".ref($adp) .") with values (".$obj->primary_key() .") (FK to ".ref($obj->obj)."):\n".$sth->errstr()); } return $rv;
}
store_synonymdescriptionprevnextTop
sub store_synonym {
    my ($self,$adp,$obj,$syn) = @_;

    # insert and look-up statements cached?
my $icachekey = "INSERT SYNONYM"; my $isth = $adp->sth($icachekey); # if not we need to build them
if(! $isth) { # we need table name, foreign key, and slot map
my $table = $self->table_name("TermSynonym"); my $fkname = $self->foreign_key_name($obj->obj); my $colmap = $self->slot_attribute_map($table); # build, prepare, and cache the SQL statements
$isth = $self->_build_sth($adp, $icachekey, "INSERT INTO $table (". join(", ", $colmap->{'synonym'}, $fkname). ") VALUES (?, ?)"); } # bind parameters and execute insert
my $dbgmsg = "executing with values ($syn, ". $obj->primary_key().") (synonym, FK to ".ref($obj->obj).")"; $adp->debug("$icachekey: $dbgmsg\n"); my $rv = $isth->execute($syn, $obj->primary_key()); if(! $rv) { # this might be a UK failure, not a bad statement error
if (index($isth->errstr(), "Duplicate entry") >= 0) { # we actually don't need to execute a look-up here because the
# synonym is not an object and hence has no primary key itself
$rv = "0E0"; # evaluates to TRUE, but numerically equals zero
} else { $self->warn("failed to store term synonym (".ref($adp) .") with values ($syn) (FK ".$obj->primary_key() ." to ".ref($obj->obj)."):\n" .$isth->errstr()); } } return $rv;
}
_build_sthdescriptionprevnextTop
sub _build_sth {
    my ($self,$adp,$cachekey,$sql) = @_;
    # prepare and cache
$adp->debug("$cachekey: preparing: $sql\n"); my $sth = $adp->dbh->prepare($sql); $self->throw("failed to prepare\" $sql\": ".$adp->dbh->errstr) unless $sth; $adp->sth($cachekey,$sth); return $sth;
}
get_synonymsdescriptionprevnextTop
sub get_synonyms {
    my ($self,$adp,$obj) = @_;

    # look-up statement cached?
my $cachekey = "SELECT SYNONYMS"; my $sth = $adp->sth($cachekey); # if not we need to build it
if(! $sth) { # we need table name, foreign key, and slot map
my $table = $self->table_name("TermSynonym"); my $fkname = $self->foreign_key_name($obj->obj); my $colmap = $self->slot_attribute_map($table); # build, prepare, and cache the SQL statement
$sth = $self->_build_sth($adp, $cachekey, "SELECT ".$colmap->{'synonym'}. " FROM $table WHERE $fkname = ?"); } # bind parameters and execute select
my $dbgmsg = "executing with values (". $obj->primary_key().") (FK to ".ref($obj->obj).")"; $adp->debug("$cachekey: $dbgmsg\n"); my $rv = $sth->execute($obj->primary_key()); $self->warn("failed to execute $cachekey: ".$sth->errstr) unless $rv; while(my $row = $sth->fetchrow_arrayref()) { $obj->add_synonym($row->[0]); } return $rv; } 1;
}
General documentation
FEEDBACKTop
Mailing ListsTop
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.
  bioperl-l@bioperl.org                  - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
Support Top
 
Please direct usage questions or support issues to the mailing list:

bioperl-l@bioperl.org

rather than to the module maintainer directly. Many experienced and
reponsive experts will be able look at the problem and quickly
address it. Please include a thorough description of the problem
with code and data examples if at all possible.
Reporting BugsTop
Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via
the web:
  http://bugzilla.open-bio.org/
AUTHOR - Hilmar LappTop
Email hlapp at gmx.net
CONTRIBUTORSTop
Additional contributors names and emails here
APPENDIXTop
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _