Bio::EnsEMBL::Funcgen
Storable
Toolbar
Summary
Bio::EnsEMBL::Funcgen::Storable
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
my $dbID = $storable_object->dbID();
my $adaptor = $storable_object->adaptor();
if($storable_object->is_stored($db_adaptor))) {
}
Description
This is a simple wrapper class to provide convenience methods for the StorableAdaptor.
Only get type methods have been implemented here to avoid obfuscating DB writes which
should only be done by the specific 'Storable'Adaptors.
Methods
Methods description
Arg [1] : Bio::EnsEMBL::DBEntry $dbe The dbEntry to be added Example : my $dbe = Bio::EnsEMBL::DBEntery->new(...); $transcript->add_DBEntry($dbe); Description: Associates a DBEntry with this transcript. Note that adding DBEntries will prevent future lazy-loading of DBEntries for this storable (see get_all_DBEntries). Returntype : none Exceptions : thrown on incorrect argument type Caller : general Status : Stable |
Example : $ec->add_state('DISPLAYABLE'); Description: Adds a state to a new or previously stored Storable Returntype : None Exceptions : Throws if no status supplied Caller : general Status : At risk |
Arg[1] : string - External DB name e.g. ensembl_core_Gene Arg[2] : string - External DB type Example : my @dbentries = @{ $set_feature->get_all_DBEntries }; Description: Retrieves DBEntries (xrefs) for this SetFeature. This does _not_ include the corresponding translations DBEntries (see get_all_DBLinks).
This method will attempt to lazy-load DBEntries from a
database if an adaptor is available and no DBEntries are present
on the SetFeature (i.e. they have not already been added or
loaded).
Returntype : Listref of Bio::EnsEMBL::DBEntry objects
Exceptions : none
Caller : general, get_all_DBLinks
Status : Stable - at risk move to storable |
Example : my @gene_dbentries = @{ $storable->get_all_Gene_DBEntries }; Description: Retrieves Ensembl Gene DBEntries (xrefs) for this Storable. This does _not_ include the corresponding translations DBEntries (see get_all_DBLinks).
This method will attempt to lazy-load DBEntries from a
database if an adaptor is available and no DBEntries are present
on the transcript (i.e. they have not already been added or
loaded).
Returntype : Listref of Bio::EnsEMBL::DBEntry objects
Exceptions : none
Caller : general
Status : at risk |
Example : my @transc_dbentries = @{ $set_feature->get_all_Transcript_DBEntries }; Description: Retrieves ensembl Transcript DBEntries (xrefs) for this Storable. This does _not_ include the corresponding translations DBEntries (see get_all_DBLinks).
This method will attempt to lazy-load DBEntries from a
database if an adaptor is available and no DBEntries are present
on the Storable (i.e. they have not already been added or
loaded).
Returntype : Listref of Bio::EnsEMBL::DBEntry objects
Exceptions : none
Caller : general
Status : at risk |
Example : my @ec_states = @{$experimental_chip->get_all_states()}; Description: Retrieves all states from DB and merges with current states array Returntype : LISTREF Exceptions : None Caller : general Status : At risk |
Arg [1] : string - status e.g. IMPORTED, DISPLAYABLE Example : if($experimental_chip->has_status('IMPORTED'){ ... skip import ... }; Description: Tests whether storable has a given status Returntype : BOOLEAN Exceptions : Throws if not status is provided Caller : general Status : At risk |
Arg [-STATES] : Arrayref of states Arg [-dbID] : database internal id Example : none Caller : internal calls Description : create a new Storable object Returntype : Bio::EnsEMBL::Storable Exceptions : Adaptor not a Bio::EnsEMBL::Funcgen::DBSQL::BaseAdaptor Status : Stable |
Methods code
sub add_DBEntry
{ my $self = shift;
my $dbe = shift;
unless($dbe && ref($dbe) && $dbe->isa('Bio::EnsEMBL::DBEntry')) {
throw('Expected DBEntry argument');
}
$self->{'dbentries'} ||= [];
push @{$self->{'dbentries'}}, $dbe;
}
1; } |
sub add_status
{ my ($self, $status) = @_;
throw("Must pass a status to add e.g. 'DISPLAYABLE'") if ! $status;
if($self->adaptor && $self->is_stored($self->adaptor->db()) && ! $self->{'states'}){
@{$self->{'states'}} = @{$self->adaptor->fetch_all_states($self)};
}
push @{$self->{'states'}}, $status;
return; } |
sub get_all_DBEntries
{ my $self = shift;
my $ex_db_exp = shift;
my $ex_db_type = shift;
my $cache_name = "dbentries";
if(defined($ex_db_exp)){
$cache_name .= $ex_db_exp;
}
if(defined($ex_db_type)){
$cache_name .= $ex_db_type;
}
my @tables = $self->adaptor->_tables;
if(!defined $self->{$cache_name} && $self->adaptor()) {
my @tables = $self->adaptor->_tables;
@tables = split/_/, $tables[0]->[0]; my $object_type = join('', (map ucfirst($_), @tables));
$self->{$cache_name} =
$self->adaptor->db->get_DBEntryAdaptor->_fetch_by_object_type($self->dbID(), $object_type, $ex_db_exp, $ex_db_type);
}
$self->{$cache_name} ||= [];
return $self->{$cache_name}; } |
sub get_all_Gene_DBEntries
{ my $self = shift;
my $species = $self->adaptor->db->species;
if(!$species){
throw('You must specify a DBAdaptor -species to retrieve DBEntries based on the external_db.db_name');
}
($species = lc($species)) =~ s/ /_/;
return $self->get_all_DBEntries($species.'_core_Gene'); } |
sub get_all_Transcript_DBEntries
{ my $self = shift;
my $species = $self->adaptor->db->species;
if(!$species){
throw('You must specify a DBAdaptor -species to retrieve DBEntries based on the external_db.db_name');
}
($species = lc($species)) =~ s/ /_/;
return $self->get_all_DBEntries($species.'_core_Transcript'); } |
sub get_all_states
{ my ($self) = @_;
my %states;
if($self->is_stored($self->adaptor->db()) && ! $self->{'states'}){
@{$self->{'states'}} = @{$self->adaptor->fetch_all_states($self)};
}
return $self->{'states'}; } |
sub has_status
{ my ($self, $status) = @_;
throw("Must provide a status to check") if ! $status;
my @state = grep(/$status/, @{$self->get_all_states()});
my $boolean = scalar(@state);
return $boolean;
}
} |
sub is_displayable
{ my $self = shift;
return $self->has_status('DISPLAYABLE');
}
} |
sub new
{ my $caller = shift;
my $class = ref($caller) || $caller;
my $self = $class->SUPER::new(@_);
my ($states) = rearrange(['STATES'],@_);
if ($self->adaptor() && (! $self->adaptor->isa("Bio::EnsEMBL::Funcgen::DBSQL::BaseAdaptor"))){
throw("Adaptor muct be a valid Bio::EnsEMBL::Funcgen::DBSQL::BaseAdaptor");
}
@{$self->{'states'}} = @$states if $states;
return $self; } |
General documentation
AUTHOR - Nathan Johnson | Top |
Post questions to the Ensembl development list ensembl-dev@ebi.ac.uk