From 270695a652a197c7af726d894b63a1bc1d46e790 Mon Sep 17 00:00:00 2001 From: Will Spooner <whs@sanger.ac.uk> Date: Tue, 23 Mar 2004 16:42:41 +0000 Subject: [PATCH] Ported get_all_DASFeatures call from branch-ensembl-19-2 --- modules/Bio/EnsEMBL/Gene.pm | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/modules/Bio/EnsEMBL/Gene.pm b/modules/Bio/EnsEMBL/Gene.pm index 850b1f7985..0551eaf7c2 100755 --- a/modules/Bio/EnsEMBL/Gene.pm +++ b/modules/Bio/EnsEMBL/Gene.pm @@ -757,4 +757,58 @@ sub chr_name { } } +=head2 get_all_DASFactories + + Arg [1] : none + Function : Retrieves a listref of registered DAS objects + TODO: Abstract to a DBLinkContainer obj + Returntype: [ DAS_objects ] + Exceptions: + Caller : + Example : $dasref = $prot->get_all_DASFactories + +=cut + +sub get_all_DASFactories { + my $self = shift; + return [ $self->adaptor()->db()->_each_DASFeatureFactory ]; +} + +=head2 get_all_DASFeatures + + Arg [1] : none + Example : $features = $prot->get_all_DASFeatures; + Description: Retreives a hash reference to a hash of DAS feature + sets, keyed by the DNS, NOTE the values of this hash + are an anonymous array containing: + (1) a pointer to an array of features; + (2) a pointer to the DAS stylesheet + TODO: Abstract to a DBLinkContainer obj + Returntype : hashref of Bio::SeqFeatures + Exceptions : ? + Caller : webcode + +=cut + +sub get_all_DASFeatures{ + my ($self,@args) = @_; + $self->{_das_features} ||= {}; # Cache + my %das_features; + foreach my $dasfact( @{$self->get_all_DASFactories} ){ + my $dsn = $dasfact->adaptor->dsn; + my $name = $dasfact->adaptor->name; + $name ||= $dasfact->adaptor->url .'/'. $dsn; + if( $self->{_das_features}->{$name} ){ # Use cached + $das_features{$name} = $self->{_das_features}->{$name}; + next; + } + else{ # Get fresh data + my @featref = $dasfact->fetch_all_by_DBLink_Container( $self ); + $self->{_das_features}->{$name} = [@featref]; + $das_features{$name} = [@featref]; + } + } + return \%das_features; +} + 1; -- GitLab