Bio::EnsEMBL::Funcgen::DBSQL MetaCoordContainer
Included librariesPackage variablesGeneral documentationMethods
Toolbar
WebCvsRaw content
Package variables
No package variables defined.
Included modules
Bio::EnsEMBL::DBSQL::BaseAdaptor
Bio::EnsEMBL::Utils::Exception
Inherit
Bio::EnsEMBL::DBSQL::BaseAdaptor
Synopsis
No synopsis!
Description
No description!
Methods
add_feature_typeDescriptionCode
fetch_all_CoordSystems_by_feature_typeDescriptionCode
fetch_max_length_by_CoordSystem_feature_typeDescriptionCode
new
No description
Code
Methods description
add_feature_typecode    nextTop
  Arg [1]    : Bio::EnsEMBL::Funcgen::CoordSystem $cs
The coordinate system to associate with a feature table
Arg [2] : string $table - the name of the table in which features of
a given coordinate system will be stored in
Arg [3] : int $length
This length is used to update the max_length in the database
and the internal cache.
Example : $csa->add_feature_table($chr_coord_system, 'gene');
Description: This function tells the coordinate system adaptor that
features from a specified table will be stored in a certain
coordinate system. If this information is not already stored
in the database it will be added.
Returntype : none
Exceptions : none
Caller : BaseFeatureAdaptor
Status : At risk
fetch_all_CoordSystems_by_feature_typecodeprevnextTop
  Arg [1]    : string $table - the name of the table to retrieve coord systems
for. E.g. 'gene', 'exon', 'dna_align_feature'
Example : @css = @{$mcc->fetch_all_CoordSystems_by_feature_type('gene')};
Description: This retrieves the list of coordinate systems that features
in a particular table are stored. It is used internally by
the API to perform queries to these tables and to ensure that
features are only stored in appropriate coordinate systems.
Returntype : listref of Bio::EnsEMBL::Funcgen::CoordSystem objects
Exceptions : throw if name argument not provided
Caller : BaseFeatureAdaptor
Status : At risk
fetch_max_length_by_CoordSystem_feature_typecodeprevnextTop
  Arg [1]    : Bio::EnsEMBL::Funcgen::CoordSystem $cs
Arg [2] : string $table
Example : $max_len =
$mcc->fetch_max_length_by_CoordSystem_feature_type($cs,'gene');
Description: Returns the maximum length of features of a given type in
a given coordinate system.
Returntype : int or undef
Exceptions : throw on incorrect argument
Caller : BaseFeatureAdaptor
Status : At risk
Methods code
add_feature_typedescriptionprevnextTop
sub add_feature_type {
  my $self = shift;
  my $cs   = shift;
  my $table = lc(shift);
  my $length = shift;
  if(!ref($cs) || !$cs->isa('Bio::EnsEMBL::Funcgen::CoordSystem')) {
    throw('CoordSystem argument is required.');
  }

  if(!$table) {
    throw('Table argument is required.');
  }

  my $cs_ids = $self->{'_feature_cache'}->{$table} || [];

  my ($exists) = grep {$cs->dbID() == $_} @$cs_ids;
  if( $exists ) {
    if( !$self->{'_max_len_cache'}->{$cs->dbID()}->{$table} ||
        $self->{'_max_len_cache'}->{$cs->dbID()}->{$table} < $length ) {
      my $sth = $self->prepare('UPDATE meta_coord ' .
                               "SET max_length = $length " .
                               'WHERE coord_system_id = ? ' .
                               'AND table_name = ? '.
                               "AND (max_length<$length ".
                               "OR max_length is null)");
      $sth->execute( $cs->dbID(), $table );
      $self->{'_max_len_cache'}->{$cs->dbID()}->{$table} = $length;
    }
    return;
  }

  #store the new tablename -> coord system relationship in the db
#ignore failures b/c during the pipeline multiple processes may try
#to update this table and only the first will be successful
my $sth = $self->prepare('INSERT IGNORE INTO meta_coord ' . 'SET coord_system_id = ?, ' . 'table_name = ?, ' . 'max_length = ? ' ); $sth->execute($cs->dbID, $table, $length ); #update the internal cache
$self->{'_feature_cache'}->{$table} ||= []; push @{$self->{'_feature_cache'}->{$table}}, $cs->dbID(); $self->{'_max_len_cache'}->{$cs->dbID()}->{$table} = $length; return; } 1;
}
fetch_all_CoordSystems_by_feature_typedescriptionprevnextTop
sub fetch_all_CoordSystems_by_feature_type {
  my $self = shift;
  my $table = lc(shift); #case insensitive matching
throw('Name argument is required') unless $table; if(!$self->{'_feature_cache'}->{$table}) { return []; } my @cs_ids = @{$self->{'_feature_cache'}->{$table}}; my @coord_systems; my $csa = $self->db->get_FGCoordSystemAdaptor(); foreach my $cs_id (@cs_ids) { my $cs = $csa->fetch_by_dbID($cs_id); if(!$cs) { throw("meta_coord table refers to non-existant coord_system $cs_id"); } push @coord_systems, $cs; } return\@ coord_systems;
}
fetch_max_length_by_CoordSystem_feature_typedescriptionprevnextTop
sub fetch_max_length_by_CoordSystem_feature_type {
  my $self = shift;
  my $cs = shift;
  my $table = shift;

  if(!ref($cs) || !$cs->isa('Bio::EnsEMBL::Funcgen::CoordSystem')) {
    throw('Bio::EnsEMBL::Funcgen::CoordSystem argument expected');
  }

  throw("Table name argument is required") unless $table;

  return $self->{'_max_len_cache'}->{$cs->dbID()}->{lc($table)};
}
newdescriptionprevnextTop
sub new {
  my $class = shift;

  my $self = $class->SUPER::new(@_);

  #
# Retrieve the list of the coordinate systems that features are stored in
# and cache them
#
my $sql = 'SELECT mc.table_name, mc.coord_system_id, mc.max_length FROM meta_coord mc'; my @args; if($self->is_multispecies()) { $sql .= ' join coord_system cs using (coord_system_id) where cs.species_id =?'; push(@args, $self->species_id()); } my $sth = $self->prepare($sql); $sth->execute(@args); while(my ($table_name, $cs_id, $max_length) = $sth->fetchrow_array()) { $self->{'_feature_cache'}->{lc($table_name)} ||= []; push @{$self->{'_feature_cache'}->{lc($table_name)}}, $cs_id; $self->{'_max_len_cache'}->{$cs_id}->{lc($table_name)} = $max_length; } $sth->finish(); return $self;
}
General documentation
No general documentation available.