From ee4735e47a392ea8cd2862407cd32af061c2c4be Mon Sep 17 00:00:00 2001 From: Ian Longden <ianl@sanger.ac.uk> Date: Tue, 11 Dec 2007 13:13:33 +0000 Subject: [PATCH] added remove_DBAdaptor method. (Nathans code - tested) --- modules/Bio/EnsEMBL/Registry.pm | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/modules/Bio/EnsEMBL/Registry.pm b/modules/Bio/EnsEMBL/Registry.pm index 1468a53388..23cf46bb6e 100644 --- a/modules/Bio/EnsEMBL/Registry.pm +++ b/modules/Bio/EnsEMBL/Registry.pm @@ -584,6 +584,42 @@ sub get_all_DBAdaptors_by_connection{ return \@return; } +=head2 remove_DBAdaptor + + Arg [1] : name of the species to get the adaptor for in the registry. + Arg [2] : name of the group to get the adaptor for in the registry. + Example : $dba = Bio::EnsEMBL::Registry->remove_DBAdaptor("Human", "core"); + Returntype : none + Exceptions : none + Status : At risk + +=cut + +sub remove_DBAdaptor{ + my ($class, $species, $group) = @_; + + $species = $class->get_alias($species); + + delete $registry_register{$species}{$group}; + #This will remove the DBAdaptor and all the other adaptors + + #Now remove if from the _DBA array + my $index; + + foreach my $i(0..$#{$registry_register{'_DBA'}}){ + my $dba = $registry_register{'_DBA'}->[$i]; + if(($dba->species eq $species) && + $dba->group eq $group){ + $index = $i; + last; + } + } + + @{$registry_register{'_DBA'}} = splice(@{$registry_register{'_DBA'}}, $index, 1); + + return; +} + # # DNA Adaptors -- GitLab