Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
use lib 't';
use strict;
use warnings;
BEGIN { $| = 1;
use Test;
plan tests => 9;
}
use MultiTestDB;
use TestUtils qw ( debug test_getter_setter );
use Bio::EnsEMBL::DBEntry;
# switch on the debug prints
our $verbose = 1;
debug( "Startup test" );
#
# 1 Test started
#
ok(1);
my $multi = 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->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_geneIds();
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 );
#
# 4,5 correct number of GoXrefs and IdentityXrefs
#
ok( $goxref_count == 48 );
ok( $ident_count == 32 );
# try storing and retrieval
my $xref = Bio::EnsEMBL::DBEntry->new
(
-primary_id => "1",
-dbname => "SWISSPROT",
-release => "1",
-display_id => "Ens related thing"
);
my %goxref = %$xref;
my %identxref = %$xref;
my $goref = Bio::EnsEMBL::GoXref->new
(
-primary_id => "1",
-dbname => "GO",
-release => "1",
-display_id => "Ens related GO"
);
$goref->linkage_type( "experimental" );
my $ident_xref = Bio::EnsEMBL::IdentityXref->new
(
-primary_id => "1",
-dbname => "SPTREMBL",
-release => "1",
-display_id => "Ens related Ident"
);
$ident_xref->query_identity( 100 );
$ident_xref->target_identity( 95 );
$multi->hide( "core", "object_xref", "xref", "identity_xref", "go_xref" );
my $gene = $ga->fetch_by_dbID( $all_gene_ids->[0] );
my $tr = $gene->get_all_Transcripts()->[0];
my $tl = $tr->translation();
$dbEntryAdaptor->store( $xref, $gene, "Gene" );
$dbEntryAdaptor->store( $xref, $tr, "Transcript" );
$dbEntryAdaptor->store( $goref, $tl, "Translation" );
$dbEntryAdaptor->store( $ident_xref, $tl, "Translation" );
$dbEntryAdaptor->store( $ident_xref, $tr, "Transcript" );
my ( $oxr_count, $go_count );
$sth = $db->prepare( "select count(*) from object_xref" );
$sth->execute();
( $oxr_count ) = $sth->fetchrow_array();
$sth->finish();
#
# 6 right number of object xrefs in db
#
debug( "object_xref_count = $oxr_count" );
ok( $oxr_count == 5 );
$sth = $db->prepare( "select count(*) from xref" );
$sth->execute();
( $xref_count ) = $sth->fetchrow_array();
$sth->finish();
#
# 7 number of xrefs right
#
debug( "Number of xrefs = $xref_count" );
ok( $xref_count == 3 );
$sth = $db->prepare( "select count(*) from go_xref" );
$sth->execute();
( $go_count ) = $sth->fetchrow_array();
$sth->finish();
#
# 8 number of go entries right
#
debug( "Number of go_xrefs = $go_count" );
ok( $go_count == 1 );
$sth = $db->prepare( "select count(*) from identity_xref" );
$sth->execute();
( $ident_count ) = $sth->fetchrow_array();
$sth->finish();
#
# 9 identity xrefs right
#
# the identity (query/target)values are not normalized ...
debug( "Number of identity_xrefs = $ident_count" );
ok( $ident_count == 2 );
#
# Need more tests here ...
#
$multi->restore();