Skip to content
Snippets Groups Projects
Commit 7e646b02 authored by Graham McVicker's avatar Graham McVicker
Browse files

removed seq_region_attrib functions now present on AttributeAdaptor instead

parent 8b27ca5d
No related branches found
No related tags found
No related merge requests found
......@@ -410,131 +410,6 @@ sub get_seq_region_id {
}
=head2 get_seq_region_attribs
Arg [1] : Bio::EnsEMBL::Slice $slice
The slice to fetch attributes for
Example : %attribs = %{$slice_adaptor->get_seq_region_attribs($slice)};
($htg_phase) = @{$attribs->{'htg_phase'} || []};
@synonyms = @{$attribs->{'synonym'} || []};
Description: Retrieves a reference to a hash containing attrib code values
and listref value keys.
Returntype : hashref
Exceptions : throw if the seq_region of the slice is not in the db
throw if incorrect arg provided
Caller : Bio::EnsEMBL::Slice
=cut
sub get_seq_region_attribs {
my $self = shift;
my $slice = shift;
if(!ref($slice) || !$slice->isa('Bio::EnsEMBL::Slice')) {
throw('Slice argument is required');
}
my $srid = $self->get_seq_region_id($slice);
if(!$srid) {
throw('Slice is not on a seq_region stored in this database.');
}
$self->{'_attribs_cache'} ||= {};
if($self->{'_attribs_cache'}->{$srid}) {
return $self->{'_attribs_cache'}->{$srid};
}
my $sth = $self->prepare('SELECT at.code, sra.value ' .
'FROM seq_region_attrib sra, attrib_type at ' .
'WHERE sra.seq_region_id = ? ' .
'AND at.attrib_type_id = sra.attrib_type_id');
$sth->execute($srid);
my($code, $attrib);
$sth->bind_columns(\$code, \$attrib);
my %attrib_hash;
while($sth->fetch()) {
$attrib_hash{uc($code)} ||= [];
push @{$attrib_hash{uc($code)}}, $attrib;
}
$sth->finish();
$self->{'_attribs_cache'}->{$srid} = \%attrib_hash;
return \%attrib_hash;
}
=head2 set_seq_region_attrib
Arg [1] : Bio::EnsEMBL::Slice $slice
The seq_region of the slice is the one which gets this attribute set
Arg [2] : string $code
code in attrib_type table. This method can not set name or description in
that table.
Arg [3] : string $value
An attribute value for the given code and seq_region
Example : $slice_adaptor->set_seq_region_attrib
( $chromosome_slice, "GeneCount", 23332 )
Description: Set an attribute for given slices seq_region.
Returntype : none
Exceptions : none
Caller : general
=cut
sub set_seq_region_attrib {
my $self = shift;
my $slice = shift;
my $code = shift;
my $value = shift;
my $sth = $self->prepare
("INSERT IGNORE INTO attrib_type set code = ?");
$sth->execute($code);
my $atid = $sth->{'mysql_insertid'};
$sth->finish();
if( $self->db->db_handle->{'mysql_info'} == 0 ){
# the insert failed because the code is already stored
$sth = $self->prepare
("SELECT attrib_type_id FROM attrib_type " .
"WHERE code = ?");
$sth->execute($code);
($atid) = $sth->fetchrow_array();
$sth->finish();
if(!$atid) {
throw("Could not store or fetch attrib_type code [$code]\n" .
"Wrong permissions?");
}
}
my $srid = $self->get_seq_region_id($slice);
$sth = $self->prepare
("INSERT INTO seq_region_attrib " .
"SET seq_region_id=?, value=?, attrib_type_id=?" );
$sth->execute( $srid, $value, $atid );
$sth->finish();
#update the cache if it exists already
if(exists $self->{'_attribs_cache'} &&
exists $self->{'_attribs_cache'}->{$srid}) {
$self->{'_attribs_cache'}->{$srid}->{uc($code)} ||= [];
push(@{$self->{'_attribs_cache'}->{$srid}->{uc($code)}}, $value);
}
return;
}
=head2 fetch_all
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment