BioPerl-DB
view release on metacpan or search on metacpan
lib/Bio/DB/BioSQL/SpeciesAdaptor.pm view on Meta::CPAN
# an explicit variant overwrites
$obj->variant($rows->[5]) if $rows->[5] && ($rows->[5] ne "-");
# check for common name if not already in the result
if(! $obj->common_name()) {
my $cname = $self->get_common_name($rows->[0]);
$obj->common_name($cname) if $cname;
}
# primary key
if($obj->isa("Bio::DB::PersistentObjectI")) {
$obj->primary_key($rows->[0]);
}
return $obj;
}
return undef;
}
=head2 get_unique_key_query
Title : get_unique_key_query
Usage :
Function: Obtain the suitable unique key slots and values as determined by the
attribute values of the given object and the additional foreign
key objects, in case foreign keys participate in a UK.
Example :
Returns : One or more references to hash(es) where each hash
represents one unique key, and the keys of each hash
represent the names of the object's slots that are part of
the particular unique key and their values are the values
of those slots as suitable for the key.
Args : The object with those attributes set that constitute the chosen
unique key (note that the class of the object will be suitable for
the adaptor).
A reference to an array of foreign key objects if not retrievable
from the object itself.
=cut
sub get_unique_key_query{
my ($self,$obj,$fkobjs) = @_;
my $uk_h = {};
# UKs for species are full binomial with variant, and ncbi_taxid
if($obj->ncbi_taxid()) {
$uk_h->{'ncbi_taxid'} = $obj->ncbi_taxid();
$uk_h->{'name_class'} = "scientific name";
} elsif($obj->binomial()) {
$uk_h->{'binomial'} = $obj->binomial('full');
$uk_h->{'binomial'} .= " ".$obj->variant() if $obj->variant();
$uk_h->{'name_class'} = "scientific name";
}
return $uk_h;
}
=head2 remove_children
Title : remove_children
Usage :
Function: This method is to cascade deletes in maintained objects.
We just return TRUE here.
Example :
Returns : TRUE on success and FALSE otherwise
Args : The persistent object that was just removed from the database.
Additional (named) parameter, as passed to remove().
=cut
sub remove_children{
return 1;
}
=head2 get_classification
Title : get_classification
Usage :
Function: Returns the classification array for a taxon as identified by
its primary key.
Example :
Returns : a reference to an array of two-element arrays, where the first
element contains the name of the node and the second element
denotes its rank
Args : the primary key of the taxon
=cut
sub get_classification{
my $self = shift;
return $self->dbd->get_classification($self,@_);
}
=head2 get_common_name
Title : get_common_name
Usage :
Function: Get the common name for a taxon as identified by its primary
key.
Example :
Returns : a string denoting the common name
Args : the primary key of the taxon
=cut
sub get_common_name{
my $self = shift;
return $self->dbd->get_common_name($self,@_);
}
1;
( run in 1.496 second using v1.01-cache-2.11-cpan-39bf76dae61 )