Bio::EnsEMBL::Funcgen::DBSQL
SliceAdaptor
Toolbar
Summary
Bio::EnsEMBL::Funcgen::DBSQL::SliceAdaptor - A database aware adaptor responsible for
the creation of Slices in the context of eFG objects.
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
use Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor;
$db = Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor->new(...);
$slice_adaptor = $db->get_SliceAdaptor();
# get a slice on the entire chromosome X
$gene_regulation_slice = $slice_adaptor->fetch_by_Gene_FeatureSets($gene, \@fsets);
Description
This module is simple wrapper class for the core SliceAdaptor, extending new
methods to generate Slices for eFG features associated with a given gene or transcript.
Methods
Methods description
Arg [1] : string - seq_region_name i.e. chromosome name. Arg [2] : string - seq_region_start of current slice bound Arg [3] : string - seq_region_end of current slice bound. Arg [4] : Bio::EnsEMBL::Gene|Transcript|Translation Arg [5] : arrayref - Bio::EnsEMBL::Funcgen::FeatureSet Example : ($start, $end) = $self->_set_bounds_by_regulatory_feature_xref ($trans_chr, $start, $end, $transcript, $fsets); Description: Internal method to set an xref Slice bounds given a list of FeatureSets. Returntype : List - ($start, $end); Exceptions : throw if incorrent args provided Caller : self Status : at risk |
Arg [1] : Bio::EnsEMBL::Gene Example : my $gene_reg_slice = $efg_slice_adaptor->fetch_by_gene($gene); Description: Fetches a slice by finding the associated regulatory elements associated with a given gene(and it's transcripts and translations), and extending the gene feature slice to encapsulate the associated regulatory elements. Returntype : Bio::EnsEMBL::Slice or undef Exceptions : throw if incorrent arg provided Caller : General Status : At risk |
Arg [1] : Bio::EnsEMBL::Transcript Example : my $trans_reg_slice = $efg_slice_adaptor->fetch_by_transcript($transcript); Description: Fetches a slice by finding the associated regulatory elements associated with a given transcript(and it's translation), and extending the gene feature slice to encapsulate the associated regulatory elements. Returntype : Bio::EnsEMBL::Slice or undef Exceptions : throw if incorrent arg provided Caller : self Status : at risk |
Methods code
sub _set_bounds_by_xref_FeatureSets
{ my ($self, $chr, $start, $end, $obj, $fsets) = @_;
my ($extdb_name, $efg_feature);
my $dbe_adaptor = $self->efgdb->get_DBEntryAdaptor;
if($obj->isa('Bio::EnsEMBL::Gene')){
$extdb_name = 'ensembl_core_Gene';
}
elsif($obj->isa('Bio::EnsEMBL::Transcript')){
$extdb_name = 'ensembl_core_Transcript';
}
elsif($obj->isa('Bio::EnsEMBL::Translation')){
$extdb_name = 'ensembl_core_Translation';
}
else{
throw('Currently only handles Ensembl Gene, Transcript and Translation xrefs');
}
if(ref($fsets) ne 'ARRAY' || scalar(@$fsets) == 0){
throw('Must define an array of Bio::EnsEMBL::FeatureSets to extend xref Slice bound. You passed: '.$fsets);
}
my %feature_set_types;
foreach my $fset(@$fsets){
$self->efgdb->is_stored_and_valid('Bio::EnsEMBL::Funcgen::FeatureSet', $fset);
$feature_set_types{$fset->type} ||= [];
push @{$feature_set_types{$fset->type}}, $fset;
}
foreach my $fset_type(keys %feature_set_types){
my $xref_method = 'list_'.$fset_type.'_feature_ids_by_extid';
my $adaptor_method = 'get_'.ucfirst($fset_type).'FeatureAdaptor';
my $adaptor = $self->efgdb->$adaptor_method;
my %feature_set_ids;
map $feature_set_ids{$_->dbID} = 1, @{$feature_set_types{$fset_type}};
foreach my $efg_feature(@{$adaptor->fetch_all_by_external_name($obj->stable_id, $extdb_name)}){
next if ! exists $feature_set_ids{$efg_feature->feature_set->dbID};
next if $efg_feature->seq_region_name ne $chr;
$start = $efg_feature->seq_region_start if $efg_feature->seq_region_start < $start;
$end = $efg_feature->seq_region_end if $efg_feature->seq_region_end > $end;
}
}
return ($start, $end);
}
1; } |
sub efgdb
{ my ($self, $efgdb) = @_;
if($efgdb){
if(! (ref($efgdb) && $efgdb->isa('Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor'))){
throw('Must provide a Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor');
}
$self->{'efgdb'} = $efgdb;
}
return $self->{'efgdb'}; } |
sub fetch_by_Gene_FeatureSets
{ my ($self, $gene, $fsets) = @_;
if(! ( ref($gene) && $gene->isa('Bio::EnsEMBL::Gene'))){
throw("You must pass a valid Bio::EnsEMBL::Gene object");
}
my $cs_name = $gene->slice->coord_system_name;
my $gene_chr = $gene->seq_region_name;
my $start = $gene->seq_region_start;
my $end = $gene->seq_region_end;
($start, $end) = $self->_set_bounds_by_xref_FeatureSets
($gene_chr, $start, $end, $gene, $fsets);
foreach my $trans(@{$gene->get_all_Transcripts}){
($start, $end) = $self->_set_bounds_by_xref_FeatureSets
($gene_chr, $start, $end, $trans, $fsets);
my $translation = $trans->translation;
($start, $end) = $self->_set_bounds_by_xref_FeatureSets
($gene_chr, $start, $end, $translation, $fsets) if $translation;
}
return $self->fetch_by_region($cs_name, $gene_chr, $start, $end, $gene->strand); } |
sub fetch_by_Transcript_FeatureSets
{ my ($self, $transcript, $fsets) = @_;
if(! ( ref($transcript) && $transcript->isa('Bio::EnsEMBL::Transcript'))){
throw("You must pass a valid Bio::EnsEMBL::Transcript object");
}
my $cs_name = $transcript->slice->coord_system_name;
my $trans_chr = $transcript->seq_region_name;
my $start = $transcript->seq_region_start;
my $end = $transcript->seq_region_end;
($start, $end) = $self->_set_bounds_by_xref_FeatureSets
($trans_chr, $start, $end, $transcript, $fsets);
my $translation = $transcript->translation;
($start, $end) = $self->_set_bounds_by_xref_FeatureSets
($trans_chr, $start, $end, $translation, $fsets) if $translation;
return $self->fetch_by_region($cs_name, $trans_chr, $start, $end, $transcript->strand);
}
} |
sub new
{ my ($caller, $efgdb) = @_;
my $class = ref($caller) || $caller;
my $self = $class->SUPER::new($efgdb->dnadb);
$self->efgdb($efgdb);
return $self; } |
General documentation