From 20ae012021f00da1b007917775bde1875b78b977 Mon Sep 17 00:00:00 2001 From: Patrick Meidl <pm2@sanger.ac.uk> Date: Fri, 28 Jul 2006 11:23:14 +0000 Subject: [PATCH] added list_seq_region_ids() --- .../Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm | 34 ++++++++++++++++++- modules/Bio/EnsEMBL/DBSQL/GeneAdaptor.pm | 7 ++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm index 261bd60e56..2f24b32baa 100644 --- a/modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm +++ b/modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm @@ -85,6 +85,11 @@ sub new { which are on the Slice defined by $slice. If $logic_name is defined only features with an analysis of type $logic_name will be returned. + NOTE: only features that are entirely on the slice's seq_region + will be returned (i.e. if they hang off the start/end of a + seq_region they will be discarded). Features can extend over the + slice boundaries though (in cases where you have a slice that + doesn't span the whole seq_region). Returntype : listref of Bio::EnsEMBL::SeqFeatures in Slice coordinates Exceptions : none Caller : Bio::EnsEMBL::Slice @@ -564,7 +569,7 @@ sub _remap { $strand = $f->strand(); $seq_region = $f->slice->seq_region_name(); } - + # maps to region outside desired area next if ($start > $slice_end) || ($end < $slice_start) || ($slice_seq_region ne $seq_region); @@ -761,6 +766,33 @@ sub _max_feature_length { } +# +# Lists all seq_region_ids that a particular feature type is found on. +# Useful e.g. for finding out which seq_regions have genes. +# Returns a listref of seq_region_ids. +# +sub _list_seq_region_ids { + my ($self, $table) = @_; + + my @out; + + my $sql = qq( + SELECT distinct(sr.seq_region_id) + FROM seq_region sr, $table a + WHERE sr.seq_region_id = a.seq_region_id + ); + my $sth = $self->prepare($sql); + $sth->execute; + + while (my ($id) = $sth->fetchrow) { + push(@out, $id); + } + + $sth->finish; + + return \@out; +} + =head1 DEPRECATED METHODS diff --git a/modules/Bio/EnsEMBL/DBSQL/GeneAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/GeneAdaptor.pm index d9b73fb383..93a7fc6102 100644 --- a/modules/Bio/EnsEMBL/DBSQL/GeneAdaptor.pm +++ b/modules/Bio/EnsEMBL/DBSQL/GeneAdaptor.pm @@ -145,6 +145,13 @@ sub list_stable_ids { } +sub list_seq_region_ids { + my $self = shift; + + return $self->_list_seq_region_ids('gene'); +} + + =head2 fetch_by_display_label Arg [1] : String $label - display label of gene to fetch -- GitLab