Unverified Commit b687ee4d authored by ens-bwalts's avatar ens-bwalts Committed by GitHub
Browse files

Merge pull request #379 from Ensembl/feature/ENSCORESW-3119_master

Registry: add support for versioned ensembl_metadata DBs [master]
parents cb7c8c69 79aeae37
...@@ -1743,6 +1743,7 @@ sub load_registry_from_db { ...@@ -1743,6 +1743,7 @@ sub load_registry_from_db {
my $taxonomy_db; my $taxonomy_db;
my $ensembl_metadata_db; my $ensembl_metadata_db;
my $ensembl_metadata_db_versioned;
my $production_dba_ok = my $production_dba_ok =
eval { require Bio::EnsEMBL::Production::DBSQL::DBAdaptor; 1 }; eval { require Bio::EnsEMBL::Production::DBSQL::DBAdaptor; 1 };
...@@ -1818,6 +1819,11 @@ sub load_registry_from_db { ...@@ -1818,6 +1819,11 @@ sub load_registry_from_db {
$taxonomy_db = $db; $taxonomy_db = $db;
} elsif ( $db =~ /^ensembl_metadata$/ ) { } elsif ( $db =~ /^ensembl_metadata$/ ) {
$ensembl_metadata_db = $db; $ensembl_metadata_db = $db;
}
elsif ( $db =~ m{ \A ensembl_metadata_(\d+) \z }msx ) {
if ( $1 eq $software_version ) {
$ensembl_metadata_db_versioned = $db;
}
} elsif ( $production_dba_ok and $db =~ /^ensembl(?:genomes)?_production(_\d+)?/x ) { } elsif ( $production_dba_ok and $db =~ /^ensembl(?:genomes)?_production(_\d+)?/x ) {
# production db can come with no version (i.e. that on ens-staging1), # production db can come with no version (i.e. that on ens-staging1),
# but it's backed up with a release number # but it's backed up with a release number
...@@ -2349,7 +2355,7 @@ sub load_registry_from_db { ...@@ -2349,7 +2355,7 @@ sub load_registry_from_db {
# ensembl_metadata # ensembl_metadata
if ( defined $ensembl_metadata_db) { if ( ( defined $ensembl_metadata_db ) || ( defined $ensembl_metadata_db_versioned ) ) {
my $has_metadata = eval {require Bio::EnsEMBL::MetaData::DBSQL::MetaDataDBAdaptor}; my $has_metadata = eval {require Bio::EnsEMBL::MetaData::DBSQL::MetaDataDBAdaptor};
if($@ or (!defined $has_metadata)) { if($@ or (!defined $has_metadata)) {
...@@ -2357,6 +2363,16 @@ sub load_registry_from_db { ...@@ -2357,6 +2363,16 @@ sub load_registry_from_db {
print "ensembl_metadata API not found - ignoring $ensembl_metadata_db\n"; print "ensembl_metadata API not found - ignoring $ensembl_metadata_db\n";
} }
} else { } else {
my $metadata_dbname;
# Versioned database has priority over unversioned one.
if ( defined $ensembl_metadata_db_versioned ) {
$metadata_dbname = $ensembl_metadata_db_versioned;
}
else {
$metadata_dbname = $ensembl_metadata_db;
}
my $dba = Bio::EnsEMBL::MetaData::DBSQL::MetaDataDBAdaptor->new( my $dba = Bio::EnsEMBL::MetaData::DBSQL::MetaDataDBAdaptor->new(
'-species' => 'multi' . $species_suffix, '-species' => 'multi' . $species_suffix,
'-group' => 'metadata', '-group' => 'metadata',
...@@ -2364,10 +2380,10 @@ sub load_registry_from_db { ...@@ -2364,10 +2380,10 @@ sub load_registry_from_db {
'-port' => $port, '-port' => $port,
'-user' => $user, '-user' => $user,
'-pass' => $pass, '-pass' => $pass,
'-dbname' => $ensembl_metadata_db, ); '-dbname' => $metadata_dbname, );
if ($verbose) { if ($verbose) {
printf( "%s loaded\n", $ensembl_metadata_db ); printf( "%s loaded\n", $metadata_dbname );
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment