From c43a7310a2203eaab2bf26757c66d86993e255bf Mon Sep 17 00:00:00 2001 From: Glenn Proctor <gp1@sanger.ac.uk> Date: Fri, 20 Jun 2003 10:08:54 +0000 Subject: [PATCH] Added get_generic_features --- modules/Bio/EnsEMBL/Slice.pm | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/modules/Bio/EnsEMBL/Slice.pm b/modules/Bio/EnsEMBL/Slice.pm index 78b7402b80..78cb5bce1c 100644 --- a/modules/Bio/EnsEMBL/Slice.pm +++ b/modules/Bio/EnsEMBL/Slice.pm @@ -1476,6 +1476,51 @@ sub accession_number { =head2 sub DEPRECATED methods =cut +############################################################################### + +# GENERIC FEATURES (See DBAdaptor.pm) + +=head2 get_generic_features + + Arg [1] : (optional) List of names of generic feature types to return. If no feature + names are given, all generic features are returned. + Example : my %features = $slice->get_generic_features() + Description: Gets generic features via the generic feature adaptors that have been added + via DBAdaptor->add_GenericFeatureAdaptor (if any) + Returntype : Hash of named features. + Exceptions : none + Caller : none + +=cut + +sub get_generic_features() { + + my ($self, @names) = @_; + + my $db = $self->adaptor()->db(); + + my %features = {}; # this will hold the results + + # get the adaptors for each feature + my %adaptors = $db->get_GenericFeatureAdaptors(@names); + + foreach my $adaptor_name (keys(%adaptors)) { + + my $adaptor_obj = %adaptors->{$adaptor_name}; + # get the features and add them to the hash + my $features_ref = $adaptor_obj->fetch_all_by_Slice($self); + # add each feature to the hash to be returned + foreach my $feature (@$features_ref) { + %features->{$adaptor_name} = $feature; + } + } + + return %features; + +} + + + # sub DEPRECATED METHODS # ############################################################################### -- GitLab