Bio::EnsEMBL::Funcgen::DBSQL CellTypeAdaptor
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvsRaw content
Summary
Bio::EnsEMBL::Funcgen::DBSQL::CellTypeAdaptor - A database adaptor for fetching and
storing Funcgen CellType objects.
Package variables
No package variables defined.
Included modules
Bio::EnsEMBL::DBSQL::BaseAdaptor
Bio::EnsEMBL::Funcgen::CellType
Bio::EnsEMBL::Utils::Exception qw ( warning throw )
Inherit
Bio::EnsEMBL::DBSQL::BaseAdaptor
Synopsis
my $ct_adaptor = $db->get_CellTypeAdaptor();
my $cell_type = $ct_adaptor->fetch_by_name("U2OS");
#my @cell_types = $st_adaptor->fetch_all_by_type("TISSUE");
Description
The CellTypeAdaptor is a database adaptor for storing and retrieving
Funcgen CellType objects.
Methods
_columnsDescriptionCode
_objs_from_sthDescriptionCode
_tablesDescriptionCode
fetch_by_nameDescriptionCode
list_dbIDsDescriptionCode
storeDescriptionCode
Methods description
_columnscode    nextTop
  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
_objs_from_sthcodeprevnextTop
  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::CellType objects
Exceptions : None
Caller : Internal
Status : At Risk
_tablescodeprevnextTop
  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
fetch_by_namecodeprevnextTop
  Arg [1]    : string - name of CellType
Arg [1] : optional string - class of CellType
Example : my $ct = $ct_adaptor->fetch_by_name('U2OS');
Description: Retrieves CellType objects by name.
Returntype : Bio::EnsEMBL::Funcgen::CellType object
Exceptions : Throws no name given
Caller : General
Status : At risk
list_dbIDscodeprevnextTop
  Args       : None
Example : my @ct_ids = @{$ct_a->list_dbIDs()};
Description: Gets an array of internal IDs for all CellType objects in the
current database.
Returntype : List of ints
Exceptions : None
Caller : ?
Status : At risk
storecodeprevnextTop
  Args       : List of Bio::EnsEMBL::Funcgen::CellType objects
Example : $chan_a->store($c1, $c2, $c3);
Description: Stores CellType objects in the database.
Returntype : None
Exceptions : None
Caller : General
Status : At Risk
Methods code
_columnsdescriptionprevnextTop
sub _columns {
  my $self = shift;
	
  return qw( ct.cell_type_id ct.name ct.display_label ct.description);#ct.type/class
}
_objs_from_sthdescriptionprevnextTop
sub _objs_from_sth {
	my ($self, $sth) = @_;
	
	my (@result, $ct_id, $name, $dlabel, $desc);
	
	$sth->bind_columns(\$ct_id,\$ name,\$ dlabel,\$ desc);
	
	while ( $sth->fetch() ) {
		my $ctype = Bio::EnsEMBL::Funcgen::CellType->new(
														 -dbID          => $ct_id,
														 -NAME          => $name,
														 -DISPLAY_LABEL => $dlabel,
														 -DESCRIPTION    => $desc,
														 -ADAPTOR       => $self,
														);
	  
		push @result, $ctype;
	  
	}
	return\@ result;
}
_tablesdescriptionprevnextTop
sub _tables {
  my $self = shift;
	
  return (
	  ['cell_type', 'ct'],
	 );
}
fetch_by_namedescriptionprevnextTop
sub fetch_by_name {
  my ($self, $name) = @_;

  throw("Must specify a CellType name") if(! $name);

  my $constraint = "ct.name ='$name'";

  my @ctype = @{$self->generic_fetch($constraint)};
  #name is unique so we should only have one
return $ctype[0];
}
list_dbIDsdescriptionprevnextTop
sub list_dbIDs {
    my ($self) = @_;
	
    return $self->_list_dbIDs('cell_type');
}



1;
}
storedescriptionprevnextTop
sub store {
  my $self = shift;
  my @args = @_;
  
  
  my $sth = $self->prepare("
			INSERT INTO cell_type
			(name, display_label, description)
			VALUES (?, ?, ?)");
    
  
  
  foreach my $ct (@args) {
	  if ( ! $ct->isa('Bio::EnsEMBL::Funcgen::CellType') ) {
		  warning('Can only store CellType objects, skipping $ct');
		  next;
	  }
	  
	  if ( $ct->dbID() && $ct->adaptor() == $self ){
		  warn("Skipping previously stored CellType dbID:".$ct->dbID().")");
		  next;
	  }
	  
	  
	  $sth->bind_param(1, $ct->name(),           SQL_VARCHAR);
	  $sth->bind_param(2, $ct->display_label(),  SQL_VARCHAR);
	  $sth->bind_param(3, $ct->description(),    SQL_VARCHAR);
	  
	  $sth->execute();
	  $ct->dbID($sth->{'mysql_insertid'});
	  $ct->adaptor($self);
	  
  }

  return\@ args;
}
General documentation
AUTHORTop
This module was created by Nathan Johnson.
This module is part of the Ensembl project: /
CONTACTTop
Post comments or questions to the Ensembl development list: ensembl-dev@ebi.ac.uk