Bio::EnsEMBL::Funcgen::DBSQL
ProbeSetAdaptor
Toolbar
Summary
Bio::EnsEMBL::DBSQL::ProbeSetAdaptor - A database adaptor for fetching and
storing ProbeSet objects.
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
my $opa = $db->get_ProbeSetAdaptor();
my $probeset = $opa->fetch_by_array_probeset_name('Array-1', 'ProbeSet-1');
Description
The ProbeSetAdaptor is a database adaptor for storing and retrieving
ProbeSet 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 ProbeSet objects from an executed DBI statement handle. Returntype : Listref of Bio::EnsEMBL::ProbeSet 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::Array Example : my @probesets = @{$opsa->fetch_all_by_Array($array)}; Description: Fetch all probes on a particular array. Returntype : Listref of Bio::EnsEMBL::ProbeSet objects. Exceptions : None Caller : General Status : At Risk |
Arg [1] : Bio::EnsEMBL::ProbeFeature Example : my $probeset = $opsa->fetch_by_ProbeFeature($feature); Description: Returns the probeset that created a particular feature. Returntype : Bio::EnsEMBL::ProbeSet Exceptions : Throws if argument is not a Bio::EnsEMBL::ProbeFeature object Caller : General Status : At Risk |
Arg [1] : string - name of array Arg [2] : string - name of probeset Example : my $probeset = $opsa->fetch_by_array_probeset_name('Array-1', 'Probeset-1'); Description: Returns a probeset given the array name and probeset name This will uniquely define a probeset. Only one probeset is ever returned. Returntype : Bio::EnsEMBL::ProbeSet Exceptions : None Caller : General Status : At Risk |
Arg [1] : none Example : my @ps_ids = @{$opa->list_dbIDs()}; Description: Gets an array of internal IDs for all ProbeSet objects in the current database. Returntype : List of ints Exceptions : None Caller : ? Status : Medium Risk |
Arg [1] : List of Bio::EnsEMBL::Funcgen::ProbeSet objects Example : $opa->store($probeset1, $probeset2, $probeset3); Description: Stores given ProbeSet objects in the database. Should only be called once per probe because no checks are made for duplicates.??? It certainly looks like there is :/ Sets dbID and adaptor on the objects that it stores. Returntype : None Exceptions : Throws if arguments are not Probe objects Caller : General Status : At Risk |
Methods code
sub _columns
{ my $self = shift;
return qw( ps.probe_set_id ps.name ps.size ps.family); } |
sub _objs_from_sth
{ my ($self, $sth) = @_;
my (@result, $current_dbid, $probeset_id, $name, $size, $family);
my ($array, %array_cache);
$sth->bind_columns(\$ probeset_id,\$ name,\$ size,\$ family);
my $probeset;
while ( $sth->fetch() ) {
$probeset = Bio::EnsEMBL::Funcgen::ProbeSet->new
(
-dbID => $probeset_id,
-name => $name,
-size => $size,
-family => $family,
-adaptor => $self,
);
push @result, $probeset;
}
return\@ result; } |
sub _tables
{ my $self = shift;
return [ 'probe_set', 'ps' ]; } |
sub fetch_all_by_Array
{ my $self = shift;
my $array = shift;
throw("Not yet implemented");
my ($probeset_id, @probesets);
if ( !ref($array) || !$array->isa('Bio::EnsEMBL::Array') ) {
warning('fetch_all_by_Array requires a Bio::EnsEMBL::Array object');
return [];
}
my $array_id = $array->dbID();
if (!defined $array_id) {
warning('fetch_all_by_Array requires a stored Bio::EnsEMBL::Array object');
return [];
}
my $sth = $self->prepare("
SELECT probe_set_id
FROM probe_set ps, array a, array_chip ac
WHERE a.array_id = ac.array_id
AND ac.array_chip_id = ps.array_chip_id
AND a.name = $array_id
");
$sth->execute();
while($probeset_id = $sth->fetchrow()){
push @probesets, $self->fetch_by_dbID($probeset_id);
}
return\@ probesets; } |
sub fetch_by_ProbeFeature
{ my $self = shift;
my $feature = shift;
if (
!ref($feature)
|| !$feature->isa('Bio::EnsEMBL::Funcgen::ProbeFeature')
|| !$feature->{'probe_id'}
) {
throw('fetch_by_ProbeFeature requires a stored Bio::EnsEMBL::Funcgen::ProbeFeature object');
}
my $sth = $self->prepare("
SELECT probe_set_id
FROM probe_set ps, probe p, probe_feature pf
WHERE pf.probe_id = p.probe_id
AND ps.probe_set_id = p.probe_set_id
AND pf.probe_feature_id = ?
");
$sth->bind_param(1, $feature->{'probe_id'}, SQL_VARCHAR);
$sth->execute();
my ($probeset_id) = $sth->fetchrow();
return $self->fetch_by_dbID($probeset_id); } |
sub fetch_by_array_probeset_name
{ my $self = shift;
my $array_name = shift;
my $probeset_name = shift;
my $sth = $self->prepare("
SELECT probe_set_id
FROM probe_set ps, array a, array_chip ac
WHERE a.array_id = ac.array_id
AND a.name = ?
AND ps.name = ?
");
$sth->bind_param(1, $array_name, SQL_VARCHAR);
$sth->bind_param(2, $probeset_name, SQL_VARCHAR);
$sth->execute();
my ($probeset_id) = $sth->fetchrow();
if ($probeset_id) {
return $self->fetch_by_dbID($probeset_id);
} else {
return undef;
} } |
sub list_dbIDs
{ my ($self) = @_;
return $self->_list_dbIDs('probe_set');
}
1; } |
sub store
{ my ($self, @probesets) = @_;
my ($sth, $array);
if (scalar @probesets == 0) {
throw('Must call store with a list of Probe objects');
}
my $db = $self->db();
PROBESET: foreach my $probeset (@probesets) {
if ( !ref $probeset || !$probeset->isa('Bio::EnsEMBL::Funcgen::ProbeSet') ) {
throw('ProbeSet must be an ProbeSet object');
}
if ( $probeset->is_stored($db) ) {
warning('ProbeSet [' . $probeset->dbID() . '] is already stored in the database');
next PROBESET;
}
$sth = $self->prepare("
INSERT INTO probe_set
(name, size, family)
VALUES (?, ?, ?)
");
$sth->bind_param(1, $probeset->name(), SQL_VARCHAR);
$sth->bind_param(2, $probeset->size(), SQL_INTEGER);
$sth->bind_param(3, $probeset->family(), SQL_VARCHAR);
$sth->execute();
my $dbID = $sth->{'mysql_insertid'};
$probeset->dbID($dbID);
$probeset->adaptor($self);
}
return\@ probesets; } |
General documentation
This module was created by Nathan Johnson, but is almost entirely based on the
ProbeAdaptor module written by Ian Sealy and Arne Stabenau.
This module is part of the Ensembl project:
/