From b1ca6d5243d8e7a5232eafb821da18f5b0ba9b9d Mon Sep 17 00:00:00 2001 From: Ian Longden <ianl@sanger.ac.uk> Date: Thu, 10 Mar 2011 16:47:04 +0000 Subject: [PATCH] report warning if regitry call to get_alias is called with an invalid species name. Also had to add option to get_DBAdaptor to not look up aliases so that warning are not given the first time we use it --- modules/Bio/EnsEMBL/Registry.pm | 16 ++++++++++++---- modules/Bio/EnsEMBL/Utils/ConfigRegistry.pm | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/Bio/EnsEMBL/Registry.pm b/modules/Bio/EnsEMBL/Registry.pm index 0a1d13ec71..5359ea9e41 100644 --- a/modules/Bio/EnsEMBL/Registry.pm +++ b/modules/Bio/EnsEMBL/Registry.pm @@ -554,6 +554,7 @@ sub add_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. + Arg [3] : if set will not look for alias. Example : $dba = Bio::EnsEMBL::Registry->get_DBAdaptor("Human", "core"); Returntype : DBAdaptor Exceptions : none @@ -562,10 +563,11 @@ sub add_DBAdaptor { =cut sub get_DBAdaptor { - my ( $class, $species, $group ) = @_; + my ( $class, $species, $group , $no_alias_check) = @_; throw 'arrggh for '.$species if ! defined $species; - $species = $class->get_alias($species); - + if(!defined($no_alias_check) or !$no_alias_check){ + $species = $class->get_alias($species); + } return $registry_register{_SPECIES}{$species}{ lc($group) }{'_DB'}; } @@ -1104,7 +1106,13 @@ sub get_alias{ my ($class, $key) = @_; if(!defined($registry_register{'_ALIAS'}{lc($key)})){ - return $key; + if(!defined( $registry_register{_SPECIES}{ lc($key) }) and !defined ($registry_register{_ALIAS}{ lc($key) })){ + warn "$key is not a valid species name for this instance\n"; + return undef; + } + else{ + return $key; + } } return $registry_register{'_ALIAS'}{lc($key)}; } diff --git a/modules/Bio/EnsEMBL/Utils/ConfigRegistry.pm b/modules/Bio/EnsEMBL/Utils/ConfigRegistry.pm index 4eee78fff6..ed6b06c143 100644 --- a/modules/Bio/EnsEMBL/Utils/ConfigRegistry.pm +++ b/modules/Bio/EnsEMBL/Utils/ConfigRegistry.pm @@ -154,7 +154,7 @@ sub gen_load { # return if the connection and species, group are the same if ( defined( $dba->species ) ) { - my $db_reg = $reg->get_DBAdaptor( $dba->species, $dba->group ); + my $db_reg = $reg->get_DBAdaptor( $dba->species, $dba->group, 1 ); if ( defined($db_reg) ) { if ( $dba->dbc->equals( $db_reg->dbc ) ) { return $db_reg } else { @@ -169,6 +169,7 @@ sub gen_load { } } } else { # no species + my @db_reg = @{ $reg->get_all_DBAdaptors_by_connection( $dba->dbc ) }; -- GitLab