Skip to content
Snippets Groups Projects
Commit 220229e7 authored by Andreas Kusalananda Kähäri's avatar Andreas Kusalananda Kähäri
Browse files

More patches from Andy Yates.

* Correction to a previous commit regarding a multi-species regular
  expression.

* Add registration of multi-species user upload databases.

* Add registration of multi-species functional genomics databases.
parent de129e2e
No related branches found
No related tags found
No related merge requests found
......@@ -1406,7 +1406,7 @@ sub load_registry_from_db {
}
for my $db (@dbnames) {
if ( $db =~ /^(\w+)_(collection_\w_(?:\d+_)?(\d+)_(\w+))/ )
if ( $db =~ /^(\w+)_(collection_\w+_(?:\d+_)?(\d+)_(\w+))/ )
{ # NEEDS TO BE FIRST
if ( $3 eq $software_version ) {
$temp{$1} = $2;
......@@ -1429,9 +1429,7 @@ sub load_registry_from_db {
if ( $2 eq $software_version ) {
$ontology_version = $2;
}
} elsif (
$db =~ /^([a-z]+_[a-z]+_[a-z]+(?:_\d+)?)_(\d+)_(\w+)/ )
{
} elsif ( $db =~ /^([a-z]+_[a-z]+_[a-z]+(?:_\d+)?)_(\d+)_(\w+)/ ) {
if ( $2 eq $software_version ) {
$temp{$1} = $2 . "_" . $3;
}
......@@ -1451,7 +1449,10 @@ sub load_registry_from_db {
my @core_dbs = grep { /^[a-z]+_[a-z]+_core_(?:\d+_)?\d+_/ } @dbnames;
foreach my $coredb (@core_dbs) {
next if ($coredb =~ /collection/); # Skip multi-species databases
if ( index( $coredb, 'collection' ) != -1 ) {
# Skip multi-species databases.
next;
}
my ( $species, $num ) =
( $coredb =~ /(^[a-z]+_[a-z]+)_core_(?:\d+_)?(\d+)/ );
......@@ -1475,14 +1476,15 @@ sub load_registry_from_db {
}
# Register multi-species databases
my @multi_dbs = grep { /^\w+_collection_core_\w+$/ } @dbnames;
foreach my $multidb (@multi_dbs) {
my $sth =
$dbh->prepare(
sprintf( 'SELECT species_id, meta_value FROM %s.meta ',
$dbh->quote_identifier($multidb) )
. "WHERE meta_key = 'species.db_name'" );
my $sth = $dbh->prepare(
sprintf(
"SELECT species_id, meta_value FROM %s.meta "
. "WHERE meta_key = 'species.db_name'",
$dbh->quote_identifier($multidb) ) );
$sth->execute();
......@@ -1490,23 +1492,23 @@ sub load_registry_from_db {
$sth->bind_columns( \( $species_id, $species ) );
while ( $sth->fetch() ) {
my $dba =
Bio::EnsEMBL::DBSQL::DBAdaptor->new(
-group => "core",
-species => $species,
-species_id => $species_id,
-multispecies_db => 1,
-host => $host,
-user => $user,
-pass => $pass,
-port => $port,
-dbname => $multidb,
-wait_timeout => $wait_timeout,
-no_cache => $no_cache );
my $dba = Bio::EnsEMBL::DBSQL::DBAdaptor->new(
-group => "core",
-species => $species,
-species_id => $species_id,
-multispecies_db => 1,
-host => $host,
-user => $user,
-pass => $pass,
-port => $port,
-dbname => $multidb,
-wait_timeout => $wait_timeout,
-no_cache => $no_cache
);
if ($verbose) {
printf( "Species '%s' (id:%d) loaded from database '%s'\n",
$species, $species_id, $multidb );
$species, $species_id, $multidb );
}
}
} ## end foreach my $multidb (@multi_dbs)
......@@ -1585,6 +1587,11 @@ sub load_registry_from_db {
my @userupload_dbs = grep { /_userdata$/ } @dbnames;
for my $userupload_db (@userupload_dbs) {
if ( index( $userupload_db, 'collection' ) != -1 ) {
# Skip multi-species databases.
next;
}
my ($species) = ( $userupload_db =~ /(^.+)_userdata$/ );
my $dba =
Bio::EnsEMBL::DBSQL::DBAdaptor->new(
......@@ -1603,6 +1610,43 @@ sub load_registry_from_db {
}
}
# Register multi-species userupload databases.
my @userdata_multidbs = grep { /^.+_collection_userdata$/ } @dbnames;
foreach my $multidb (@userdata_multidbs) {
my $sth = $dbh->prepare(
sprintf(
"SELECT species_id, meta_value FROM %s.meta "
. "WHERE meta_key = 'species.db_name'",
$dbh->quote_identifier($multidb) ) );
$sth->execute();
my ( $species_id, $species );
$sth->bind_columns( \( $species_id, $species ) );
while ( $sth->fetch() ) {
my $dba = Bio::EnsEMBL::DBSQL::DBAdaptor->new(
-group => "userupload",
-species => $species,
-species_id => $species_id,
-multispecies_db => 1,
-host => $host,
-user => $user,
-pass => $pass,
-port => $port,
-dbname => $multidb,
-wait_timeout => $wait_timeout,
-no_cache => $no_cache
);
if ($verbose) {
printf( "Species '%s' (id:%d) loaded from database '%s'\n",
$species, $species_id, $multidb );
}
}
} ## end foreach my $multidb (@userdata_multidbs)
# Variation
eval "require Bio::EnsEMBL::Variation::DBSQL::DBAdaptor";
......@@ -1642,33 +1686,77 @@ sub load_registry_from_db {
if ($@) {
if ($verbose) {
# Ignore funcgen DBs as code required not there for this
print( "Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor module not found "
. "so functional genomics databases will be ignored if found\n"
print("Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor module not found "
. "so functional genomics databases will be ignored if found\n"
);
}
} else {
my @funcgen_dbs = grep { /^[a-z]+_[a-z]+_funcgen_(?:\d+_)?\d+_/ } @dbnames;
my @funcgen_dbs =
grep { /^[a-z]+_[a-z]+_funcgen_(?:\d+_)?\d+_/ } @dbnames;
for my $funcgen_db (@funcgen_dbs) {
if ( index( $funcgen_db, 'collection' ) != -1 ) {
# Skip multi-species databases.
next;
}
my ( $species, $num ) =
( $funcgen_db =~ /(^[a-z]+_[a-z]+)_funcgen_(?:\d+_)?(\d+)_/ );
my $dba =
Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor->new(
-group => "funcgen",
-species => $species,
-host => $host,
-user => $user,
-pass => $pass,
-port => $port,
-wait_timeout => $wait_timeout,
-dbname => $funcgen_db,
-no_cache => $no_cache );
my $dba = Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor->new(
-group => "funcgen",
-species => $species,
-host => $host,
-user => $user,
-pass => $pass,
-port => $port,
-wait_timeout => $wait_timeout,
-dbname => $funcgen_db,
-no_cache => $no_cache
);
if ($verbose) {
printf( "%s loaded\n", $funcgen_db );
}
}
}
# Register functional genomics multispecies databases
my @funcgen_multidbs =
grep { /^\w+_collection_funcgen_\w+$/ } @dbnames;
foreach my $multidb (@funcgen_multidbs) {
my $sth = $dbh->prepare(
sprintf( 'SELECT species_id, meta_value FROM %s.meta ',
$dbh->quote_identifier($multidb) )
. "WHERE meta_key = 'species.db_name'"
);
$sth->execute();
my ( $species_id, $species );
$sth->bind_columns( \( $species_id, $species ) );
while ( $sth->fetch() ) {
my $dba = Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor->new(
-group => "funcgen",
-species => $species,
-species_id => $species_id,
-multispecies_db => 1,
-host => $host,
-user => $user,
-pass => $pass,
-port => $port,
-dbname => $multidb,
-wait_timeout => $wait_timeout,
-no_cache => $no_cache
);
if ($verbose) {
printf( "Species '%s' (id:%d) loaded from database '%s'\n",
$species, $species_id, $multidb );
}
}
} ## end foreach my $multidb (@funcgen_multidbs)
} ## end else [ if ($@) ]
# Compara
......
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