Skip to content
Snippets Groups Projects
Commit 2292b772 authored by Kieron Taylor's avatar Kieron Taylor :angry:
Browse files

Fix for production team, for whom changing taxonomy ids (Gorilla) caused it to...

Fix for production team, for whom changing taxonomy ids (Gorilla) caused it to leave old metadata behind. Failure triggers an attempt to guess taxon id by regexing the end of the dbname off and searching by that instead of taxon id.
parent 00262241
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,7 @@ use POSIX; ...@@ -9,6 +9,7 @@ use POSIX;
use Bio::EnsEMBL::DBSQL::DBAdaptor; use Bio::EnsEMBL::DBSQL::DBAdaptor;
use Bio::EnsEMBL::DBSQL::DBConnection; use Bio::EnsEMBL::DBSQL::DBConnection;
use Bio::EnsEMBL::Utils::Scalar qw/wrap_array/; use Bio::EnsEMBL::Utils::Scalar qw/wrap_array/;
use Bio::EnsEMBL::Utils::Exception;
sub run { sub run {
my ($class) = @_; my ($class) = @_;
...@@ -134,33 +135,58 @@ sub databases { ...@@ -134,33 +135,58 @@ sub databases {
return $dbs; return $dbs;
} }
sub _query_production {
my ( $self, $sql ) = @_;
my $dbc = $self->_production_dbc();
my $h = $dbc->sql_helper();
my $hash;
$h->execute_no_return(
-SQL => $sql,
-PARAMS => [$taxon],
-CALLBACK => sub {
my ($row) = @_;
my $i = 0;
$hash->{'species.common_name'} = $row->[ $i++ ];
$hash->{'species.display_name'} = $row->[ $i++ ];
$hash->{'species.scientific_name'} = $row->[ $i++ ];
$hash->{'species.production_name'} = $row->[ $i++ ];
$hash->{'species.url'} = $row->[ $i++ ];
$hash->{'species.taxonomy_id'} = $row->[ $i++ ];
$hash->{'species.stable_id_prefix'} = $row->[ $i++ ];
return;
}
);
return $hash;
}
sub _production { sub _production {
my ( $self, $db ) = @_; my ( $self, $db ) = @_;
$self->v('Querying production'); $self->v('Querying production');
my $dbc = $self->_production_dbc(); my $dbc = $self->_production_dbc();
my $h = $dbc->sql_helper(); my $h = $dbc->sql_helper();
my $taxon = $self->_db_to_taxon($db); my $taxon = $self->_db_to_taxon($db);
my $hash = { 'species.taxonomy_id' => $taxon };
my $sql = my $sql = 'select common_name, web_name, scientific_name, production_name, url_name, taxon, species_prefix from species where taxon =?';
'select common_name, web_name, scientific_name, production_name, url_name, species_prefix from species where taxon =?'; my $hash = $self->_query_production($sql);
$h->execute_no_return(
-SQL => $sql, if (!exists $hash->{'species.common_name'}) {
-PARAMS => [$taxon], # taxon id was *probably* not obtained, try again using database name
-CALLBACK => sub { warning("Failed to find original taxon id for $db. Attempting to obtain by DB name instead");
my ($row) = @_; my $db_name = $db;
my $i = 0; $db_name =~ s/_\w+_\d+_.+$//;
$hash->{'species.common_name'} = $row->[ $i++ ]; $sql = 'select common_name, web_name, scientific_name, production_name, url_name, taxon, species_prefix from species where db_name = ?';
$hash->{'species.display_name'} = $row->[ $i++ ]; $self->_query_production($sql);
$hash->{'species.scientific_name'} = $row->[ $i++ ];
$hash->{'species.production_name'} = $row->[ $i++ ]; # Update $taxon to reflect new guessed id
$hash->{'species.url'} = $row->[ $i++ ]; $taxon = $hash->{'species.taxonomy_id'};
$hash->{'species.stable_id_prefix'} = $row->[ $i++ ]; }
return;
}
);
$hash->{'species.alias'} = $h->execute_simple( $hash->{'species.alias'} = $h->execute_simple(
-SQL => -SQL => 'select sa.alias from species_alias sa join species s using (species_id) where s.taxon =?',
'select sa.alias from species_alias sa join species s using (species_id) where s.taxon =?',
-PARAMS => [$taxon] -PARAMS => [$taxon]
); );
return $hash; return $hash;
......
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