Bio::EnsEMBL::Funcgen::DBSQL
ArrayAdaptor
Toolbar
Summary
Bio::EnsEMBL::Funcgen::DBSQL::ArrayAdaptor - A database adaptor for fetching and
storing Funcgen Array objects.
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
my $oaa = $db->get_ArrayAdaptor();
my $array = $oaa->fetch_by_name('Array-1');
my @arrays = @{$oaa->fetch_all()};
Description
The ArrayAdaptor is a database adaptor for storing and retrieving
Funcgen Array 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 Array objects from an executed DBI statement handle. Returntype : Listref of Bio::EnsEMBL::Funcgen::Array 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::Funcgen::Experiement Example : my @arrays = @{$aa->fetch_all_by_Experiment($exp)}; Description: Fetch all arrays associated with a given Experiment This is a convenience method to hide the 3 adaptor required for this call. Returntype : Listref of Bio::EnsEMBL::Funcgen::Array objects Exceptions : none Caller : General Status : at risk |
Arg [1] : string - class Example : my $array = $oaa->fetch_all_by_class(''AFFY_ST'); Description: Retrieves Array object from the database based class. Returntype : ARRAYREF of Bio::EnsEMBL::Funcgen::Array objects Exceptions : Throws if nor class passed Caller : General Status : At Risk |
Arg [1] : List of strings - type(s) (e.g. OLIGO, PCR) Example : my @arrays = @{$aa->fetch_all_by_type('OLIGO')}; Description: Fetch all arrays of a particular type. Returntype : Listref of Bio::EnsEMBL::Funcgen::Array objects Exceptions : Throws if no type is provided Caller : General Status : at risk |
Arg [1] : Bio::EnsEMBL::Funcgen::Array - array to fetch attributes for Example : None Description: This function is solely intended to lazy load attributes into empty Array objects. You should not need to call this. Returntype : None Exceptions : None Caller : Bio::EnsEMBL::Funcgen::Array getters Status : Medium Risk |
Arg [1] : int - dbID of array_chip Example : my $array = $oaa->fetch_by_array_chip_dbID($ac_dbid); Description: Retrieves a named Array object from the database. Returntype : Bio::EnsEMBL::Funcgen::Array Exceptions : None Caller : General Status : At Risk |
Arg [1] : string - name of an array Arg [2] : string - class of array e.g. AFFY_UTR Example : my $array = $oaa->fetch_by_name_class('HuGene_1_0_st_v1', 'AFFY_ST'); Description: Retrieves Array object from the database based on name and class. Returntype : Bio::EnsEMBL::Funcgen::Array Exceptions : Throws is name and class not passed Caller : General Status : At Risk |
Arg [1] : string - name of an array Arg [2] : string - name of vendor e.g. NIMBLEGEN Example : my $array = $oaa->fetch_by_name('Array-1'); Description: Retrieves a named Array object from the database. Returntype : Bio::EnsEMBL::Funcgen::Array Exceptions : None Caller : General Status : At Risk |
Args : None Example : my @array_ids = @{$oaa->list_dbIDs()}; Description: Gets an array of internal IDs for all Array objects in the current database. Returntype : List of ints Exceptions : None Caller : ? Status : Medium Risk |
Args : List of Bio::EnsEMBL::Funcgen::Array objects Example : $oaa->store($array1, $array2, $array3); Description: Stores given Array objects in the database. This method checks for arrays previously stored and updates and new array_chips accordingly. Returntype : Listref of stored Array objects Exceptions : None Caller : General Status : At Risk |
Methods code
sub _columns
{ my $self = shift;
return qw( a.array_id a.name a.format a.vendor a.description a.type a.class); } |
sub _objs_from_sth
{ my ($self, $sth) = @_;
my (@result, $array_id, $name, $format, $vendor, $description, $type, $class);
$sth->bind_columns(\$array_id,\$ name,\$ format,\$ vendor,\$ description,\$ type,\$ class);
while ( $sth->fetch() ) {
my $array = Bio::EnsEMBL::Funcgen::Array->new
(
-dbID => $array_id,
-adaptor => $self,
-name => $name,
-format => $format,
-vendor => $vendor,
-description => $description,
-type => $type,
-class => $class,
);
push @result, $array;
}
return\@ result; } |
sub _tables
{ my $self = shift;
return ['array', 'a']; } |
sub fetch_all_by_Experiment
{ my ($self, $exp) = @_;
my %array_ids;
my $echips = $self->db->get_ExperimentalChipAdaptor->fetch_all_by_Experiment($exp);
foreach my $achip(@{$self->db->get_ArrayChipAdaptor->fetch_all_by_ExperimentalChips($echips)}){
$array_ids{$achip->array_id()} = 1;
}
return $self->generic_fetch('a.array_id IN ('.join(', ', keys %array_ids).')'); } |
sub fetch_all_by_class
{ my ($self, $class) = @_;
throw("Must provide and array class e.g.'AFFY_ST'") if (! defined $class);
return $self->generic_fetch("a.class='".uc($class)."'"); } |
sub fetch_all_by_type
{ my ($self, @types) = @_;
throw('Need type as parameter') if ! @types;
my $constraint;
if (scalar @types == 1) {
$constraint = qq( a.type = '$types[0]' );
} else {
$constraint = join q(','), @types;
$constraint = qq( a.type IN ('$constraint') );
}
return $self->generic_fetch($constraint); } |
sub fetch_attributes
{ my $self = shift;
my $array = shift;
my $tmp_array = $self->fetch_by_dbID( $array->dbID() );
%$array = %$tmp_array; } |
sub fetch_by_array_chip_dbID
{ my $self = shift;
my $ac_dbid = shift;
my $sth = $self->prepare("
SELECT a.array_id
FROM array a, array_chip ac
WHERE a.array_id = ac.array_id
AND ac.array_chip_id = $ac_dbid
");
$sth->execute();
my ($array_id) = $sth->fetchrow();
return $self->fetch_by_dbID($array_id); } |
sub fetch_by_name_class
{ my ($self, $name, $class) = @_;
throw("Must provide and array and class e.g.'HuGene_1_0_st_v1', 'AFFY_ST'") if (! ($name && $class));
my ($result) = @{$self->generic_fetch("a.name = '$name' and a.class='".uc($class)."'")};
return $result; } |
sub fetch_by_name_vendor
{ my ($self, $name, $vendor) = @_;
throw("Must provide and array and vendor name") if (! ($name && $vendor));
my ($result) = @{$self->generic_fetch("a.name = '$name' and a.vendor='".uc($vendor)."'")};
return $result; } |
sub list_dbIDs
{ my ($self) = @_;
return $self->_list_dbIDs('array');
}
1; } |
sub store
{ my $self = shift;
my @args = @_;
my ($sarray);
my $sth = $self->prepare("
INSERT INTO array
(name, format, vendor, description, type, class)
VALUES (?, ?, ?, ?, ?, ?)");
foreach my $array (@args) {
if ( !$array->isa('Bio::EnsEMBL::Funcgen::Array') ) {
warning('Can only store Array objects, skipping $array');
next;
}
if (!( $array->dbID() && $array->adaptor() == $self )){
$sarray = $self->fetch_by_name_vendor($array->name(), $array->vendor());
if( ! $sarray){
throw("Array name must not be longer than 30 characters") if (length($array->name) > 40);
$sth->bind_param(1, $array->name(), SQL_VARCHAR);
$sth->bind_param(2, $array->format(), SQL_VARCHAR);
$sth->bind_param(3, $array->vendor(), SQL_VARCHAR);
$sth->bind_param(4, $array->description(), SQL_VARCHAR);
$sth->bind_param(5, $array->type(), SQL_VARCHAR);
$sth->bind_param(6, $array->class(), SQL_VARCHAR);
$sth->execute();
my $dbID = $sth->{'mysql_insertid'};
$array->dbID($dbID);
$array->adaptor($self);
}
else{
$array = $sarray;
}
}
}
return\@ args; } |
General documentation
This module was created by Nathan Johnson, but is almost entirely based on the
ArrayAdaptor modules written by Ian Sealy and Arne Stabenau.
This module is part of the Ensembl project:
/