Bio::EnsEMBL::Funcgen::DBSQL
FeatureTypeAdaptor
Toolbar
Summary
Bio::EnsEMBL::Funcgen::DBSQL::FeatureTypeAdaptor - A database adaptor for fetching and
storing Funcgen FeatureType objects.
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
my $ft_adaptor = $db->get_FeatureTypeAdaptor();
my $feature_type = $ft_adaptor->fetch_by_name("H3K4me3");
Description
The FeatureTypeAdaptor is a database adaptor for storing and retrieving
Funcgen FeatureType objects.
Methods
Methods description
Args : None Example : None Description: PROTECTED implementation of superclass abstract method. Returns a list of columns to use for queries. Returntype : List of strings Exceptions : None Caller : Internal Status : At Risk |
Arg [1] : DBI statement handle object Example : None Description: PROTECTED implementation of superclass abstract method. Creates Channel objects from an executed DBI statement handle. Returntype : Listref of Bio::EnsEMBL::Funcgen::FeatureType objects Exceptions : None Caller : Internal Status : At Risk |
Args : None Example : None Description: PROTECTED implementation of superclass abstract method. Returns the names and aliases of the tables to use for queries. Returntype : List of listrefs of strings Exceptions : None Caller : Internal Status : At Risk |
Arg [1] : Bio::EnsEMBL:SetFeature Example : my $assoc_ftypes = $ft_adaptor->fetch_all_by_associated_SetFeature($ext_feature); Description: Fetches all associated FeatureTypes for a given SetFeature. Note: The main FeatureType for a SetFeature is accessible via the feature_type method. Returntype : ARRAYREF of Bio::EnsEMBL::Funcgen::FeatureType objects Exceptions : Throws if arg is not valid or stored Caller : General Status : At risk |
Arg [1] : string - class of FeatureType Example : my $ft = $ft_adaptor->fetch_all_by_class('Histone'); Description: Fetches all FeatureTypes of a given class. Returntype : ARRAYREF of Bio::EnsEMBL::Funcgen::FeatureType objects Exceptions : None Caller : General Status : At risk |
Arg [1] : string - name of FeatureType Arg [1] : optional string - class of FeatureType Example : my $ft = $ft_adaptor->fetch_by_name('H3K4me2'); Description: Does what it says on the tin Returntype : Bio::EnsEMBL::Funcgen::FeatureType object Exceptions : Throws if more than one FeatureType for a given name found Caller : General Status : At risk |
Args : None Example : my @array_ids = @{$ec_a->list_dbIDs()}; Description: Gets an array of internal IDs for all ExperimentalChip objects in the current database. Returntype : List of ints Exceptions : None Caller : ? Status : At risk |
Args : List of Bio::EnsEMBL::Funcgen::FeatureType objects Example : $chan_a->store($c1, $c2, $c3); Description: Stores given Channel objects in the database. Should only be called once per array because no checks are made for duplicates. Sets dbID and adaptor on the objects that it stores. Returntype : None Exceptions : None Caller : General Status : At Risk |
Methods code
sub _columns
{ my $self = shift;
return qw( ft.feature_type_id ft.name ft.class ft.description); } |
sub _objs_from_sth
{ my ($self, $sth) = @_;
my (@result, $ft_id, $name, $class, $desc);
$sth->bind_columns(\$ft_id,\$ name,\$ class,\$ desc);
while ( $sth->fetch() ) {
my $ftype = Bio::EnsEMBL::Funcgen::FeatureType->new(
-dbID => $ft_id,
-NAME => $name,
-CLASS => $class,
-DESCRIPTION => $desc,
-ADAPTOR => $self,
);
push @result, $ftype;
}
return\@ result; } |
sub _tables
{ my $self = shift;
return (
['feature_type', 'ft'],
); } |
sub fetch_all_by_associated_SetFeature
{ my ($self, $sfeat) = @_;
$self->db->is_stored_and_valid('Bio::EnsEMBL::Funcgen::SetFeature', $sfeat);
my $constraint;
my $sql = 'SELECT feature_type_id from associated_feature_type where feature_table="'.$sfeat->feature_set->type.'" and feature_id='.$sfeat->dbID;
my @ft_ids = map {$_ = "@$_"} @{$self->dbc->db_handle->selectall_arrayref($sql)};
$constraint = ' feature_type_id in ('.join(',',@ft_ids).') ' if @ft_ids;
return ($constraint) ? $self->generic_fetch($constraint) : []; } |
sub fetch_all_by_class
{ my ($self, $class) = @_;
throw("Must specify a FeatureType class") if(! defined $class);
my $constraint = " class = ? ";
$self->bind_param_generic_fetch($class, SQL_VARCHAR);
return $self->generic_fetch($constraint); } |
sub fetch_by_name
{ my ($self, $name, $class) = @_;
throw("Must specify a FeatureType name") if(! $name);
my $constraint = " name = ?";
$constraint .= " AND class = ?" if $class;
$self->bind_param_generic_fetch($name, SQL_VARCHAR);
$self->bind_param_generic_fetch($class, SQL_VARCHAR) if $class;
my @fts = @{$self->generic_fetch($constraint)};
if(scalar @fts >1){
$class ||= "";
throw("Found more than one FeatureType:$class $name");
}
return $fts[0]; } |
sub list_dbIDs
{ my ($self) = @_;
return $self->_list_dbIDs('feature_type');
}
1; } |
sub store
{ my $self = shift;
my @args = @_;
my $sth = $self->prepare("
INSERT INTO feature_type
(name, class, description)
VALUES (?, ?, ?)");
foreach my $ft (@args) {
if ( ! $ft->isa('Bio::EnsEMBL::Funcgen::FeatureType') ) {
warning('Can only store FeatureType objects, skipping $ft');
next;
}
if (!( $ft->dbID() && $ft->adaptor() == $self )){
my $s_ft = $self->fetch_by_name($ft->name(), $ft->class());
if(! $s_ft){
$sth->bind_param(1, $ft->name(), SQL_VARCHAR);
$sth->bind_param(2, $ft->class(), SQL_VARCHAR);
$sth->bind_param(3, $ft->description(), SQL_VARCHAR);
$sth->execute();
my $dbID = $sth->{'mysql_insertid'};
$ft->dbID($dbID);
$ft->adaptor($self);
}
else{
$ft = $s_ft;
warn("Using previously stored FeatureType:\t".$ft->name()."\n");
}
}
}
return\@ args; } |
General documentation
This module was created by Nathan Johnson.
This module is part of the Ensembl project:
/