Bio-EnsEMBL
view release on metacpan or search on metacpan
lib/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm view on Meta::CPAN
my $self = shift;
my $feature = shift;
if(!ref($feature) || !$feature->isa('Bio::EnsEMBL::Feature')) {
throw('Expected Feature argument.');
}
my $slice = $feature->slice();
$self->_check_start_end_strand($feature->start(),$feature->end(),
$feature->strand(), $slice);
my $db = $self->db();
my $slice_adaptor = $db->get_SliceAdaptor();
if(!ref($slice) || !($slice->isa('Bio::EnsEMBL::Slice') or $slice->isa('Bio::EnsEMBL::LRGSlice')) ) {
throw('Feature must be attached to Slice to be stored.');
}
# make sure feature coords are relative to start of entire seq_region
if($slice->start != 1 || $slice->strand != 1) {
#move feature onto a slice of the entire seq_region
$slice = $slice_adaptor->fetch_by_region($slice->coord_system->name(),
$slice->seq_region_name(),
undef, #start
undef, #end
undef, #strand
$slice->coord_system->version());
$feature = $feature->transfer($slice);
if(!$feature) {
throw('Could not transfer Feature to slice of ' .
'entire seq_region prior to storing');
}
}
# Ensure this type of feature is known to be stored in this coord system.
my $cs = $slice->coord_system;
my ($tab) = $self->_tables();
my $tabname = $tab->[0];
my $mcc = $db->get_MetaCoordContainer();
$mcc->add_feature_type($cs, $tabname, $feature->length);
my $seq_region_id = $slice_adaptor->get_seq_region_id($slice);
if(!$seq_region_id) {
throw('Feature is associated with seq_region which is not in this DB.');
}
return ($feature, $seq_region_id);
}
# The same function as _pre_store
# This one is used to store user uploaded features in XXX_userdata db
sub _pre_store_userdata {
my $self = shift;
my $feature = shift;
if(!ref($feature) || !$feature->isa('Bio::EnsEMBL::Feature')) {
throw('Expected Feature argument.');
}
my $slice = $feature->slice();
my $slice_adaptor = $slice->adaptor;
$self->_check_start_end_strand($feature->start(),$feature->end(),
$feature->strand(), $slice);
if(!ref($slice) || !($slice->isa('Bio::EnsEMBL::Slice') or $slice->isa('Bio::EnsEMBL::LRGSlice')) ) {
throw('Feature must be attached to Slice to be stored.');
}
# make sure feature coords are relative to start of entire seq_region
if($slice->start != 1 || $slice->strand != 1) {
#move feature onto a slice of the entire seq_region
$slice = $slice_adaptor->fetch_by_region($slice->coord_system->name(),
$slice->seq_region_name(),
undef, #start
undef, #end
undef, #strand
$slice->coord_system->version());
$feature = $feature->transfer($slice);
if(!$feature) {
throw('Could not transfer Feature to slice of ' .
'entire seq_region prior to storing');
}
}
# Ensure this type of feature is known to be stored in this coord system.
my $cs = $slice->coord_system;
my ($tab) = $self->_tables();
my $tabname = $tab->[0];
my $db = $self->db;
my $mcc = $db->get_MetaCoordContainer();
$mcc->add_feature_type($cs, $tabname, $feature->length);
my $seq_region_id = $slice_adaptor->get_seq_region_id($slice);
if(!$seq_region_id) {
throw('Feature is associated with seq_region which is not in this DB.');
}
return ($feature, $seq_region_id);
}
( run in 1.682 second using v1.01-cache-2.11-cpan-b16cb0d3907 )