Skip to content
Snippets Groups Projects
Commit 6ce75b17 authored by Ian Longden's avatar Ian Longden
Browse files

version_check changed to only check when adaptors are instantiated or not at...

version_check changed to only check when adaptors are instantiated or not at all if special file exists
parent 69e156a0
No related branches found
No related tags found
No related merge requests found
......@@ -108,6 +108,8 @@ use DBI;
use vars qw(%registry_register);
my $API_VERSION = 34;
=head2 load_all
......@@ -580,6 +582,10 @@ sub get_adaptor{
warning("$module cannot be found.\nException $@\n");
return undef;
}
if(!defined($registry_register{$species}{lc($group)}{'CHECKED'})){
$registry_register{$species}{lc($group)}{'CHECKED'} = 1;
$class->version_check($dba);
}
my $adap = "$module"->new($dba);
Bio::EnsEMBL::Registry->add_adaptor($species, $group, $type, $adap, "reset");
$ret = $adap;
......@@ -1103,5 +1109,39 @@ sub add_new_tracks{
}
sub software_version{
return $API_VERSION;
}
sub version_check{
my ($self, $dba) = @_;
# Check the datbase and versions match
# give warning if they do not.
if(-e $ENV{HOME}."/.ensemblapi_no_version_check"){
return;
}
my $mca = $self->get_adaptor($dba->species(),$dba->group(),"MetaContainer");
my $database_version = 0;
if(defined($mca)){
$database_version = $mca->get_schema_version();
}
if($database_version == 0){
#try to work out the version
if($dba->dbc->dbname() =~ /^_test_db_/){
return;
}
if($dba->dbc->dbname() =~ /\S+_\S+_\S+_(\d+)_\S+/){
$database_version = $1;
}
else{
warn("No database version for database ".$dba->dbc->dbname().". You must be using as pre version 34 database with version 34 or later code. You need to update your database or use the appropriate ensembl software release to ensure your script does not crash\n");
}
}
if($database_version != $API_VERSION){
warn("For ".$dba->dbc->dbname()." there is a difference in the software release (".$API_VERSION.") and the database release (".$database_version."). You should change one of these to ensure your script does not crash.\n");
}
}
1;
......@@ -45,8 +45,6 @@ use Bio::EnsEMBL::DBSQL::DBAdaptor;
use Bio::EnsEMBL::Utils::Exception qw(warning throw deprecate stack_trace_dump);
my $SOFTWARE_VERSION = 34;
=head2 load_core, load_estgene, load_vega, load_compara, load_pipeline, load_SNP, load_lite
Arg [1] : DBAdaptor with DBConnection alredy attached
Returntype : DBAdaptor;
......@@ -60,10 +58,6 @@ my $SOFTWARE_VERSION = 34;
# 3)
#
sub software_version{
return $SOFTWARE_VERSION;
}
sub gen_load{
my ($dba) = @_;
......@@ -246,40 +240,11 @@ sub load_and_attach_dnadb_to_core{
$reg->add_DNAAdaptor($dba->species,$dba->group,$dba->species,"core");
}
# those that do not need to attach to core:-#
sub check_version{
my ($dba) = @_;
# Check the datbase and versions match
# give warning if they do not.
my $mca = $reg->get_adaptor($dba->species(),$dba->group(),"MetaContainer");
my $database_version = 0;
if(defined($mca)){
$database_version = $mca->get_schema_version();
}
if($database_version == 0){
#try to work out the version
if($dba->dbc->dbname() =~ /^_test_db_/){
return;
}
if($dba->dbc->dbname() =~ /\S+_\S+_\S+_(\d+)_\S+/){
$database_version = $1;
}
else{
warn("No database version for database ".$dba->dbc->dbname().". You must be using as pre version 34 database with version 34 or later code. You need to update your database or use the appropriate ensembl software release to ensure your script does not crash\n");
}
}
if($database_version != $SOFTWARE_VERSION){
warn("For ".$dba->dbc->dbname()." there is a difference in the software release (".$SOFTWARE_VERSION.") and the database release (".$database_version."). You should change one of these to ensure your script does not crash.\n");
}
}
sub load_core{
my ($dba) = @_;
load_adaptors($dba);
check_version($dba);
}
sub load_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