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

changes for registry mainly due to the fact that DBAdaptor no longer inherits from DBConnection

parent 534916d1
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,7 @@ $aa->store_on_MiscFeature($mf, [$attrib]); ...@@ -50,7 +50,7 @@ $aa->store_on_MiscFeature($mf, [$attrib]);
# #
# make sure the misc_attrib table was updated # make sure the misc_attrib table was updated
# #
my $count = $db->db_handle->selectall_arrayref my $count = $db->db->db_handle->selectall_arrayref
("SELECT count(*) FROM misc_attrib " . ("SELECT count(*) FROM misc_attrib " .
"WHERE misc_feature_id = 1")->[0]->[0]; "WHERE misc_feature_id = 1")->[0]->[0];
...@@ -59,7 +59,7 @@ ok($count == 1); ...@@ -59,7 +59,7 @@ ok($count == 1);
# #
# make sure the attrib_type table was updated # make sure the attrib_type table was updated
# #
$count = $db->db_handle->selectall_arrayref $count = $db->db->db_handle->selectall_arrayref
("SELECT count(*) FROM attrib_type " . ("SELECT count(*) FROM attrib_type " .
"WHERE code = 'test_code'")->[0]->[0]; "WHERE code = 'test_code'")->[0]->[0];
ok($count == 1); ok($count == 1);
...@@ -87,7 +87,7 @@ $aa->remove_from_MiscFeature($mf); ...@@ -87,7 +87,7 @@ $aa->remove_from_MiscFeature($mf);
# #
# make sure the misc_attrib table was updated # make sure the misc_attrib table was updated
# #
$count = $db->db_handle->selectall_arrayref $count = $db->db->db_handle->selectall_arrayref
("SELECT count(*) FROM misc_attrib " . ("SELECT count(*) FROM misc_attrib " .
"WHERE misc_feature_id = 1")->[0]->[0]; "WHERE misc_feature_id = 1")->[0]->[0];
...@@ -119,7 +119,7 @@ $aa->store_on_Slice($slice, [$attrib]); ...@@ -119,7 +119,7 @@ $aa->store_on_Slice($slice, [$attrib]);
# #
# make sure the seq_region_attrib table was updated # make sure the seq_region_attrib table was updated
# #
$count = $db->db_handle->selectall_arrayref $count = $db->db->db_handle->selectall_arrayref
("SELECT count(*) FROM seq_region_attrib " . ("SELECT count(*) FROM seq_region_attrib " .
"WHERE seq_region_id = ".$slice->get_seq_region_id())->[0]->[0]; "WHERE seq_region_id = ".$slice->get_seq_region_id())->[0]->[0];
...@@ -128,7 +128,7 @@ ok($count == 1); ...@@ -128,7 +128,7 @@ ok($count == 1);
# #
# make sure the attrib_type table was updated # make sure the attrib_type table was updated
# #
$count = $db->db_handle->selectall_arrayref $count = $db->db->db_handle->selectall_arrayref
("SELECT count(*) FROM attrib_type " . ("SELECT count(*) FROM attrib_type " .
"WHERE code = 'test_code2'")->[0]->[0]; "WHERE code = 'test_code2'")->[0]->[0];
ok($count == 1); ok($count == 1);
...@@ -156,7 +156,7 @@ $aa->remove_from_Slice($slice); ...@@ -156,7 +156,7 @@ $aa->remove_from_Slice($slice);
# #
# make sure the seq_region_attrib table was updated # make sure the seq_region_attrib table was updated
# #
$count = $db->db_handle->selectall_arrayref $count = $db->db->db_handle->selectall_arrayref
("SELECT count(*) FROM seq_region_attrib " . ("SELECT count(*) FROM seq_region_attrib " .
"WHERE seq_region_id = " . $slice->get_seq_region_id())->[0]->[0]; "WHERE seq_region_id = " . $slice->get_seq_region_id())->[0]->[0];
...@@ -178,7 +178,7 @@ $aa->store_on_Slice($slice, [$attrib]); ...@@ -178,7 +178,7 @@ $aa->store_on_Slice($slice, [$attrib]);
# #
# make sure the seq_region_attrib table was updated # make sure the seq_region_attrib table was updated
# #
$count = $db->db_handle->selectall_arrayref $count = $db->db->db_handle->selectall_arrayref
("SELECT count(*) FROM seq_region_attrib " . ("SELECT count(*) FROM seq_region_attrib " .
"WHERE seq_region_id = ".$slice->get_seq_region_id())->[0]->[0]; "WHERE seq_region_id = ".$slice->get_seq_region_id())->[0]->[0];
...@@ -187,7 +187,7 @@ ok($count == 1); ...@@ -187,7 +187,7 @@ ok($count == 1);
# #
# make sure the attrib_type table was updated # make sure the attrib_type table was updated
# #
$count = $db->db_handle->selectall_arrayref $count = $db->db->db_handle->selectall_arrayref
("SELECT count(*) FROM attrib_type " . ("SELECT count(*) FROM attrib_type " .
"WHERE code = 'test_code2'")->[0]->[0]; "WHERE code = 'test_code2'")->[0]->[0];
ok($count == 1); ok($count == 1);
......
...@@ -36,8 +36,8 @@ $test_adaptor = $db->get_ProteinFeatureAdaptor(); ...@@ -36,8 +36,8 @@ $test_adaptor = $db->get_ProteinFeatureAdaptor();
ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::ProteinFeatureAdaptor")); ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::ProteinFeatureAdaptor"));
#$test_adaptor = $db->get_ProteinAdaptor(); #$test_adaptor = $db->get_ProteinAdaptor();
#ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::ProteinAdaptor")); #ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::ProteinAdaptor"));
$test_adaptor = $db->get_MapFragAdaptor(); #$test_adaptor = $db->get_MapFragAdaptor();
ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::MapFragAdaptor")); #ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::MapFragAdaptor"));
#$test_adaptor = $db->get_CloneAdaptor(); #$test_adaptor = $db->get_CloneAdaptor();
#ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::CloneAdaptor")); #ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::CloneAdaptor"));
$test_adaptor = $db->get_PredictionTranscriptAdaptor(); $test_adaptor = $db->get_PredictionTranscriptAdaptor();
...@@ -74,8 +74,8 @@ $test_adaptor = $db->get_DBEntryAdaptor(); ...@@ -74,8 +74,8 @@ $test_adaptor = $db->get_DBEntryAdaptor();
ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::DBEntryAdaptor")); ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::DBEntryAdaptor"));
$test_adaptor = $db->get_KaryotypeBandAdaptor(); $test_adaptor = $db->get_KaryotypeBandAdaptor();
ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::KaryotypeBandAdaptor")); ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::KaryotypeBandAdaptor"));
$test_adaptor = $db->get_ChromosomeAdaptor(); #$test_adaptor = $db->get_ChromosomeAdaptor();
ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::ChromosomeAdaptor")); #ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::ChromosomeAdaptor"));
$test_adaptor = $db->get_SupportingFeatureAdaptor(); $test_adaptor = $db->get_SupportingFeatureAdaptor();
ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::SupportingFeatureAdaptor")); ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::SupportingFeatureAdaptor"));
$test_adaptor = $db->get_MarkerFeatureAdaptor(); $test_adaptor = $db->get_MarkerFeatureAdaptor();
...@@ -93,19 +93,20 @@ ok($test_adaptor->isa("Bio::EnsEMBL::Map::DBSQL::MarkerAdaptor")); ...@@ -93,19 +93,20 @@ ok($test_adaptor->isa("Bio::EnsEMBL::Map::DBSQL::MarkerAdaptor"));
#ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::ProxySNPAdaptor")); #ok($test_adaptor->isa("Bio::EnsEMBL::DBSQL::ProxySNPAdaptor"));
# Should get an error if we ask for something non-existent # Should get an error if we ask for something non-existent
eval { $db->get_adaptor("SomeNonExistentType") }; #eval { $db->get_adaptor("SomeNonExistentType") };
ok($@); #ok($@);
# Check setting module with good values # Check setting module with good values
ok($db->set_adaptor("ArchiveStableId", "Bio::EnsEMBL::DBSQL::ArchiveStableIdAdaptor" )); ok($db->set_adaptor("ArchiveStableId", "Bio::EnsEMBL::DBSQL::ArchiveStableIdAdaptor" ));
# Setting an unknown data type should give an error # Setting an unknown data type should NO LONGER give an error
eval { $db->set_adaptor("SomeNonExistentType", "Bio::EnsEMBL::DBSQL::ArchiveStableIdAdaptor") }; my $ret = $db->set_adaptor("SomeNonExistentType", "Bio::EnsEMBL::DBSQL::ArchiveStableIdAdaptor");
ok($@); ok(defined($ret));
# Setting to a non-subclass of the default should give an error
eval { $db->set_adaptor("ArchiveStableId", "Bio::EnsEMBL::DBSQL::GeneAdaptor") }; # Setting to a non-subclass of the default should NOT give an error
ok($@); $ret = $db->set_adaptor("ArchiveStableId", "Bio::EnsEMBL::DBSQL::GeneAdaptor");
ok(defined($ret));
# Generic adaptors # Generic adaptors
......
...@@ -36,7 +36,7 @@ $multi_db->save('core', 'dnac', 'seq_region'); ...@@ -36,7 +36,7 @@ $multi_db->save('core', 'dnac', 'seq_region');
#we can get weird padding at the end due to the last byte being not #we can get weird padding at the end due to the last byte being not
#fully packed but still labelled as non-gap #fully packed but still labelled as non-gap
my $sth = my $sth =
$db->prepare('INSERT INTO seq_region (name, length, coord_system_id) ' . $db->db->prepare('INSERT INTO seq_region (name, length, coord_system_id) ' .
'VALUES (?,?,?)'); 'VALUES (?,?,?)');
$sth->execute('testfrag', $len,$contig_cs->dbID); $sth->execute('testfrag', $len,$contig_cs->dbID);
......
...@@ -155,7 +155,7 @@ ok(!$cs->is_sequence_level); ...@@ -155,7 +155,7 @@ ok(!$cs->is_sequence_level);
ok(!$cs->is_top_level); ok(!$cs->is_top_level);
ok($cs->rank() == 10); ok($cs->rank() == 10);
my $sth = $db->prepare('SELECT attrib FROM coord_system ' . my $sth = $db->db->prepare('SELECT attrib FROM coord_system ' .
'WHERE name = ? and version = ?'); 'WHERE name = ? and version = ?');
$sth->execute('newsystem', 'NCBI35'); $sth->execute('newsystem', 'NCBI35');
......
use lib 't';
use strict; use strict;
use warnings; use warnings;
BEGIN { $| = 1; BEGIN { $| = 1;
use Test; use Test;
plan tests => 30; plan tests => 24;
} }
use Bio::EnsEMBL::Test::MultiTestDB; use Bio::EnsEMBL::Test::MultiTestDB;
...@@ -29,12 +30,12 @@ my $db = $multi->get_DBAdaptor('core'); ...@@ -29,12 +30,12 @@ my $db = $multi->get_DBAdaptor('core');
# #
my $dbc; my $dbc;
{ {
my $db_name = $db->dbname; my $db_name = $db->db->dbname;
my $port = $db->port; my $port = $db->db->port;
my $user = $db->username; my $user = $db->db->username;
my $pass = $db->password; my $pass = $db->db->password;
my $host = $db->host; my $host = $db->db->host;
my $driver = $db->driver; my $driver = $db->db->driver;
$dbc = Bio::EnsEMBL::DBSQL::DBConnection->new(-dbname => $db_name, $dbc = Bio::EnsEMBL::DBSQL::DBConnection->new(-dbname => $db_name,
-user => $user, -user => $user,
...@@ -72,17 +73,17 @@ ok(test_getter_setter($dbc, 'username', 'ensembl_user')); ...@@ -72,17 +73,17 @@ ok(test_getter_setter($dbc, 'username', 'ensembl_user'));
ok(test_getter_setter($dbc, 'password', 'ensembl_password')); ok(test_getter_setter($dbc, 'password', 'ensembl_password'));
# #
# 8-9 _get_adaptor # 8-9 _get_adaptor NO LONGER ALLOWED MUST GO VIA DBAdaptor
# #
my $adaptor_name = 'Bio::EnsEMBL::DBSQL::GeneAdaptor'; #my $adaptor_name = 'Bio::EnsEMBL::DBSQL::GeneAdaptor';
my $adaptor = $dbc->_get_adaptor($adaptor_name); #my $adaptor = $dbc->_get_adaptor($adaptor_name);
ok($adaptor->isa($adaptor_name)); #ok($adaptor->isa($adaptor_name));
ok($adaptor == $dbc->_get_adaptor($adaptor_name)); #verify cache is used #ok($adaptor == $dbc->_get_adaptor($adaptor_name)); #verify cache is used
# #
# 10 dbhandle # 10 dbhandle
# #
ok(test_getter_setter($dbc, 'db_handle', $db->db_handle)); ok(test_getter_setter($dbc, 'db_handle', $dbc->db_handle));
{ {
...@@ -94,27 +95,29 @@ ok(test_getter_setter($dbc, 'db_handle', $db->db_handle)); ...@@ -94,27 +95,29 @@ ok(test_getter_setter($dbc, 'db_handle', $db->db_handle));
ok($sth->rows); ok($sth->rows);
$sth->finish; $sth->finish;
} }
# AGAIN NOW DONE VIA DBADAPTOR
# #
# 12 add_db_adaptor # 12 add_db_adaptor
# #
$dbc->add_db_adaptor('core', $db); #$dbc->add_db_adaptor('core', $db);
my $db1 = $dbc->get_all_db_adaptors->{'core'};
my $db2 = $db->_obj;
debug("\n\ndb1=[$db1] db2=[$db2]\n\n");
ok($db1 == $db2);
# #
# 13 get_db_adaptor #my $db1 = $dbc->get_all_db_adaptors->{'core'};
# #my $db2 = $db->_obj;
ok($dbc->get_db_adaptor('core')->isa('Bio::EnsEMBL::DBSQL::DBConnection')); #debug("\n\ndb1=[$db1] db2=[$db2]\n\n");
#ok($db1 == $db2);
# #
# 14-15 remove_db_adaptor ##
## 13 get_db_adaptor
##
#ok($dbc->get_db_adaptor('core')->isa('Bio::EnsEMBL::DBSQL::DBConnection'));
# #
$dbc->remove_db_adaptor('core'); ##
ok(!defined $dbc->get_db_adaptor('core')); ## 14-15 remove_db_adaptor
ok(!defined $dbc->get_all_db_adaptors->{'core'}); ##
#$dbc->remove_db_adaptor('core');
#ok(!defined $dbc->get_db_adaptor('core'));
#ok(!defined $dbc->get_all_db_adaptors->{'core'});
# #
......
...@@ -37,7 +37,7 @@ ok( $db ); ...@@ -37,7 +37,7 @@ ok( $db );
my $dbEntryAdaptor = $db->get_DBEntryAdaptor(); my $dbEntryAdaptor = $db->get_DBEntryAdaptor();
my $sth = $db->prepare( 'select count(*) from object_xref where ensembl_object_type = "Translation"' ); my $sth = $db->db->prepare( 'select count(*) from object_xref where ensembl_object_type = "Translation"' );
$sth->execute(); $sth->execute();
my ( $xref_count ) = $sth->fetchrow_array(); my ( $xref_count ) = $sth->fetchrow_array();
......
...@@ -30,7 +30,7 @@ ok( $db ); ...@@ -30,7 +30,7 @@ ok( $db );
my $gene; my $gene;
my $ga = $db->get_GeneAdaptor(); my $ga = $db->get_GeneAdaptor();
print STDERR $ga."\n";
debug ("Gene->list_dbIDs"); debug ("Gene->list_dbIDs");
my $ids = $ga->list_dbIDs(); my $ids = $ga->list_dbIDs();
ok (@{$ids}); ok (@{$ids});
...@@ -41,6 +41,8 @@ ok (@{$stable_ids}); ...@@ -41,6 +41,8 @@ ok (@{$stable_ids});
$gene = $ga->fetch_by_stable_id( "ENSG00000171456" ); $gene = $ga->fetch_by_stable_id( "ENSG00000171456" );
print STDERR $gene."\n";
debug( "Gene->fetch_by_stable_id()" ); debug( "Gene->fetch_by_stable_id()" );
ok( $gene ); ok( $gene );
...@@ -602,7 +604,7 @@ debug( "Storing gene" ); ...@@ -602,7 +604,7 @@ debug( "Storing gene" );
$gene_ad->store($gene); $gene_ad->store($gene);
my $dbe_id = $db->db_handle->selectall_arrayref("SELECT display_xref_id FROM gene")->[0]->[0]; my $dbe_id = $db->db->db_handle->selectall_arrayref("SELECT display_xref_id FROM gene")->[0]->[0];
ok($dbe_id && $dbe_id == $dbe->dbID()); ok($dbe_id && $dbe_id == $dbe->dbID());
......
...@@ -109,7 +109,7 @@ ok($marker_feature->dbID && ...@@ -109,7 +109,7 @@ ok($marker_feature->dbID &&
$marker_feature->adaptor == $mfa); $marker_feature->adaptor == $mfa);
my $sth = $db->prepare('SELECT count(*) from marker_feature'); my $sth = $db->db->prepare('SELECT count(*) from marker_feature');
$sth->execute; $sth->execute;
my ($count) = $sth->fetchrow_array; my ($count) = $sth->fetchrow_array;
$sth->finish(); $sth->finish();
......
...@@ -8,7 +8,6 @@ BEGIN { $| = 1; ...@@ -8,7 +8,6 @@ BEGIN { $| = 1;
use Bio::EnsEMBL::Test::MultiTestDB; use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::MiscSet; use Bio::EnsEMBL::MiscSet;
use Bio::EnsEMBL::Test::TestUtils; use Bio::EnsEMBL::Test::TestUtils;
our $verbose = 0; #set to 1 to turn on debug printouts our $verbose = 0; #set to 1 to turn on debug printouts
...@@ -74,7 +73,7 @@ $msa->store($misc_set); ...@@ -74,7 +73,7 @@ $msa->store($misc_set);
ok($misc_set->dbID()); ok($misc_set->dbID());
ok($misc_set->adaptor() == $msa); ok($misc_set->adaptor() == $msa);
my $count = $db->db_handle->selectall_arrayref my $count = $db->db->db_handle->selectall_arrayref
("SELECT COUNT(*) FROM misc_set WHERE code = 'code'")->[0]->[0]; ("SELECT COUNT(*) FROM misc_set WHERE code = 'code'")->[0]->[0];
ok($count == 1); ok($count == 1);
...@@ -100,7 +99,7 @@ $msa->store($misc_set); ...@@ -100,7 +99,7 @@ $msa->store($misc_set);
ok($misc_set->dbID && $misc_set->adaptor); ok($misc_set->dbID && $misc_set->adaptor);
$count = $db->db_handle->selectall_arrayref $count = $db->db->db_handle->selectall_arrayref
("SELECT COUNT(*) FROM misc_set WHERE code = 'code'")->[0]->[0]; ("SELECT COUNT(*) FROM misc_set WHERE code = 'code'")->[0]->[0];
ok($count == 1); ok($count == 1);
......
...@@ -28,7 +28,7 @@ my $db = $multi->get_DBAdaptor('core'); ...@@ -28,7 +28,7 @@ my $db = $multi->get_DBAdaptor('core');
# #
# SliceAdaptor::new # SliceAdaptor::new
# #
my $slice_adaptor = Bio::EnsEMBL::DBSQL::SliceAdaptor->new($db->_obj); my $slice_adaptor = Bio::EnsEMBL::DBSQL::SliceAdaptor->new($db);
ok($slice_adaptor->isa('Bio::EnsEMBL::DBSQL::SliceAdaptor')); ok($slice_adaptor->isa('Bio::EnsEMBL::DBSQL::SliceAdaptor'));
ok($slice_adaptor->db); ok($slice_adaptor->db);
...@@ -406,7 +406,7 @@ ok($slice->seq_region_name =~ /$clone_name\.\d+/); ...@@ -406,7 +406,7 @@ ok($slice->seq_region_name =~ /$clone_name\.\d+/);
# highest (lowest-numbered) ranked comes out first # highest (lowest-numbered) ranked comes out first
$multi->hide('core', 'seq_region'); $multi->hide('core', 'seq_region');
my $sth = $db->prepare(qq{INSERT INTO seq_region (coord_system_id, name, my $sth = $db->db->prepare(qq{INSERT INTO seq_region (coord_system_id, name,
length) length)
SELECT cs.coord_system_id, 'TESTREGION', 1000000 SELECT cs.coord_system_id, 'TESTREGION', 1000000
FROM coord_system cs FROM coord_system cs
......
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