-
Ian Longden authoredf08cba0f
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
dbEntries.t 8.18 KiB
use strict;
use warnings;
BEGIN { $| = 1;
use Test;
plan tests => 42;
}
use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::Test::TestUtils;
use Bio::EnsEMBL::DBEntry;
# switch on the debug prints
our $verbose = 0;
debug( "Startup test" );
#
# 1 Test started
#
ok(1);
my $multi = Bio::EnsEMBL::Test::MultiTestDB->new();
my $db = $multi->get_DBAdaptor( "core" );
debug( "Test database instatiated" );
#
# 2 Database instatiated
#
ok( $db );
# some retrievals
my $dbEntryAdaptor = $db->get_DBEntryAdaptor();
my $sth = $db->dbc->prepare( 'select count(*) from object_xref where ensembl_object_type = "Translation"' );
$sth->execute();
my ( $xref_count ) = $sth->fetchrow_array();
my $db_entry_count = 0;
my $goxref_count = 0;
my $ident_count = 0;
$sth->finish();
my $ga = $db->get_GeneAdaptor();
my $all_gene_ids = $ga->list_dbIDs();
for my $gene_id ( @$all_gene_ids ) {
my $gene = $ga->fetch_by_dbID( $gene_id );
for my $tr ( @{$gene->get_all_Transcripts()} ) {
my $tl = $tr->translation();
my $dbentries = $dbEntryAdaptor->fetch_all_by_Translation( $tl );
$db_entry_count += scalar( @{$dbentries});
$goxref_count += grep { $_->isa( "Bio::EnsEMBL::GoXref" )} @$dbentries;
$ident_count += grep {$_->isa( "Bio::EnsEMBL::IdentityXref" )} @$dbentries;
}
}
debug( "Found $xref_count xrefs and $db_entry_count dblinks." );
debug( " $goxref_count GoXrefs, $ident_count identityXrefs." );
#
# 3 as many dblinks as entries in object_xref
#
ok( $db_entry_count == $xref_count );