From d9eaabe4dc809405a9b207dc230e0738ea8f57f6 Mon Sep 17 00:00:00 2001 From: Jessica Severin <jessica@ebi.ac.uk> Date: Mon, 18 Apr 2005 11:07:54 +0000 Subject: [PATCH] made more Registry friendly by setting -species to be the $dbname thus allowing one to do hybrid URL/Registry code like... if($url) { $dbc = Bio::EnsEMBL::Hive::URLFactory->fetch($url, 'compara')->dbc; $dbname = $dbc->dbname(); } else { $dbc = Bio::EnsEMBL::Registry->get_DBAdaptor($dbname,'compara')->dbc; } $fa = Bio::EnsEMBL::Registry->get_adaptor($dbname,'compara','Family'); --- modules/Bio/EnsEMBL/Hive/URLFactory.pm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/Bio/EnsEMBL/Hive/URLFactory.pm b/modules/Bio/EnsEMBL/Hive/URLFactory.pm index fe8e7efca..134b77283 100755 --- a/modules/Bio/EnsEMBL/Hive/URLFactory.pm +++ b/modules/Bio/EnsEMBL/Hive/URLFactory.pm @@ -38,6 +38,7 @@ my $_URLFactory_global_instance; package Bio::EnsEMBL::Hive::URLFactory; use strict; +use Switch; use Bio::EnsEMBL::Utils::Argument; use Bio::EnsEMBL::Utils::Exception; @@ -195,10 +196,15 @@ sub _get_db_connection return ($dba,$path) if($dba); #print("CONNECT via\n user=$user\n pass=$pass\n host=$host\n port=$port\n dbname=$dbname\n path=$path\n type=$type\n"); - $module = "Bio::EnsEMBL::DBSQL::DBAdaptor" if($type eq 'core'); - $module = "Bio::EnsEMBL::Compara::DBSQL::DBAdaptor" if($type eq 'compara'); - $module = "Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor" if($type eq 'pipeline'); - + switch ($type) { + case 'core' { $module = "Bio::EnsEMBL::DBSQL::DBAdaptor"; } + case 'pipeline' { $module = "Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor"; } + case 'compara' { + use Bio::EnsEMBL::Compara::DBSQL::DBAdaptor; + $module = "Bio::EnsEMBL::Compara::DBSQL::DBAdaptor"; + } + } + $dba = "$module"->new ( -disconnect_when_inactive => 0, -driver => 'mysql', @@ -206,7 +212,9 @@ sub _get_db_connection -pass => $pass, -host => $host, -port => $port, - -dbname => $dbname); + -dbname => $dbname, + -species => $dbname + ); $_URLFactory_global_instance->{$connectionKey} = $dba; return ($dba,$path); -- GitLab