From bbc30a4eb88dfd5a3130fe3c89eb8515b8efe961 Mon Sep 17 00:00:00 2001 From: Andrew Yates <ayates@ebi.ac.uk> Date: Fri, 21 Sep 2012 16:01:03 +0000 Subject: [PATCH] [ENSCORESW-261]. Edits to allow for easier regulation adaptor creation. Grab the species name from the DB if it wasn't given to the adaptor and make sure we avoid returning the coord system core adaptor if the group was funcgen --- modules/Bio/EnsEMBL/Registry.pm | 4 ++-- modules/Bio/EnsEMBL/Utils/ConfigRegistry.pm | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/modules/Bio/EnsEMBL/Registry.pm b/modules/Bio/EnsEMBL/Registry.pm index ba96c628f2..da893779a9 100644 --- a/modules/Bio/EnsEMBL/Registry.pm +++ b/modules/Bio/EnsEMBL/Registry.pm @@ -943,7 +943,7 @@ sub add_adaptor { } if ( !defined( $registry_register{_TYPE}{ lc($type) }{$species} ) ) { - $registry_register{_TYPE}{ lc($type) }{$species} = [$type]; + $registry_register{_TYPE}{ lc($type) }{$species} = [$adap]; } else { push( @{ $registry_register{_TYPE}{ lc($type) }{$species} }, $adap ); @@ -990,7 +990,7 @@ sub get_adaptor { 'assemblymapper' => 1, 'karyotypeband' => 1, 'repeatfeature' => 1, - 'coordsystem' => 1, + 'coordsystem' => ((lc($group) ne 'funcgen') ? 1 : undef), 'assemblyexceptionfeature' => 1 ); diff --git a/modules/Bio/EnsEMBL/Utils/ConfigRegistry.pm b/modules/Bio/EnsEMBL/Utils/ConfigRegistry.pm index 5b2481ea2e..7c686ca0f3 100644 --- a/modules/Bio/EnsEMBL/Utils/ConfigRegistry.pm +++ b/modules/Bio/EnsEMBL/Utils/ConfigRegistry.pm @@ -54,6 +54,7 @@ use Bio::EnsEMBL::Utils::Exception qw(warning throw deprecate stack_trace_dump) sub gen_load { my ($dba) = @_; + my $pre_hook; my $config_sub; # At some point we hope to set the group in the DBadaptor, hence this @@ -106,6 +107,7 @@ sub gen_load { if ( !defined( $dba->group() ) ) { $dba->group('funcgen'); } + $pre_hook = \&Bio::EnsEMBL::Utils::ConfigRegistry::pre_funcgen_hook; $config_sub = \&Bio::EnsEMBL::Utils::ConfigRegistry::load_funcgen; } elsif ( $dba->isa('Bio::Ensembl::DBSQL::OntologyTermAdaptor') ) { if ( !defined( $dba->group() ) ) { @@ -138,6 +140,9 @@ sub gen_load { \&Bio::EnsEMBL::Utils::ConfigRegistry::load_and_attach_dnadb_to_core; # throw("Unknown DBAdaptor type $dba\n"); } + + #Run the pre-hook if one was defined + $pre_hook->($dba) if $pre_hook; # return if the connection and species, group are the same @@ -326,6 +331,22 @@ sub add_alias { } } +# WARNING: "CONVENIENCE METHOD" for retriving the species name when one was +# not set. Regulation DB requirement +sub pre_funcgen_hook { + my ($dba) = @_; + if(! $dba->species() ) { + warn "Setting name"; + my $name = $dba->dbc()->sql_helper()->execute_single_result( + -SQL => 'select meta_value from meta where meta_key =?', + -PARAMS => ['species.production_name'], + ); + $dba->dbc()->disconnect_if_idle(); + $dba->species($name); + } + return; +} + # # overwrite/load new types. Done this way to enable no changes to CVS for # external users. External users should add there own "GROUPS" in the file -- GitLab