0
|
1 =head1 LICENSE
|
|
2
|
|
3 Copyright (c) 1999-2012 The European Bioinformatics Institute and
|
|
4 Genome Research Limited. All rights reserved.
|
|
5
|
|
6 This software is distributed under a modified Apache license.
|
|
7 For license details, please see
|
|
8
|
|
9 http://www.ensembl.org/info/about/code_licence.html
|
|
10
|
|
11 =head1 CONTACT
|
|
12
|
|
13 Please email comments or questions to the public Ensembl
|
|
14 developers list at <dev@ensembl.org>.
|
|
15
|
|
16 Questions may also be sent to the Ensembl help desk at
|
|
17 <helpdesk@ensembl.org>.
|
|
18
|
|
19 =cut
|
|
20
|
|
21 =head1 NAME
|
|
22
|
|
23 Bio::EnsEMBL::Registry
|
|
24
|
|
25 =head1 SYNOPSIS
|
|
26
|
|
27 use Bio::EnsEMBL::Registry;
|
|
28
|
|
29 my $registry = 'Bio::EnsEMBL::Registry';
|
|
30
|
|
31 $registry->load_all("configuration_file");
|
|
32
|
|
33 $gene_adaptor = $registry->get_adaptor( 'Human', 'Core', 'Gene' );
|
|
34
|
|
35 =head1 DESCRIPTION
|
|
36
|
|
37 All Adaptors are stored/registered using this module. This module should
|
|
38 then be used to get the adaptors needed.
|
|
39
|
|
40 The registry can be loaded from a configuration file using the load_all
|
|
41 method.
|
|
42
|
|
43 If a filename is passed to load_all then this is used. Else if the
|
|
44 environment variable ENSEMBL_REGISTRY is set to the name on an existing
|
|
45 configuration file, then this is used. Else if the file .ensembl_init
|
|
46 in your home directory exist, it is used.
|
|
47
|
|
48 For the Web server ENSEMBL_REGISTRY should be set in SiteDefs.pm. This
|
|
49 will then be passed on to load_all.
|
|
50
|
|
51
|
|
52 The registry can also be loaded via the method load_registry_from_db
|
|
53 which given a database host will load the latest versions of the Ensembl
|
|
54 databases from it.
|
|
55
|
|
56 The four types of registries are for db adaptors, dba adaptors, dna
|
|
57 adaptors and the standard type.
|
|
58
|
|
59 =head2 db
|
|
60
|
|
61 These are registries for backwards compatibility and enable the
|
|
62 subroutines to add other adaptors to connections.
|
|
63
|
|
64 e.g. get_all_db_adaptors, get_db_adaptor, add_db_adaptor,
|
|
65 remove_db_adaptor are the old DBAdaptor subroutines which are now
|
|
66 redirected to the Registry.
|
|
67
|
|
68 So if before we had
|
|
69
|
|
70 my $sfa = $self->adaptor()->db()->get_db_adaptor('blast');
|
|
71
|
|
72 We now want to change this to
|
|
73
|
|
74 my $sfa =
|
|
75 Bio::EnsEMBL::Registry->get_adaptor( "human", "core", "blast" );
|
|
76
|
|
77
|
|
78 =head2 DBA
|
|
79
|
|
80 These are the stores for the DBAdaptors
|
|
81
|
|
82 The Registry will create all the DBConnections needed now if you set up
|
|
83 the configuration correctly. So instead of the old commands like
|
|
84
|
|
85 my $db = Bio::EnsEMBL::DBSQL::DBAdaptor->new(...);
|
|
86 my $exon_adaptor = $db->get_ExonAdaptor;
|
|
87
|
|
88 we should now have just
|
|
89
|
|
90 my $exon_adaptor =
|
|
91 Bio::EnsEMBL::Registry->get_adaptor( "human", "core", "exon" );
|
|
92
|
|
93
|
|
94 =head2 DNA
|
|
95
|
|
96 This is an internal Registry and allows the configuration of a dnadb.
|
|
97 An example here is to set the est database to get its dna data from the
|
|
98 core database.
|
|
99
|
|
100 ## set the est db to use the core for getting dna data.
|
|
101 # Bio::EnsEMBL::Utils::ConfigRegistry->dnadb_add( "Homo Sapiens",
|
|
102 # "core", "Homo Sapiens", "est" );
|
|
103
|
|
104
|
|
105 =head2 adaptors
|
|
106
|
|
107 This is the registry for all the general types of adaptors like
|
|
108 GeneAdaptor, ExonAdaptor, Slice Adaptor etc.
|
|
109
|
|
110 These are accessed by the get_adaptor subroutine i.e.
|
|
111
|
|
112 my $exon_adaptor =
|
|
113 Bio::EnsEMBL::Registry->get_adaptor( "human", "core", "exon" );
|
|
114
|
|
115 =head1 METHODS
|
|
116
|
|
117 =cut
|
|
118
|
|
119
|
|
120
|
|
121 package Bio::EnsEMBL::Registry;
|
|
122 use strict;
|
|
123 use warnings;
|
|
124
|
|
125 use Bio::EnsEMBL::DBSQL::DBAdaptor;
|
|
126 use Bio::EnsEMBL::DBSQL::BaseFeatureAdaptor;
|
|
127 use Bio::EnsEMBL::Utils::Exception qw( deprecate throw warning );
|
|
128 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
|
|
129 use Bio::EnsEMBL::Utils::ConfigRegistry;
|
|
130 use Bio::EnsEMBL::ApiVersion;
|
|
131 use Bio::EnsEMBL::Utils::URI qw/parse_uri/;
|
|
132
|
|
133 use DBI qw(:sql_types);
|
|
134
|
|
135 use vars qw(%registry_register);
|
|
136
|
|
137 # This is a map from group names to Ensembl DB adaptors. Used by
|
|
138 # load_all() and reset_DBAdaptor().
|
|
139 my %group2adaptor = (
|
|
140 'blast' => 'Bio::EnsEMBL::External::BlastAdaptor',
|
|
141 'compara' => 'Bio::EnsEMBL::Compara::DBSQL::DBAdaptor',
|
|
142 'core' => 'Bio::EnsEMBL::DBSQL::DBAdaptor',
|
|
143 'estgene' => 'Bio::EnsEMBL::DBSQL::DBAdaptor',
|
|
144 'funcgen' => 'Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor',
|
|
145 'regulation' => 'Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor',
|
|
146 'haplotype' => 'Bio::EnsEMBL::ExternalData::Haplotype::DBAdaptor',
|
|
147 'hive' => 'Bio::EnsEMBL::Hive::DBSQL::DBAdaptor',
|
|
148 'ontology' => 'Bio::EnsEMBL::DBSQL::OntologyDBAdaptor',
|
|
149 'otherfeatures' => 'Bio::EnsEMBL::DBSQL::DBAdaptor',
|
|
150 'pipeline' => 'Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor',
|
|
151 'snp' => 'Bio::EnsEMBL::ExternalData::SNPSQL::DBAdaptor',
|
|
152 'stable_ids' => 'Bio::EnsEMBL::DBSQL::DBAdaptor',
|
|
153 'variation' => 'Bio::EnsEMBL::Variation::DBSQL::DBAdaptor',
|
|
154 'vega' => 'Bio::EnsEMBL::DBSQL::DBAdaptor',
|
|
155 'vega_update' => 'Bio::EnsEMBL::DBSQL::DBAdaptor',
|
|
156 );
|
|
157
|
|
158
|
|
159 =head2 load_all
|
|
160
|
|
161 Will load the registry with the configuration file which is
|
|
162 obtained from the first in the following and in that order.
|
|
163
|
|
164 1) If an argument is passed to this method, this is used as the
|
|
165 name of the configuration file to read.
|
|
166
|
|
167 2) If the environment variable ENSEMBL_REGISTRY is set, this is
|
|
168 used as the name of the configuration file to read.
|
|
169
|
|
170 3) If the file .ensembl_init exist in the home directory, it is
|
|
171 used as the configuration file.
|
|
172
|
|
173 Arg [1] : (optional) string
|
|
174 Name of file to load the registry from.
|
|
175
|
|
176 Arg [2] : (optional) integer
|
|
177 If not 0, will print out all information.
|
|
178
|
|
179 Arg [3] : (optional) integer
|
|
180 If not 0, the database connection will not be
|
|
181 cleared, if 0 or if not set the database connections
|
|
182 will be cleared (this is the default).
|
|
183
|
|
184 Arg [4]: (optional) boolean
|
|
185 This option will turn off caching for slice features,
|
|
186 so, every time a set of features is retrieved,
|
|
187 they will come from the database instead of the
|
|
188 cache. This option is only recommended for advanced
|
|
189 users, specially if you need to store and retrieve
|
|
190 features. It might reduce performance when querying
|
|
191 the database if not used properly. If in doubt, do
|
|
192 not use it or ask in the developer mailing list.
|
|
193
|
|
194 Example : Bio::EnsEMBL::Registry->load_all();
|
|
195 Returntype : Int count of the DBAdaptor instances which can be found in the
|
|
196 registry
|
|
197 Exceptions : none
|
|
198 Status : Stable
|
|
199
|
|
200 =cut
|
|
201
|
|
202 sub load_all {
|
|
203 my ($class, $config_file, $verbose, $no_clear, $no_cache ) = @_;
|
|
204
|
|
205 if ( !defined($config_file) ) {
|
|
206 if ( defined( $ENV{ENSEMBL_REGISTRY} ) ) {
|
|
207 $config_file = $ENV{ENSEMBL_REGISTRY};
|
|
208 } elsif ( defined( $ENV{HOME} ) ) {
|
|
209 $config_file = $ENV{HOME} . "/.ensembl_init";
|
|
210 }
|
|
211 }
|
|
212
|
|
213 $verbose ||= 0;
|
|
214 $no_clear ||= 0;
|
|
215 $no_cache ||= 0;
|
|
216
|
|
217 my $original_count = $class->get_DBAdaptor_count();
|
|
218
|
|
219 if ( !defined($config_file) ) {
|
|
220 if ($verbose) {
|
|
221 print( STDERR
|
|
222 "No default registry configuration to load.\n" );
|
|
223 }
|
|
224 } elsif ( !-e $config_file ) {
|
|
225 if ($verbose) {
|
|
226 printf( STDERR "Configuration file '%s' does not exist. "
|
|
227 . "Registry configuration not loaded.\n",
|
|
228 $config_file );
|
|
229 }
|
|
230 } else {
|
|
231 if ( defined( $registry_register{'seen'} ) ) {
|
|
232 if ( !$no_clear ) {
|
|
233 if ($verbose) {
|
|
234 print( STDERR "Clearing previously loaded "
|
|
235 . "registry configuration\n" );
|
|
236 }
|
|
237 $class->clear();
|
|
238 }
|
|
239 }
|
|
240 $registry_register{'seen'} = 1;
|
|
241
|
|
242 if ($verbose) {
|
|
243 printf( STDERR
|
|
244 "Loading registry configuration from '%s'.\n",
|
|
245 $config_file );
|
|
246 }
|
|
247
|
|
248 my $cfg;
|
|
249
|
|
250 my $test_eval = eval { require Config::IniFiles };
|
|
251
|
|
252 if ($@ or (!$test_eval)) {
|
|
253 # The user does not have the 'Config::IniFiles' module.
|
|
254 if ($verbose) {
|
|
255 print( STDERR "No Config::IniFiles module found, "
|
|
256 . "assuming this is not an ini-file\n" );
|
|
257 }
|
|
258 # If the configuration file *is* an ini-file, we can expect a
|
|
259 # load of compilation errors from the next eval...
|
|
260 } else {
|
|
261 # The user has the 'Config::IniFiles' module installed. See
|
|
262 # if this is an ini-file or not...
|
|
263 $cfg = Config::IniFiles->new( -file => $config_file );
|
|
264 }
|
|
265
|
|
266 if ( defined $cfg ) {
|
|
267 my %default_adaptor_args = ();
|
|
268
|
|
269 if ( $cfg->SectionExists('default') ) {
|
|
270 # The 'default' section is special. It contain default
|
|
271 # values that should be implicit to all other section in
|
|
272 # this configuration file. Aliases are added if there
|
|
273 # is also a 'species' setting.
|
|
274
|
|
275 my $alias = $cfg->val( 'default', 'alias' );
|
|
276 $cfg->delval( 'default', 'alias' );
|
|
277
|
|
278 my $species = $cfg->val( 'default', 'species' );
|
|
279
|
|
280 if ( defined($alias) && defined($species) ) {
|
|
281 Bio::EnsEMBL::Utils::ConfigRegistry->add_alias(
|
|
282 -species => $species,
|
|
283 -alias => [ split( /\n/, $alias ) ]
|
|
284 );
|
|
285 }
|
|
286
|
|
287 %default_adaptor_args =
|
|
288 map { '-' . $_ => $cfg->val( 'default', $_ ) }
|
|
289 $cfg->Parameters('default');
|
|
290 }
|
|
291
|
|
292 foreach my $section ( $cfg->Sections() ) {
|
|
293 if ( $section eq 'default' )
|
|
294 { # We have already done the 'default' section.
|
|
295 next;
|
|
296 }
|
|
297
|
|
298 my $group = $cfg->val( $section, 'group' )
|
|
299 || $cfg->val( 'default', 'group' );
|
|
300
|
|
301 if ( !defined($group) ) {
|
|
302 printf( STDERR "Key 'group' is undefined "
|
|
303 . "for configuration section '%s', "
|
|
304 . "skipping this section.\n",
|
|
305 $section );
|
|
306 next;
|
|
307 }
|
|
308
|
|
309 my $adaptor = $group2adaptor{ lc($group) };
|
|
310 if ( !defined($adaptor) ) {
|
|
311 printf( STDERR "Unknown group '%s' "
|
|
312 . "for configuration section '%s', "
|
|
313 . "skipping this section.\n",
|
|
314 $group, $section );
|
|
315 next;
|
|
316 }
|
|
317
|
|
318 # Handle aliases. A section must have both an 'alias'
|
|
319 # setting and a 'species' setting for aliases to be
|
|
320 # added. The 'species' setting might be inherited from
|
|
321 # the 'default' section.
|
|
322
|
|
323 my $alias = $cfg->val( $section, 'alias' );
|
|
324 $cfg->delval( $section, 'alias' );
|
|
325
|
|
326 my $species = $cfg->val( $section, 'species' )
|
|
327 || $cfg->val( 'default', 'species' );
|
|
328
|
|
329 if ( defined($alias) && defined($species) ) {
|
|
330 Bio::EnsEMBL::Utils::ConfigRegistry->add_alias(
|
|
331 -species => $species,
|
|
332 -alias => [ split( /\n/, $alias ) ]
|
|
333 );
|
|
334 }
|
|
335
|
|
336 # Fill in the adaptor initialization arguments.
|
|
337 # We trust the user to provide sensible key-value pairs.
|
|
338 my %adaptor_args = %default_adaptor_args;
|
|
339 foreach my $parameter ( $cfg->Parameters($section) ) {
|
|
340 $adaptor_args{ '-' . $parameter } =
|
|
341 $cfg->val( $section, $parameter );
|
|
342
|
|
343 # when set, do not use the feature cache in the
|
|
344 # different adaptors
|
|
345 if ($no_cache) {
|
|
346 $adaptor_args{'-no_cache'} = 1;
|
|
347 }
|
|
348 }
|
|
349
|
|
350 if ($verbose) {
|
|
351 printf( "Configuring adaptor '%s' "
|
|
352 . "for configuration section '%s'...\n",
|
|
353 $adaptor, $section );
|
|
354 }
|
|
355
|
|
356 my $test_eval = eval "require $adaptor";
|
|
357 if ($@ or (!$test_eval)) { die($@) }
|
|
358
|
|
359 $adaptor->new(%adaptor_args);
|
|
360
|
|
361 } ## end foreach my $section ( $cfg->Sections...
|
|
362 } else {
|
|
363 # This is probably no ini-file but an old style piece
|
|
364 # of configuration written in Perl. We need to try to
|
|
365 # require() it.
|
|
366
|
|
367 my $test_eval = eval { require($config_file) };
|
|
368 if ($@ or (!$test_eval)) { die($@) }
|
|
369
|
|
370 # To make the web code avoid doing this again:
|
|
371 delete $INC{$config_file};
|
|
372 }
|
|
373 } ## end else [ if ( !defined($config_file...
|
|
374
|
|
375 return $class->get_DBAdaptor_count() - $original_count;
|
|
376 } ## end sub load_all
|
|
377
|
|
378 =head2 clear
|
|
379
|
|
380 Will clear the registry and disconnect from all databases.
|
|
381
|
|
382 Example : Bio::EnsEMBL::Registry->clear();
|
|
383 Returntype : none
|
|
384 Exceptions : none
|
|
385 Status : Stable
|
|
386
|
|
387 =cut
|
|
388
|
|
389 sub clear{
|
|
390 my ($self);
|
|
391
|
|
392 foreach my $dba (@{$registry_register{'_DBA'}}){
|
|
393 if($dba->dbc->connected){
|
|
394 $dba->dbc->db_handle->disconnect();
|
|
395 }
|
|
396 }
|
|
397 %registry_register = ();
|
|
398 return;
|
|
399 }
|
|
400
|
|
401 #
|
|
402 # db adaptors. (for backwards compatibility)
|
|
403 #
|
|
404
|
|
405 =head2 add_db
|
|
406
|
|
407 Arg [1] : db (DBAdaptor) to add adaptor to.
|
|
408 Arg [2] : name of the name to add the adaptor to in the registry.
|
|
409 Arg [3] : The adaptor to be added to the registry.
|
|
410 Example : Bio::EnsEMBL::Registry->add_db($db, "lite", $dba);
|
|
411 Returntype : none
|
|
412 Exceptions : none
|
|
413 Status : At Risk.
|
|
414 : This is here for backwards compatibility only and may
|
|
415 : be removed eventually. Solution is to make sure the
|
|
416 : db and the adaptor have the same species and the call
|
|
417 : is then no longer needed.
|
|
418
|
|
419 =cut
|
|
420
|
|
421 sub add_db {
|
|
422 my ( $class, $db, $name, $adap ) = @_;
|
|
423
|
|
424 if ( lc( $db->species() ) ne lc( $adap->species ) ) {
|
|
425 $registry_register{_SPECIES}{ lc( $db->species() ) }
|
|
426 { lc( $db->group() ) }{'_special'}{ lc($name) } = $adap;
|
|
427 }
|
|
428 return;
|
|
429 }
|
|
430
|
|
431 =head2 remove_db
|
|
432
|
|
433 Arg [1] : db (DBAdaptor) to remove adaptor from.
|
|
434 Arg [2] : name to remove the adaptor from in the registry.
|
|
435 Example : my $db = Bio::EnsEMBL::Registry->remove_db($db, "lite");
|
|
436 Returntype : adaptor
|
|
437 Exceptions : none
|
|
438 Status : At Risk.
|
|
439 : This is here for backwards compatibility only and may
|
|
440 : be removed eventually. Solution is to make sure the
|
|
441 : db and the adaptor have the same species and the call
|
|
442 : is then no longer needed.
|
|
443
|
|
444 =cut
|
|
445
|
|
446 sub remove_db {
|
|
447 my ( $class, $db, $name ) = @_;
|
|
448
|
|
449 my $ret =
|
|
450 $registry_register{_SPECIES}{ lc( $db->species() ) }
|
|
451 { lc( $db->group() ) }{'_special'}{ lc($name) };
|
|
452
|
|
453 $registry_register{_SPECIES}{ lc( $db->species() ) }
|
|
454 { lc( $db->group() ) }{'_special'}{ lc($name) } = undef;
|
|
455
|
|
456 return $ret;
|
|
457 }
|
|
458
|
|
459 =head2 get_db
|
|
460
|
|
461 Arg [1] : db (DBAdaptor) to get adaptor from.
|
|
462 Arg [2] : name to get the adaptor for in the registry.
|
|
463 Example : my $db = Bio::EnsEMBL::Registry->get_db("Human", "core", "lite");
|
|
464 Returntype : adaptor
|
|
465 Exceptions : See get_DBAdaptor()
|
|
466 Status : At Risk.
|
|
467 : This is here for backwards compatibility only and may
|
|
468 : be removed eventually. Solution is to make sure the
|
|
469 : db and the adaptor have the same species then call
|
|
470 : get_DBAdaptor instead.
|
|
471
|
|
472 =cut
|
|
473
|
|
474 sub get_db {
|
|
475 my ( $class, $db, $name ) = @_;
|
|
476
|
|
477 my $ret = Bio::EnsEMBL::Registry->get_DBAdaptor( lc( $db->species ),
|
|
478 lc($name) );
|
|
479
|
|
480 if ( defined($ret) ) { return $ret }
|
|
481
|
|
482 return $registry_register{_SPECIES}{ lc( $db->species() ) }
|
|
483 { lc( $db->group() ) }{'_special'}{ lc($name) };
|
|
484 }
|
|
485
|
|
486 =head2 get_all_db_adaptors
|
|
487
|
|
488 Arg [1] : db (DBAdaptor) to get all the adaptors from.
|
|
489 Example : my $db = Bio::EnsEMBL::Registry->get_all_db_adaptors($db);
|
|
490 Returntype : adaptor
|
|
491 Exceptions : none
|
|
492 Status : At Risk.
|
|
493 : This is here for backwards compatibility only and
|
|
494 : may be removed eventually. Solution is to make
|
|
495 : sure the dbs all have the same species then call
|
|
496 : get_all_DBAdaptors(-species => "human");
|
|
497
|
|
498
|
|
499 =cut
|
|
500
|
|
501 sub get_all_db_adaptors {
|
|
502 my ( $class, $db ) = @_;
|
|
503 my %ret = ();
|
|
504
|
|
505 # we now also want to add all the DBAdaptors for the same species.
|
|
506 # as add_db_adaptor does not add if it is from the same species.
|
|
507
|
|
508 foreach my $dba ( @{ $registry_register{'_DBA'} } ) {
|
|
509 if ( lc( $dba->species() ) eq lc( $db->species() ) ) {
|
|
510 $ret{ $dba->group() } = $dba;
|
|
511 }
|
|
512 }
|
|
513
|
|
514 foreach my $key (
|
|
515 keys %{
|
|
516 $registry_register{_SPECIES}
|
|
517 { $class->get_alias( $db->species() ) }{ lc( $db->group() ) }
|
|
518 {'_special'} } )
|
|
519 {
|
|
520 $ret{$key} =
|
|
521 $registry_register{_SPECIES}
|
|
522 { $class->get_alias( $db->species() ) }{ lc( $db->group() ) }
|
|
523 {'_special'}{$key};
|
|
524 }
|
|
525
|
|
526 return \%ret;
|
|
527 } ## end sub get_all_db_adaptors
|
|
528
|
|
529
|
|
530 #
|
|
531 # DBAdaptors
|
|
532 #
|
|
533
|
|
534 =head2 add_DBAdaptor
|
|
535
|
|
536 Arg [1] : name of the species to add the adaptor to in the registry.
|
|
537 Arg [2] : name of the group to add the adaptor to in the registry.
|
|
538 Arg [3] : DBAdaptor to be added to the registry.
|
|
539 Example : Bio::EnsEMBL::Registry->add_DBAdaptor("Human", "core", $dba);
|
|
540 Returntype : none
|
|
541 Exceptions : none
|
|
542 caller : internal
|
|
543 Status : Stable
|
|
544
|
|
545 =cut
|
|
546
|
|
547 sub add_DBAdaptor {
|
|
548 my ( $class, $species, $group, $adap ) = @_;
|
|
549
|
|
550 if ( !( $class->alias_exists($species) ) ) {
|
|
551 $class->add_alias( $species, $species );
|
|
552 }
|
|
553
|
|
554 $species = $class->get_alias($species);
|
|
555
|
|
556 $registry_register{_SPECIES}{$species}{ lc($group) }{'_DB'} = $adap;
|
|
557
|
|
558 if ( !defined( $registry_register{'_DBA'} ) ) {
|
|
559 $registry_register{'_DBA'} = [$adap];
|
|
560 } else {
|
|
561 push( @{ $registry_register{'_DBA'} }, $adap );
|
|
562 }
|
|
563 return;
|
|
564 }
|
|
565
|
|
566
|
|
567
|
|
568 =head2 get_DBAdaptor
|
|
569
|
|
570 Arg [1] : name of the species to get the adaptor for in the registry.
|
|
571 Arg [2] : name of the group to get the adaptor for in the registry.
|
|
572 Arg [3] : if set will not give warnings when looking for alias.
|
|
573 Example : $dba = Bio::EnsEMBL::Registry->get_DBAdaptor("Human", "core");
|
|
574 Returntype : DBAdaptor
|
|
575 Exceptions : If $species is not defined and if no valid internal name
|
|
576 could be found for $species. If thrown check your API and DB
|
|
577 version
|
|
578 Status : Stable
|
|
579
|
|
580 =cut
|
|
581
|
|
582 sub get_DBAdaptor {
|
|
583 my ( $class, $species, $group, $no_alias_check ) = @_;
|
|
584
|
|
585 if ( !defined($species) ) {
|
|
586 throw('Species not defined.');
|
|
587 }
|
|
588
|
|
589 my $ispecies = $class->get_alias( $species, $no_alias_check );
|
|
590
|
|
591 if ( !defined($ispecies) ) {
|
|
592 if(! $no_alias_check) {
|
|
593 throw("Can not find internal name for species '$species'");
|
|
594 }
|
|
595 }
|
|
596 else { $species = $ispecies }
|
|
597
|
|
598 return $registry_register{_SPECIES}{$species}{ lc($group) }{'_DB'};
|
|
599 }
|
|
600
|
|
601 =head2 get_all_DBAdaptors
|
|
602
|
|
603 Arg [SPECIES]: (optional) string
|
|
604 species name to get adaptors for
|
|
605 Arg [GROUP] : (optional) string
|
|
606 group name to get adaptors for
|
|
607 Example :
|
|
608 @dba =
|
|
609 @{ Bio::EnsEMBL::Registry->get_all_DBAdaptors() };
|
|
610
|
|
611 @human_dbas =
|
|
612 @{ Bio::EnsEMBL::Registry->get_all_DBAdaptors(
|
|
613 -species => 'human'
|
|
614 ) };
|
|
615
|
|
616 Returntype : list of DBAdaptors
|
|
617 Exceptions : none
|
|
618 Status : Stable
|
|
619
|
|
620 =cut
|
|
621
|
|
622 sub get_all_DBAdaptors {
|
|
623 my ( $class, @args ) = @_;
|
|
624
|
|
625 my ( $species, $group ) = rearrange( [qw(SPECIES GROUP)], @args );
|
|
626
|
|
627 if ( defined($species) ) { $species = $class->get_alias($species) }
|
|
628
|
|
629 my @ret;
|
|
630 foreach my $dba ( @{ $registry_register{'_DBA'} } ) {
|
|
631 if ( ( !defined($species) || lc($species) eq lc( $dba->species() ) )
|
|
632 && ( !defined($group) || lc($group) eq lc( $dba->group() ) ) )
|
|
633 {
|
|
634 push( @ret, $dba );
|
|
635 }
|
|
636 }
|
|
637
|
|
638 return \@ret;
|
|
639 }
|
|
640
|
|
641 =head2 get_all_DBAdaptors_by_connection
|
|
642
|
|
643 Arg [1] : DBConnection used to find DBAdaptors
|
|
644 Returntype : reference to list of DBAdaptors
|
|
645 Exceptions : none
|
|
646 Example : @dba = @{ Bio::EnsEMBL::Registry
|
|
647 ->get_all_DBAdaptors_by_connection($dbc) };
|
|
648 Status : Stable
|
|
649
|
|
650 =cut
|
|
651
|
|
652 sub get_all_DBAdaptors_by_connection {
|
|
653 my ( $self, $dbc_orig ) = @_;
|
|
654
|
|
655 my @return;
|
|
656
|
|
657 foreach my $dba ( @{ $registry_register{'_DBA'} } ) {
|
|
658 my $dbc = $dba->dbc();
|
|
659
|
|
660 if ( defined($dbc)
|
|
661 && $dbc->can('equals')
|
|
662 && $dbc->equals($dbc_orig) )
|
|
663 {
|
|
664 push( @return, $dba );
|
|
665 }
|
|
666 }
|
|
667
|
|
668 return \@return;
|
|
669 }
|
|
670
|
|
671 =head2 get_all_DBAdaptors_by_dbname
|
|
672
|
|
673 Arg [1] : string, name of database
|
|
674 Returntype : reference to list of DBAdaptors
|
|
675 Exceptions : none
|
|
676 Example : @dba = @{ Bio::EnsEMBL::Registry
|
|
677 ->get_all_DBAdaptors_by_dbname($dbname) };
|
|
678 Status : Stable
|
|
679
|
|
680 =cut
|
|
681
|
|
682 sub get_all_DBAdaptors_by_dbname {
|
|
683 my ( $self, $dbname ) = @_;
|
|
684
|
|
685 my @return;
|
|
686
|
|
687 foreach my $dba ( @{ $registry_register{'_DBA'} } ) {
|
|
688 my $dbc = $dba->dbc();
|
|
689
|
|
690 if ( defined($dbc) && $dbc->dbname() eq $dbname ) {
|
|
691 push( @return, $dba );
|
|
692 }
|
|
693 }
|
|
694
|
|
695 return \@return;
|
|
696 }
|
|
697
|
|
698 =head2 remove_DBAdaptor
|
|
699
|
|
700 Arg [1] : name of the species to get the adaptor for in the registry.
|
|
701 Arg [2] : name of the group to get the adaptor for in the registry.
|
|
702 Example : $dba = Bio::EnsEMBL::Registry->remove_DBAdaptor("Human", "core");
|
|
703 Returntype : none
|
|
704 Exceptions : none
|
|
705 Status : At risk
|
|
706
|
|
707 =cut
|
|
708
|
|
709 sub remove_DBAdaptor {
|
|
710 my ( $class, $species, $group ) = @_;
|
|
711
|
|
712 $species = $class->get_alias($species);
|
|
713
|
|
714 delete $registry_register{_SPECIES}{$species}{$group};
|
|
715 # This will remove the DBAdaptor and all the other adaptors
|
|
716
|
|
717 # Now remove if from the _DBA array
|
|
718 my $index;
|
|
719
|
|
720 foreach my $i ( 0 .. $#{ $registry_register{'_DBA'} } ) {
|
|
721 my $dba = $registry_register{'_DBA'}->[$i];
|
|
722
|
|
723 if ( ( $dba->species eq $species )
|
|
724 && $dba->group eq $group )
|
|
725 {
|
|
726 $index = $i;
|
|
727 last;
|
|
728 }
|
|
729 }
|
|
730
|
|
731 # Now remove from _DBA cache
|
|
732 if ( defined($index) ) {
|
|
733 splice( @{ $registry_register{'_DBA'} }, $index, 1 );
|
|
734 }
|
|
735
|
|
736 return;
|
|
737 } ## end sub remove_DBAdaptor
|
|
738
|
|
739
|
|
740
|
|
741 =head2 reset_DBAdaptor
|
|
742
|
|
743 Arg [1]: string - species e.g. homo_sapiens
|
|
744 Arg [2]: string - DB group e.g. core
|
|
745 Arg [3]: string - new dbname
|
|
746 Args [4-7]: string - optional DB parameters, defaults to current db params if omitted
|
|
747 Arg [8]: hashref - Hash ref of additional parameters e.g. eFG dnadb params for auto selecting dnadb
|
|
748 Usage : $reg->reset_registry_db( 'homo_sapiens', 'core',
|
|
749 'homo_sapiens_core_37_35j' );
|
|
750 Description: Resets a DB within the registry.
|
|
751 Exceptions: Throws if mandatory params not supplied
|
|
752 Throws if species name is not already seen by the registry
|
|
753 Throws if no current DB for species/group available
|
|
754 Status : At risk
|
|
755
|
|
756 =cut
|
|
757
|
|
758 sub reset_DBAdaptor {
|
|
759 my (
|
|
760 $self, $species, $group, $dbname, $host,
|
|
761 $port, $user, $pass, $params
|
|
762 ) = @_;
|
|
763
|
|
764 # Check mandatory params
|
|
765 if ( !( defined $species && defined $group && defined $dbname ) ) {
|
|
766 throw(
|
|
767 'Must provide at least a species, group, and dbname parameter '
|
|
768 . 'to redefine a DB in the registry' );
|
|
769 }
|
|
770
|
|
771 # Validate species here
|
|
772 my $alias = $self->get_alias($species);
|
|
773 throw("Could not find registry alias for species:\t$species")
|
|
774 if ( !defined $alias );
|
|
775
|
|
776 # Get all current defaults if not defined
|
|
777
|
|
778 my $db = $self->get_DBAdaptor( $alias, $group );
|
|
779 my $class;
|
|
780
|
|
781 if ($db) {
|
|
782 $class = ref($db);
|
|
783 $host ||= $db->dbc->host;
|
|
784 $port ||= $db->dbc->port;
|
|
785 $user ||= $db->dbc->username;
|
|
786 $pass ||= $db->dbc->password;
|
|
787 } else {
|
|
788 #Now we need to test mandatory params
|
|
789 $class = $group2adaptor{ lc($group) };
|
|
790
|
|
791 if ( !( $host && $user ) ) {
|
|
792 throw("No comparable $alias $group DB present in Registry. "
|
|
793 . "You must pass at least a dbhost and dbuser" );
|
|
794 }
|
|
795 }
|
|
796
|
|
797 $self->remove_DBAdaptor( $alias, $group );
|
|
798
|
|
799 # ConfigRegistry should automatically add this to the Registry
|
|
800 $db = $class->new(
|
|
801 -user => $user,
|
|
802 -host => $host,
|
|
803 -port => $port,
|
|
804 -pass => $pass,
|
|
805 -dbname => $dbname,
|
|
806 -species => $alias,
|
|
807 -group => $group,
|
|
808 %{$params} );
|
|
809
|
|
810 return $db;
|
|
811 } ## end sub reset_DBAdaptor
|
|
812
|
|
813
|
|
814 #
|
|
815 # DNA Adaptors
|
|
816 #
|
|
817
|
|
818 =head2 add_DNAAdaptor
|
|
819
|
|
820 Arg [1] : name of the species to add the adaptor to in the registry.
|
|
821 Arg [2] : name of the group to add the adaptor to in the registry.
|
|
822 Arg [3] : name of the species to get the dna from
|
|
823 Arg [4] : name of the group to get the dna from
|
|
824 Example : Bio::EnsEMBL::Registry->add_DNAAdaptor("Human", "estgene", "Human", "core");
|
|
825 Returntype : none
|
|
826 Exceptions : none
|
|
827 Status : Stable
|
|
828
|
|
829 =cut
|
|
830
|
|
831 sub add_DNAAdaptor {
|
|
832 my ( $class, $species, $group, $dnadb_species, $dnadb_group ) = @_;
|
|
833
|
|
834 $species = $class->get_alias($species);
|
|
835 $dnadb_species = $class->get_alias($dnadb_species);
|
|
836 if ( $dnadb_group->isa('Bio::EnsEMBL::DBSQL::DBAdaptor') ) {
|
|
837 deprecated("");
|
|
838 } else {
|
|
839 $registry_register{_SPECIES}{$species}{ lc($group) }{'_DNA'} =
|
|
840 $dnadb_group;
|
|
841 $registry_register{_SPECIES}{$species}{ lc($group) }{'_DNA2'} =
|
|
842 $dnadb_species;
|
|
843 }
|
|
844 return;
|
|
845 }
|
|
846
|
|
847 =head2 get_DNAAdaptor
|
|
848
|
|
849 Arg [1] : name of the species to get the adaptor for in the registry.
|
|
850 Arg [2] : name of the group to get the adaptor for in the registry.
|
|
851 Example : $dnaAdap = Bio::EnsEMBL::Registry->get_DNAAdaptor("Human", "core");
|
|
852 Returntype : adaptor
|
|
853 Exceptions : none
|
|
854 Status : Stable
|
|
855
|
|
856 =cut
|
|
857
|
|
858 sub get_DNAAdaptor {
|
|
859 my ( $class, $species, $group ) = @_;
|
|
860
|
|
861 $species = $class->get_alias($species);
|
|
862 my $new_group =
|
|
863 $registry_register{_SPECIES}{$species}{ lc($group) }{'_DNA'};
|
|
864 my $new_species =
|
|
865 $registry_register{_SPECIES}{$species}{ lc($group) }{'_DNA2'};
|
|
866
|
|
867 if ( defined $new_group ) {
|
|
868 return $class->get_DBAdaptor( $new_species, $new_group );
|
|
869 }
|
|
870
|
|
871 return;
|
|
872 }
|
|
873
|
|
874 #
|
|
875 # General Adaptors
|
|
876 #
|
|
877
|
|
878 =head2 add_adaptor
|
|
879
|
|
880 Arg [1] : name of the species to add the adaptor to in the registry.
|
|
881 Arg [2] : name of the group to add the adaptor to in the registry.
|
|
882 Arg [3] : name of the type to add the adaptor to in the registry.
|
|
883 Arg [4] : The DBAdaptor to be added to the registry.
|
|
884 Arg [5] : (optional) Set to allow overwrites of existing adaptors.
|
|
885 Example : Bio::EnsEMBL::Registry->add_adaptor("Human", "core", "Gene", $adap);
|
|
886 Returntype : none
|
|
887 Exceptions : none
|
|
888 Caller : internal
|
|
889 Status : Stable
|
|
890
|
|
891 =cut
|
|
892
|
|
893 sub add_adaptor {
|
|
894 my ( $class, $species, $group, $type, $adap, $reset ) = @_;
|
|
895
|
|
896 $species = $class->get_alias($species);
|
|
897
|
|
898 # Since the adaptors are not stored initially, only their class paths
|
|
899 # when the adaptors are obtained, we need to store these instead. It
|
|
900 # is not necessarily an error if the registry is overwritten without
|
|
901 # the reset set but it is an indication that we are overwriting a
|
|
902 # database which should be a warning for now
|
|
903
|
|
904 if ( defined($reset) )
|
|
905 { # JUST RESET THE HASH VALUE NO MORE PROCESSING NEEDED
|
|
906 $registry_register{_SPECIES}{$species}{ lc($group) }{ lc($type) } =
|
|
907 $adap;
|
|
908 return;
|
|
909 }
|
|
910
|
|
911 if (
|
|
912 defined(
|
|
913 $registry_register{_SPECIES}{$species}{ lc($group) }{ lc($type) }
|
|
914 ) )
|
|
915 {
|
|
916 # print STDERR (
|
|
917 # "Overwriting Adaptor in Registry for $species $group $type\n");
|
|
918 $registry_register{_SPECIES}{$species}{ lc($group) }{ lc($type) } =
|
|
919 $adap;
|
|
920 return;
|
|
921 }
|
|
922 $registry_register{_SPECIES}{$species}{ lc($group) }{ lc($type) } =
|
|
923 $adap;
|
|
924
|
|
925 if ( !defined( $registry_register{_SPECIES}{$species}{'list'} ) ) {
|
|
926 $registry_register{_SPECIES}{$species}{'list'} = [$type];
|
|
927 } else {
|
|
928 push( @{ $registry_register{_SPECIES}{$species}{'list'} }, $type );
|
|
929 }
|
|
930
|
|
931 if ( !defined( $registry_register{_TYPE}{ lc($type) }{$species} ) ) {
|
|
932 $registry_register{_TYPE}{ lc($type) }{$species} = [$type];
|
|
933 } else {
|
|
934 push( @{ $registry_register{_TYPE}{ lc($type) }{$species} },
|
|
935 $adap );
|
|
936 }
|
|
937 return;
|
|
938 } ## end sub add_adaptor
|
|
939
|
|
940
|
|
941 =head2 get_adaptor
|
|
942
|
|
943 Arg [1] : name of the species to add the adaptor to in the registry.
|
|
944 Arg [2] : name of the group to add the adaptor to in the registry.
|
|
945 Arg [3] : name of the type to add the adaptor to in the registry.
|
|
946 Example : $adap = Bio::EnsEMBL::Registry->get_adaptor("Human", "core", "Gene");
|
|
947 Returntype : adaptor
|
|
948 Exceptions : Thrown if a valid internal name cannot be found for the given
|
|
949 name. If thrown check your API and DB version. Also thrown if
|
|
950 no type or group was given
|
|
951 Status : Stable
|
|
952
|
|
953 =cut
|
|
954
|
|
955 sub get_adaptor {
|
|
956 my ( $class, $species, $group, $type ) = @_;
|
|
957
|
|
958 my $ispecies = $class->get_alias($species);
|
|
959
|
|
960 if ( !defined($ispecies) ) {
|
|
961 throw("Can not find internal name for species '$species'");
|
|
962 }
|
|
963 else { $species = $ispecies }
|
|
964
|
|
965 throw 'No adaptor group given' if ! defined $group;
|
|
966 throw 'No adaptor type given' if ! defined $type;
|
|
967
|
|
968
|
|
969 if($type =~ /Adaptor$/i) {
|
|
970 warning("Detected additional Adaptor string in given the type '$type'. Removing it to avoid possible issues. Alter your type to stop this message");
|
|
971 $type =~ s/Adaptor$//i;
|
|
972 }
|
|
973
|
|
974 my %dnadb_adaptors = (
|
|
975 'sequence' => 1,
|
|
976 'assemblymapper' => 1,
|
|
977 'karyotypeband' => 1,
|
|
978 'repeatfeature' => 1,
|
|
979 'coordsystem' => 1,
|
|
980 'assemblyexceptionfeature' => 1
|
|
981 );
|
|
982
|
|
983 # warn "$species, $group, $type";
|
|
984
|
|
985 $type = lc($type);
|
|
986
|
|
987 # For historical reasons, allow use of group 'regulation' to refer to
|
|
988 # group 'funcgen'.
|
|
989 if ( lc($group) eq 'regulation' ) { $group = 'funcgen' }
|
|
990
|
|
991 my $dnadb_group =
|
|
992 $registry_register{_SPECIES}{$species}{ lc($group) }{'_DNA'};
|
|
993
|
|
994 if ( defined($dnadb_group)
|
|
995 && defined( $dnadb_adaptors{ lc($type) } ) )
|
|
996 {
|
|
997 $species =
|
|
998 $registry_register{_SPECIES}{$species}{ lc($group) }{'_DNA2'};
|
|
999 $group = $dnadb_group;
|
|
1000 }
|
|
1001
|
|
1002 my $ret =
|
|
1003 $registry_register{_SPECIES}{$species}{ lc($group) }{ lc($type) };
|
|
1004
|
|
1005 if ( !defined($ret) ) { return }
|
|
1006 if ( ref($ret) ) { return $ret }
|
|
1007
|
|
1008 # Not instantiated yet
|
|
1009
|
|
1010 my $dba = $registry_register{_SPECIES}{$species}{ lc($group) }{'_DB'};
|
|
1011 my $module = $ret;
|
|
1012
|
|
1013 my $test_eval = eval "require $module";
|
|
1014 if ($@ or (!$test_eval)) {
|
|
1015 warning("'$module' cannot be found.\nException $@\n");
|
|
1016 return;
|
|
1017 }
|
|
1018
|
|
1019 if (
|
|
1020 !defined(
|
|
1021 $registry_register{_SPECIES}{$species}{ lc($group) }{'CHECKED'} )
|
|
1022 )
|
|
1023 {
|
|
1024 $registry_register{_SPECIES}{$species}{ lc($group) }{'CHECKED'} = 1;
|
|
1025 $class->version_check($dba);
|
|
1026 }
|
|
1027
|
|
1028 my $adap = "$module"->new($dba);
|
|
1029 Bio::EnsEMBL::Registry->add_adaptor( $species, $group, $type, $adap,
|
|
1030 'reset' );
|
|
1031 $ret = $adap;
|
|
1032
|
|
1033 return $ret;
|
|
1034 } ## end sub get_adaptor
|
|
1035
|
|
1036 =head2 get_all_adaptors
|
|
1037
|
|
1038 Arg [SPECIES] : (optional) string
|
|
1039 species name to get adaptors for
|
|
1040 Arg [GROUP] : (optional) string
|
|
1041 group name to get adaptors for
|
|
1042 Arg [TYPE] : (optional) string
|
|
1043 type to get adaptors for
|
|
1044 Example : @adaps = @{Bio::EnsEMBL::Registry->get_all_adaptors()};
|
|
1045 Returntype : ref to list of adaptors
|
|
1046 Exceptions : none
|
|
1047 Status : Stable
|
|
1048
|
|
1049 =cut
|
|
1050
|
|
1051 sub get_all_adaptors{
|
|
1052 my ($class,@args)= @_;
|
|
1053 my ($species, $group, $type);
|
|
1054 my @ret=();
|
|
1055 my (%species_hash, %group_hash, %type_hash);
|
|
1056
|
|
1057
|
|
1058 if(@args == 1){ # Old species only one parameter
|
|
1059 warn("-SPECIES argument should now be used to get species adaptors");
|
|
1060 $species = $args[0];
|
|
1061 }
|
|
1062 else{
|
|
1063 # new style -SPECIES, -GROUP, -TYPE
|
|
1064 ($species, $group, $type) =
|
|
1065 rearrange([qw(SPECIES GROUP TYPE)], @args);
|
|
1066 }
|
|
1067
|
|
1068 if(defined($species)){
|
|
1069 $species_hash{$species} = 1;
|
|
1070 }
|
|
1071 else{
|
|
1072 # get list of species
|
|
1073 foreach my $dba (@{$registry_register{'_DBA'}}){
|
|
1074 $species_hash{lc($dba->species())} = 1;
|
|
1075 }
|
|
1076 }
|
|
1077 if(defined($group)){
|
|
1078 $group_hash{$group} = 1;
|
|
1079 }
|
|
1080 else{
|
|
1081 foreach my $dba (@{$registry_register{'_DBA'}}){
|
|
1082 $group_hash{lc($dba->group())} = 1;
|
|
1083 }
|
|
1084 }
|
|
1085
|
|
1086 if ( defined($type) ) {
|
|
1087 $type_hash{$type} = 1;
|
|
1088 } else {
|
|
1089 foreach my $dba ( @{ $registry_register{'_DBA'} } ) {
|
|
1090 foreach my $ty (
|
|
1091 @{ $registry_register{_SPECIES}{ lc( $dba->species ) }{'list'} }
|
|
1092 )
|
|
1093 {
|
|
1094 $type_hash{ lc($ty) } = 1;
|
|
1095 }
|
|
1096 }
|
|
1097 }
|
|
1098
|
|
1099 ### NOW NEED TO INSTANTIATE BY CALLING get_adaptor
|
|
1100 foreach my $sp ( keys %species_hash ) {
|
|
1101 foreach my $gr ( keys %group_hash ) {
|
|
1102 foreach my $ty ( keys %type_hash ) {
|
|
1103 my $temp = $class->get_adaptor( $sp, $gr, $ty );
|
|
1104 if ( defined($temp) ) {
|
|
1105 push @ret, $temp;
|
|
1106 }
|
|
1107 }
|
|
1108 }
|
|
1109 }
|
|
1110
|
|
1111 return (\@ret);
|
|
1112 }
|
|
1113
|
|
1114
|
|
1115 =head2 add_alias
|
|
1116
|
|
1117 Arg [1] : name of the species to add alias for
|
|
1118 Arg [2] : name of the alias
|
|
1119 Example : Bio::EnsEMBL::Registry->add_alias("Homo Sapiens","Human");
|
|
1120 Description: add alternative name for the species.
|
|
1121 Returntype : none
|
|
1122 Exceptions : none
|
|
1123 Status : Stable
|
|
1124
|
|
1125 =cut
|
|
1126
|
|
1127 sub add_alias{
|
|
1128 my ($class, $species,$key) = @_;
|
|
1129
|
|
1130 $registry_register{'_ALIAS'}{lc($key)} = lc($species);
|
|
1131 return;
|
|
1132 }
|
|
1133
|
|
1134 =head2 remove_alias
|
|
1135
|
|
1136 Arg [1] : name of the species to remove alias for
|
|
1137 Arg [2] : name of the alias
|
|
1138 Example : Bio::EnsEMBL::Registry->remove_alias("Homo Sapiens","Human");
|
|
1139 Description: remove alternative name for the species.
|
|
1140 Returntype : none
|
|
1141 Exceptions : none
|
|
1142 Status : Stable
|
|
1143
|
|
1144 =cut
|
|
1145
|
|
1146 sub remove_alias{
|
|
1147 my ($class, $species,$key) = @_;
|
|
1148
|
|
1149 delete $registry_register{'_ALIAS'}{lc($key)};
|
|
1150 return;
|
|
1151 }
|
|
1152
|
|
1153
|
|
1154
|
|
1155 =head2 get_alias
|
|
1156
|
|
1157 Arg [1] : name of the possible alias to get species for
|
|
1158 Example : Bio::EnsEMBL::Registry->get_alias("Human");
|
|
1159 Description: get proper species name.
|
|
1160 Returntype : species name
|
|
1161 Exceptions : none
|
|
1162 Status : Stable
|
|
1163
|
|
1164 =cut
|
|
1165
|
|
1166 sub get_alias {
|
|
1167 my ( $class, $key, $no_warn ) = @_;
|
|
1168
|
|
1169 if ( !defined( $registry_register{'_ALIAS'}{ lc($key) } ) ) {
|
|
1170 if ( ( !defined( $registry_register{_SPECIES}{ lc($key) } ) ) and
|
|
1171 ( !defined( $registry_register{_ALIAS}{ lc($key) } ) ) )
|
|
1172 {
|
|
1173 if ( ( !defined($no_warn) ) or ( !$no_warn ) ) {
|
|
1174 warning( "$key is not a valid species name " .
|
|
1175 "(check DB and API version)" );
|
|
1176 }
|
|
1177 return;
|
|
1178 }
|
|
1179 else { return $key }
|
|
1180 }
|
|
1181
|
|
1182 return $registry_register{'_ALIAS'}{ lc($key) };
|
|
1183 }
|
|
1184
|
|
1185 =head2 get_all_aliases
|
|
1186
|
|
1187 Arg [1] : Species name to retrieve aliases for
|
|
1188 (may be an alias as well).
|
|
1189 Example : Bio::EnsEMBL::Registry->get_all_aliases('Homo sapiens');
|
|
1190 Description: Returns all known aliases for a given species (but not the
|
|
1191 species name/alias that was given).
|
|
1192 Returntype : ArrayRef of all known aliases
|
|
1193 Exceptions : none
|
|
1194 Status : Development
|
|
1195
|
|
1196 =cut
|
|
1197
|
|
1198 sub get_all_aliases {
|
|
1199 my ( $class, $key ) = @_;
|
|
1200
|
|
1201 my $species = $registry_register{_ALIAS}{ lc($key) };
|
|
1202
|
|
1203 my @aliases;
|
|
1204 if ( defined($species) ) {
|
|
1205 foreach my $alias ( keys( %{ $registry_register{_ALIAS} } ) ) {
|
|
1206 if ( $species ne $alias
|
|
1207 && $species eq $registry_register{_ALIAS}{ lc($alias) } )
|
|
1208 {
|
|
1209 push( @aliases, $alias );
|
|
1210 }
|
|
1211 }
|
|
1212 }
|
|
1213
|
|
1214 return \@aliases;
|
|
1215 }
|
|
1216
|
|
1217 =head2 alias_exists
|
|
1218
|
|
1219 Arg [1] : name of the possible alias to get species for
|
|
1220 Example : Bio::EnsEMBL::Registry->alias_exists("Human");
|
|
1221 Description: does the species name exist.
|
|
1222 Returntype : 1 if exists else 0
|
|
1223 Exceptions : none
|
|
1224 Status : Stable
|
|
1225
|
|
1226 =cut
|
|
1227
|
|
1228 sub alias_exists {
|
|
1229 my ( $class, $key ) = @_;
|
|
1230
|
|
1231 return defined( $registry_register{'_ALIAS'}{ lc($key) } );
|
|
1232 }
|
|
1233
|
|
1234 =head2 set_disconnect_when_inactive
|
|
1235
|
|
1236 Example : Bio::EnsEMBL::Registry->set_disconnect_when_inactive();
|
|
1237 Description: Set the flag to make sure that the database connection is dropped if
|
|
1238 not being used on each database.
|
|
1239 Returntype : none
|
|
1240 Exceptions : none
|
|
1241 Status : Stable
|
|
1242
|
|
1243 =cut
|
|
1244
|
|
1245 sub set_disconnect_when_inactive{
|
|
1246 foreach my $dba ( @{get_all_DBAdaptors()}){
|
|
1247 my $dbc = $dba->dbc;
|
|
1248 # Disconnect if connected
|
|
1249 $dbc->disconnect_if_idle() if $dbc->connected();
|
|
1250 $dbc->disconnect_when_inactive(1);
|
|
1251 }
|
|
1252 return;
|
|
1253 }
|
|
1254
|
|
1255 =head2 set_reconnect_when_lost
|
|
1256
|
|
1257 Example : Bio::EnsEMBL::Registry->set_reconnect_when_lost();
|
|
1258 Description: Set the flag to make sure that the database connection is not lost before it's used.
|
|
1259 This is useful for long running jobs (over 8hrs).
|
|
1260 Returntype : none
|
|
1261 Exceptions : none
|
|
1262 Status : Stable
|
|
1263
|
|
1264 =cut
|
|
1265
|
|
1266 sub set_reconnect_when_lost{
|
|
1267 foreach my $dba ( @{get_all_DBAdaptors()}){
|
|
1268 my $dbc = $dba->dbc;
|
|
1269 $dbc->reconnect_when_lost(1);
|
|
1270 }
|
|
1271 return;
|
|
1272 }
|
|
1273
|
|
1274 =head2 disconnect_all
|
|
1275
|
|
1276 Example : Bio::EnsEMBL::Registry->disconnect_all();
|
|
1277 Description: disconnect from all the databases.
|
|
1278 Returntype : none
|
|
1279 Exceptions : none
|
|
1280 Status : Stable
|
|
1281
|
|
1282 =cut
|
|
1283
|
|
1284 sub disconnect_all {
|
|
1285 foreach my $dba ( @{get_all_DBAdaptors()||[]} ){
|
|
1286 my $dbc = $dba->dbc;
|
|
1287 next unless $dbc;
|
|
1288 # Disconnect if connected
|
|
1289 $dbc->disconnect_if_idle() if $dbc->connected();
|
|
1290 }
|
|
1291 return;
|
|
1292 }
|
|
1293
|
|
1294 =head get_DBAdaptor_count
|
|
1295
|
|
1296 Example : Bio::EnsEMBL::Registry->get_DBAdaptor_count();
|
|
1297 Description : Returns the count of database adaptors currently held by
|
|
1298 the registry
|
|
1299 Returntype : Int count of database adaptors currently known
|
|
1300 Exceptions : None
|
|
1301
|
|
1302 =cut
|
|
1303
|
|
1304 sub get_DBAdaptor_count {
|
|
1305 return scalar(@{$registry_register{'_DBA'}}) if(defined $registry_register{'_DBA'});
|
|
1306 return 0;
|
|
1307 }
|
|
1308
|
|
1309 =head2 change_access
|
|
1310
|
|
1311 Will change the username and password for a set of databases.
|
|
1312 if host,user or database names are missing then these are not checked.
|
|
1313 So for example if you do not specify a database then ALL databases on
|
|
1314 the specified host and port will be changed.
|
|
1315
|
|
1316 Arg [1] : name of the host to change access on
|
|
1317 Arg [2] : port number to change access on
|
|
1318 Arg [3] : name of the user to change access on
|
|
1319 Arg [4] : name of the database to change access on
|
|
1320 Arg [5] : name of the new user
|
|
1321 Arg [6] : new password
|
|
1322
|
|
1323 Example : Bio::EnsEMBL::Registry->get_alias("Human");
|
|
1324 Description: change username and password on one or more databases
|
|
1325 Returntype : none
|
|
1326 Exceptions : none
|
|
1327 Status : Stable
|
|
1328
|
|
1329 =cut
|
|
1330
|
|
1331 sub change_access{
|
|
1332 my ($self, $host,$port,$user,$dbname,$new_user,$new_pass) = @_;
|
|
1333 foreach my $dba ( @{$registry_register{'_DBA'}}){
|
|
1334 my $dbc = $dba->dbc;
|
|
1335 if((((!defined($host)) or ($host eq $dbc->host))) and
|
|
1336 (((!defined($port)) or ($port eq $dbc->port))) and
|
|
1337 (((!defined($user)) or ($user eq $dbc->username))) and
|
|
1338 ((!defined($dbname)) or ($dbname eq $dbc->dbname))){
|
|
1339 if($dbc->connected()){
|
|
1340 $dbc->db_handle->disconnect();
|
|
1341 $dbc->connected(undef);
|
|
1342 }
|
|
1343 # over write the username and password
|
|
1344 $dbc->username($new_user);
|
|
1345 $dbc->password($new_pass);
|
|
1346 }
|
|
1347 }
|
|
1348 return;
|
|
1349 }
|
|
1350
|
|
1351
|
|
1352
|
|
1353 =head2 load_registry_from_url
|
|
1354
|
|
1355 Arg [1] : string $url
|
|
1356 Arg [2] : (optional) integer
|
|
1357 If not 0, will print out all information.
|
|
1358 Arg [3] : (optional) integer
|
|
1359 This option will turn off caching for slice features, so,
|
|
1360 every time a set of features is retrieved, they will come
|
|
1361 from the database instead of the cache. This option is only
|
|
1362 recommended for advanced users, specially if you need to
|
|
1363 store and retrieve features. It might reduce performance when
|
|
1364 querying the database if not used properly. If in doubt, do
|
|
1365 not use it or ask in the developer mailing list.
|
|
1366
|
|
1367 Example : load_registry_from_url(
|
|
1368 'mysql://anonymous@ensembldb.ensembl.org:3306');
|
|
1369
|
|
1370 load_registry_from_url(
|
|
1371 'mysql://anonymous@ensembldb.ensembl.org:3306/homo_sapiens_core_65_37?group=core&species=homo_sapiens'
|
|
1372 );
|
|
1373
|
|
1374 load_registry_from_url(
|
|
1375 'mysql://anonymous@ensembldb.ensembl.org:3306/homo_sapiens_core_65_37?group=core'
|
|
1376 );
|
|
1377
|
|
1378
|
|
1379 Description: Will load the correct versions of the ensembl
|
|
1380 databases for the software release it can find on
|
|
1381 a database instance into the registry. Also adds
|
|
1382 a set of standard aliases. The url format is:
|
|
1383 mysql://[[username][:password]@]hostname[:port]. You
|
|
1384 can also request a specific version for the databases
|
|
1385 by adding a slash and the version number but your
|
|
1386 script may crash as the API version won't match the
|
|
1387 DB version.
|
|
1388
|
|
1389 You can also specify a database name which will cause the
|
|
1390 loading of a single DBAdaptor instance. Parameters are
|
|
1391 mapped from a normal URL parameter set to their DBAdaptor
|
|
1392 equivalent. Group must be defined.
|
|
1393
|
|
1394 Returntype : Int count of the DBAdaptor instances which can be found in the
|
|
1395 registry
|
|
1396
|
|
1397 Exceptions : Thrown if the given URL does not parse according to the above
|
|
1398 scheme and if the specified database cannot be connected to
|
|
1399 (see L<load_registry_from_db> for more information)
|
|
1400 Status : Stable
|
|
1401
|
|
1402 =cut
|
|
1403
|
|
1404 sub load_registry_from_url {
|
|
1405 my ( $self, $url, $verbose, $no_cache ) = @_;
|
|
1406
|
|
1407 if ( $url =~ /^mysql\:\/\/([^\@]+\@)?([^\:\/]+)(\:\d+)?(\/\d+)?\/?$/x ) {
|
|
1408 my $user_pass = $1;
|
|
1409 my $host = $2;
|
|
1410 my $port = $3;
|
|
1411 my $version = $4;
|
|
1412
|
|
1413 $user_pass =~ s/\@$//;
|
|
1414 my ( $user, $pass ) = $user_pass =~ m/([^\:]+)(\:.+)?/x;
|
|
1415 $pass =~ s/^\://x if ($pass);
|
|
1416 $port =~ s/^\://x if ($port);
|
|
1417 $version =~ s/^\///x if ($version);
|
|
1418
|
|
1419 return $self->load_registry_from_db(
|
|
1420 -host => $host,
|
|
1421 -user => $user,
|
|
1422 -pass => $pass,
|
|
1423 -port => $port,
|
|
1424 -db_version => $version,
|
|
1425 -verbose => $verbose,
|
|
1426 -no_cache => $no_cache
|
|
1427 );
|
|
1428 }
|
|
1429 my $uri = parse_uri($url);
|
|
1430 if($uri) {
|
|
1431 if($uri->scheme() eq 'mysql') {
|
|
1432 my %params = $uri->generate_dbsql_params();
|
|
1433 if($params{-DBNAME}) {
|
|
1434 $params{-SPECIES} = $params{-DBNAME} unless $params{-SPECIES};
|
|
1435 $params{-NO_CACHE} = 1 if $no_cache;
|
|
1436 my $group = $params{-GROUP};
|
|
1437 my $class = $self->_group_to_adaptor_class($group);
|
|
1438 if($verbose) {
|
|
1439 printf("Loading database '%s' from group '%s' with DBAdaptor class '%s' from url %s\n", $params{-DBNAME}, $group, $class, $url);
|
|
1440 }
|
|
1441 $class->new(%params);
|
|
1442 return 1;
|
|
1443 }
|
|
1444 }
|
|
1445 }
|
|
1446 throw("Only MySQL URLs are accepted. Given URL was '${url}'");
|
|
1447 } ## end sub load_registry_from_url
|
|
1448
|
|
1449
|
|
1450 =head2 load_registry_from_db
|
|
1451
|
|
1452 Arg [HOST] : string
|
|
1453 The domain name of the database host to connect to.
|
|
1454
|
|
1455 Arg [USER] : string
|
|
1456 The name of the database user to connect with.
|
|
1457
|
|
1458 Arg [PASS] : (optional) string
|
|
1459 The password to be used to connect to the database.
|
|
1460
|
|
1461 Arg [PORT] : (optional) integer
|
|
1462 The port to use when connecting to the database.
|
|
1463
|
|
1464 Arg [VERBOSE]: (optional) boolean
|
|
1465 Whether to print database messages.
|
|
1466
|
|
1467 Arg [SPECIES]: (optional) string
|
|
1468 By default, all databases that are found on the
|
|
1469 server and that corresponds to the correct release
|
|
1470 are probed for aliases etc. For some people,
|
|
1471 depending on where they are in the world, this might
|
|
1472 be a slow operation. With the '-species' argument,
|
|
1473 one may reduce the startup time by restricting the
|
|
1474 set of databases that are probed to those of a
|
|
1475 particular species.
|
|
1476
|
|
1477 Note that the latin name of the species is required,
|
|
1478 e.g., 'homo sapiens', 'gallus gallus', 'callithrix
|
|
1479 jacchus' etc. It may be the whole species name,
|
|
1480 or only the first part of the name, e.g. 'homo',
|
|
1481 'gallus', or 'callithrix'. This will be used in
|
|
1482 matching against the name of the databases.
|
|
1483
|
|
1484 Arg [DB_VERSION]: (optional) integer
|
|
1485 By default, only databases corresponding to the
|
|
1486 current API version are loaded. This argument
|
|
1487 allows the script to use databases from another
|
|
1488 version although it might not work properly. This
|
|
1489 argument should only be used for production or
|
|
1490 testing purposes and if you really know what you are
|
|
1491 doing.
|
|
1492
|
|
1493 Arg [WAIT_TIMEOUT]: (optional) integer
|
|
1494 Time in seconds for the wait timeout to happen.
|
|
1495 Time after which the connection is deleted if not
|
|
1496 used. By default this is 28800 (8 hours), so set
|
|
1497 this to greater than this if your connection are
|
|
1498 getting deleted. Only set this if you are having
|
|
1499 problems and know what you are doing.
|
|
1500
|
|
1501 Arg [-NO_CACHE]: (optional) boolean
|
|
1502 This option will turn off caching for slice features,
|
|
1503 so, every time a set of features is retrieved, they
|
|
1504 will come from the database instead of the cache. This
|
|
1505 option is only recommended for advanced users, specially
|
|
1506 if you need to store and retrieve features. It might
|
|
1507 reduce performance when querying the database if not
|
|
1508 used properly. If in doubt, do not use it or ask in the
|
|
1509 developer mailing list.
|
|
1510
|
|
1511 Arg [SPECIES_SUFFIX]: (optional) string
|
|
1512 This option will append the string to the species name
|
|
1513 in the registry for all databases found on this server.
|
|
1514
|
|
1515 Example :
|
|
1516
|
|
1517 $registry->load_registry_from_db(
|
|
1518 -host => 'ensembldb.ensembl.org',
|
|
1519 -user => 'anonymous',
|
|
1520 -verbose => '1'
|
|
1521 );
|
|
1522
|
|
1523 Description: Will load the correct versions of the Ensembl
|
|
1524 databases for the software release it can find on a
|
|
1525 database instance into the registry. Also adds a set
|
|
1526 of standard aliases.
|
|
1527
|
|
1528 Returntype : Int count of the DBAdaptor instances which can be found in the
|
|
1529 registry
|
|
1530
|
|
1531 Exceptions : Thrown if the given MySQL database cannot be connected to
|
|
1532 or there is any error whilst querying the database.
|
|
1533 Status : Stable
|
|
1534
|
|
1535 =cut
|
|
1536
|
|
1537 sub load_registry_from_db {
|
|
1538 my ( $self, @args ) = @_;
|
|
1539
|
|
1540 my ( $host, $port, $user,
|
|
1541 $pass, $verbose, $db_version,
|
|
1542 $wait_timeout, $no_cache, $species, $species_suffix )
|
|
1543 = rearrange( [ 'HOST', 'PORT',
|
|
1544 'USER', 'PASS',
|
|
1545 'VERBOSE', 'DB_VERSION',
|
|
1546 'WAIT_TIMEOUT', 'NO_CACHE',
|
|
1547 'SPECIES', 'SPECIES_SUFFIX' ],
|
|
1548 @args );
|
|
1549
|
|
1550 if ( defined($species) ) {
|
|
1551 $species = lc($species);
|
|
1552 $species =~ tr/ -/__/;
|
|
1553 }
|
|
1554 if (!defined($species_suffix)) {
|
|
1555 $species_suffix = "";
|
|
1556 }
|
|
1557
|
|
1558 my $ontology_db;
|
|
1559 my $ontology_version;
|
|
1560
|
|
1561 my $stable_ids_db;
|
|
1562 my $stable_ids_version;
|
|
1563
|
|
1564 $user ||= "ensro";
|
|
1565 if ( !defined($port) ) {
|
|
1566 $port = 3306;
|
|
1567 if ( $host eq "ensembldb.ensembl.org" ) {
|
|
1568 if ( (!defined($db_version)) or ($db_version >= 48) ) {
|
|
1569 $port = 5306;
|
|
1570 }
|
|
1571 }
|
|
1572 }
|
|
1573
|
|
1574 $wait_timeout ||= 0;
|
|
1575
|
|
1576 my $original_count = $self->get_DBAdaptor_count();
|
|
1577
|
|
1578 my $err_pattern = 'Cannot %s to the Ensembl MySQL server at %s:%d; check your settings & DBI error message: %s';
|
|
1579
|
|
1580 my $dbh = DBI->connect( "DBI:mysql:host=$host;port=$port", $user, $pass ) or
|
|
1581 throw(sprintf($err_pattern, 'connect', $host, $port, $DBI::errstr));
|
|
1582 $dbh->ping() or
|
|
1583 throw(sprintf($err_pattern, 'ping', $host, $port, $DBI::errstr));
|
|
1584
|
|
1585 my $res = $dbh->selectall_arrayref('SHOW DATABASES');
|
|
1586 my @dbnames = map { $_->[0] } @$res;
|
|
1587
|
|
1588 my %temp;
|
|
1589 my $software_version = software_version();
|
|
1590
|
|
1591 if ( defined($db_version) ) {
|
|
1592 $software_version = $db_version;
|
|
1593 }
|
|
1594
|
|
1595 if ($verbose) {
|
|
1596 printf( "Will only load v%d databases\n", $software_version );
|
|
1597 }
|
|
1598
|
|
1599 # From the list of all the databses create a tempory hash of those we
|
|
1600 # are interested in
|
|
1601
|
|
1602 for my $db (@dbnames) {
|
|
1603 if ( $db =~ /^(\w+_collection_\w+(?:_\d+)?)_((\d+)_\w+)/ )
|
|
1604 { # NEEDS TO BE FIRST TO PICK UP COLLECTION DBS
|
|
1605 if ( $3 eq $software_version ) {
|
|
1606 $temp{$1} = $2;
|
|
1607 }
|
|
1608 } elsif ( $db =~ /^(.+)_(userdata)$/x ) {
|
|
1609 $temp{$1} = $2;
|
|
1610 } elsif (
|
|
1611 $db =~ /^(ensembl_compara # compara database
|
|
1612 (?:_\w+)*?) # optional ensembl genomes bit
|
|
1613 _
|
|
1614 (\d+)$/x )
|
|
1615 { # db version
|
|
1616 if ( $2 eq $software_version ) {
|
|
1617 $temp{$1} = $2;
|
|
1618 }
|
|
1619 } elsif ( $db =~ /^(ensembl_ancestral(?:_\w+?)*?)_(\d+)$/x ) {
|
|
1620 if ( $2 eq $software_version ) {
|
|
1621 $temp{$1} = $2;
|
|
1622 }
|
|
1623 } elsif ( $db =~ /^ensembl(?:genomes)?_ontology_(?:\d+_)?(\d+)/x ) {
|
|
1624 if ( $1 eq $software_version ) {
|
|
1625 $ontology_db = $db;
|
|
1626 $ontology_version = $1;
|
|
1627 }
|
|
1628 } elsif ( $db =~ /^ensembl(?:genomes)?_stable_ids_(?:\d+_)?(\d+)/x ) {
|
|
1629 if ( $1 eq $software_version ) {
|
|
1630 $stable_ids_db = $db;
|
|
1631 $stable_ids_version = $1;
|
|
1632 }
|
|
1633
|
|
1634 } elsif (
|
|
1635 $db =~ /^([a-z]+_[a-z0-9]+(?:_[a-z0-9]+)? # species name e.g. homo_sapiens or canis_lupus_familiaris
|
|
1636 _
|
|
1637 [a-z]+ # db type
|
|
1638 (?:_\d+)?) # optional end bit for ensembl genomes databases
|
|
1639 _
|
|
1640 (\d+) # database release
|
|
1641 _
|
|
1642 (\w+)$ # assembly number can have letters too e.g 37c
|
|
1643 /x
|
|
1644 )
|
|
1645 {
|
|
1646
|
|
1647 # Species specific databases (core, cdna, vega etc.)
|
|
1648
|
|
1649 my ( $sp_name, $db_rel, $assem ) = ( $1, $2, $3 );
|
|
1650
|
|
1651 if ( !defined($species) || $sp_name =~ /^$species/ ) {
|
|
1652 if ( $db_rel eq $software_version ) {
|
|
1653 $temp{$sp_name} = $db_rel . "_" . $assem;
|
|
1654 }
|
|
1655 }
|
|
1656
|
|
1657 } else {
|
|
1658 # warn( sprintf( "Skipping database '%s'\n", $db ) );
|
|
1659 }
|
|
1660 } ## end for my $db (@dbnames)
|
|
1661
|
|
1662 @dbnames = ();
|
|
1663
|
|
1664 foreach my $key ( keys %temp ) {
|
|
1665 push @dbnames, $key . "_" . $temp{$key};
|
|
1666 }
|
|
1667
|
|
1668 # Register Core like databases
|
|
1669 my $core_like_dbs_found = 0;
|
|
1670 foreach my $type (qw(core cdna vega vega_update otherfeatures rnaseq)) {
|
|
1671
|
|
1672 my @dbs = grep { /^[a-z]+_[a-z0-9]+(?:_[a-z0-9]+)? # species name
|
|
1673 _
|
|
1674 $type # the database type
|
|
1675 _
|
|
1676 (?:\d+_)? # optional end bit for ensembl genomes
|
|
1677 \d+ # database release
|
|
1678 _
|
|
1679 /x } @dbnames;
|
|
1680
|
|
1681 if(@dbs) {
|
|
1682 $core_like_dbs_found = 1;
|
|
1683 }
|
|
1684
|
|
1685 foreach my $database (@dbs) {
|
|
1686 if ( index( $database, 'collection' ) != -1 ) {
|
|
1687 # Skip multi-species databases.
|
|
1688 next;
|
|
1689 }
|
|
1690
|
|
1691
|
|
1692 my ( $species, $num ) =
|
|
1693 ( $database =~ /(^[a-z]+_[a-z0-9]+(?:_[a-z0-9]+)?) # species name
|
|
1694 _
|
|
1695 $type # type
|
|
1696 _
|
|
1697 (?:\d+_)? # optional endbit for ensembl genomes
|
|
1698 (\d+) # databases release
|
|
1699 _
|
|
1700 /x );
|
|
1701
|
|
1702 if(!defined($species)){
|
|
1703 warn "Cannot extract species name from database '$database'";
|
|
1704 }
|
|
1705
|
|
1706 my $dba =
|
|
1707 Bio::EnsEMBL::DBSQL::DBAdaptor->new(
|
|
1708 -group => $type,
|
|
1709 -species => $species.$species_suffix,
|
|
1710 -host => $host,
|
|
1711 -user => $user,
|
|
1712 -pass => $pass,
|
|
1713 -port => $port,
|
|
1714 -dbname => $database,
|
|
1715 -wait_timeout => $wait_timeout,
|
|
1716 -no_cache => $no_cache );
|
|
1717
|
|
1718 if ($verbose) {
|
|
1719 printf( "Species '%s' loaded from database '%s'\n",
|
|
1720 $species, $database );
|
|
1721 }
|
|
1722 }
|
|
1723 }
|
|
1724
|
|
1725 # Register multi-species databases
|
|
1726
|
|
1727 my @multi_dbs = grep { /^\w+_collection_core_\w+$/ } @dbnames;
|
|
1728
|
|
1729 foreach my $multidb (@multi_dbs) {
|
|
1730 my $sth = $dbh->prepare(
|
|
1731 sprintf(
|
|
1732 "SELECT species_id, meta_value FROM %s.meta "
|
|
1733 . "WHERE meta_key = 'species.db_name'",
|
|
1734 $dbh->quote_identifier($multidb) ) );
|
|
1735
|
|
1736 $sth->execute();
|
|
1737
|
|
1738 my ( $species_id, $species );
|
|
1739 $sth->bind_columns( \( $species_id, $species ) );
|
|
1740
|
|
1741 while ( $sth->fetch() ) {
|
|
1742 my $dba = Bio::EnsEMBL::DBSQL::DBAdaptor->new(
|
|
1743 -group => "core",
|
|
1744 -species => $species.$species_suffix,
|
|
1745 -species_id => $species_id,
|
|
1746 -multispecies_db => 1,
|
|
1747 -host => $host,
|
|
1748 -user => $user,
|
|
1749 -pass => $pass,
|
|
1750 -port => $port,
|
|
1751 -dbname => $multidb,
|
|
1752 -wait_timeout => $wait_timeout,
|
|
1753 -no_cache => $no_cache
|
|
1754 );
|
|
1755
|
|
1756 if ($verbose) {
|
|
1757 printf( "Species '%s' (id:%d) loaded from database '%s'\n",
|
|
1758 $species, $species_id, $multidb );
|
|
1759 }
|
|
1760 }
|
|
1761 } ## end foreach my $multidb (@multi_dbs)
|
|
1762
|
|
1763 if(!$core_like_dbs_found && $verbose) {
|
|
1764 print("No core-like databases found. Check your DB_VERSION (used '$software_version')\n");
|
|
1765 }
|
|
1766
|
|
1767 # User upload DBs
|
|
1768
|
|
1769 my @userupload_dbs = grep { /_userdata$/ } @dbnames;
|
|
1770 for my $userupload_db (@userupload_dbs) {
|
|
1771 if ( index( $userupload_db, 'collection' ) != -1 ) {
|
|
1772 # Skip multi-species databases.
|
|
1773 next;
|
|
1774 }
|
|
1775
|
|
1776 my ($species) = ( $userupload_db =~ /(^.+)_userdata$/ );
|
|
1777 my $dba =
|
|
1778 Bio::EnsEMBL::DBSQL::DBAdaptor->new(
|
|
1779 -group => "userupload",
|
|
1780 -species => $species.$species_suffix,
|
|
1781 -host => $host,
|
|
1782 -user => $user,
|
|
1783 -pass => $pass,
|
|
1784 -port => $port,
|
|
1785 -wait_timeout => $wait_timeout,
|
|
1786 -dbname => $userupload_db,
|
|
1787 -no_cache => $no_cache );
|
|
1788
|
|
1789 if ($verbose) {
|
|
1790 printf( "%s loaded\n", $userupload_db );
|
|
1791 }
|
|
1792 }
|
|
1793
|
|
1794 # Register multi-species userupload databases.
|
|
1795 my @userdata_multidbs = grep { /^.+_collection_userdata$/ } @dbnames;
|
|
1796
|
|
1797 foreach my $multidb (@userdata_multidbs) {
|
|
1798 my $sth = $dbh->prepare(
|
|
1799 sprintf(
|
|
1800 "SELECT species_id, meta_value FROM %s.meta "
|
|
1801 . "WHERE meta_key = 'species.db_name'",
|
|
1802 $dbh->quote_identifier($multidb) ) );
|
|
1803
|
|
1804 $sth->execute();
|
|
1805
|
|
1806 my ( $species_id, $species );
|
|
1807 $sth->bind_columns( \( $species_id, $species ) );
|
|
1808
|
|
1809 while ( $sth->fetch() ) {
|
|
1810 my $dba = Bio::EnsEMBL::DBSQL::DBAdaptor->new(
|
|
1811 -group => "userupload",
|
|
1812 -species => $species.$species_suffix,
|
|
1813 -species_id => $species_id,
|
|
1814 -multispecies_db => 1,
|
|
1815 -host => $host,
|
|
1816 -user => $user,
|
|
1817 -pass => $pass,
|
|
1818 -port => $port,
|
|
1819 -dbname => $multidb,
|
|
1820 -wait_timeout => $wait_timeout,
|
|
1821 -no_cache => $no_cache
|
|
1822 );
|
|
1823
|
|
1824 if ($verbose) {
|
|
1825 printf( "Species '%s' (id:%d) loaded from database '%s'\n",
|
|
1826 $species, $species_id, $multidb );
|
|
1827 }
|
|
1828 }
|
|
1829 } ## end foreach my $multidb (@userdata_multidbs)
|
|
1830
|
|
1831 # Variation
|
|
1832
|
|
1833 my $test_eval = eval "require Bio::EnsEMBL::Variation::DBSQL::DBAdaptor";
|
|
1834 if ($@or (!$test_eval)) {
|
|
1835 # Ignore variations as code required not there for this
|
|
1836 if ($verbose) {
|
|
1837 print(
|
|
1838 "Bio::EnsEMBL::Variation::DBSQL::DBAdaptor module not found "
|
|
1839 . "so variation databases will be ignored if found\n" );
|
|
1840 }
|
|
1841 }
|
|
1842 else {
|
|
1843 my @variation_dbs =
|
|
1844 grep { /^[a-z]+_[a-z0-9]+(?:_[a-z0-9]+)?_variation_(?:\d+_)?\d+_/ } @dbnames;
|
|
1845
|
|
1846 if(! @variation_dbs && $verbose) {
|
|
1847 print("No variation databases found\n");
|
|
1848 }
|
|
1849
|
|
1850 for my $variation_db (@variation_dbs) {
|
|
1851
|
|
1852 if ( index( $variation_db, 'collection' ) != -1 ) {
|
|
1853 # Skip multi-species databases.
|
|
1854 next;
|
|
1855 }
|
|
1856
|
|
1857 my ( $species, $num ) =
|
|
1858 ( $variation_db =~ /(^[a-z]+_[a-z0-9]+(?:_[a-z0-9]+)?)_variation_(?:\d+_)?(\d+)_/ );
|
|
1859 my $dba =
|
|
1860 Bio::EnsEMBL::Variation::DBSQL::DBAdaptor->new(
|
|
1861 -group => "variation",
|
|
1862 -species => $species.$species_suffix,
|
|
1863 -host => $host,
|
|
1864 -user => $user,
|
|
1865 -pass => $pass,
|
|
1866 -port => $port,
|
|
1867 -wait_timeout => $wait_timeout,
|
|
1868 -dbname => $variation_db,
|
|
1869 -no_cache => $no_cache );
|
|
1870
|
|
1871 if ($verbose) {
|
|
1872 printf( "%s loaded\n", $variation_db );
|
|
1873 }
|
|
1874 }
|
|
1875
|
|
1876 # Register variation multispecies databases
|
|
1877 my @variation_multidbs =
|
|
1878 grep { /^\w+_collection_variation_\w+$/ } @dbnames;
|
|
1879
|
|
1880 foreach my $multidb (@variation_multidbs) {
|
|
1881 my $sth = $dbh->prepare(
|
|
1882 sprintf( 'SELECT species_id, meta_value FROM %s.meta ',
|
|
1883 $dbh->quote_identifier($multidb) )
|
|
1884 . "WHERE meta_key = 'species.db_name'"
|
|
1885 );
|
|
1886
|
|
1887 $sth->execute();
|
|
1888
|
|
1889 my ( $species_id, $species );
|
|
1890 $sth->bind_columns( \( $species_id, $species ) );
|
|
1891
|
|
1892 while ( $sth->fetch() ) {
|
|
1893 my $dba = Bio::EnsEMBL::Variation::DBSQL::DBAdaptor->new(
|
|
1894 -group => 'variation',
|
|
1895 -species => $species.$species_suffix,
|
|
1896 -species_id => $species_id,
|
|
1897 -multispecies_db => 1,
|
|
1898 -host => $host,
|
|
1899 -user => $user,
|
|
1900 -pass => $pass,
|
|
1901 -port => $port,
|
|
1902 -dbname => $multidb,
|
|
1903 -wait_timeout => $wait_timeout,
|
|
1904 -no_cache => $no_cache
|
|
1905 );
|
|
1906
|
|
1907 if ($verbose) {
|
|
1908 printf( "Species '%s' (id:%d) loaded from database '%s'\n",
|
|
1909 $species, $species_id, $multidb );
|
|
1910 }
|
|
1911 }
|
|
1912 } ## end foreach my $multidb (@variation_multidbs)
|
|
1913 }
|
|
1914
|
|
1915 my $func_eval = eval "require Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor";
|
|
1916 if ($@ or (!$func_eval)) {
|
|
1917 if ($verbose) {
|
|
1918 # Ignore funcgen DBs as code required not there for this
|
|
1919 print("Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor module not found "
|
|
1920 . "so functional genomics databases will be ignored if found\n"
|
|
1921 );
|
|
1922 }
|
|
1923 } else {
|
|
1924 my @funcgen_dbs =
|
|
1925 grep { /^[a-z]+_[a-z0-9]+(?:_[a-z0-9]+)?_funcgen_(?:\d+_)?\d+_/ } @dbnames;
|
|
1926
|
|
1927 if(! @funcgen_dbs && $verbose) {
|
|
1928 print("No funcgen databases found\n");
|
|
1929 }
|
|
1930
|
|
1931 for my $funcgen_db (@funcgen_dbs) {
|
|
1932 if ( index( $funcgen_db, 'collection' ) != -1 ) {
|
|
1933 # Skip multi-species databases.
|
|
1934 next;
|
|
1935 }
|
|
1936
|
|
1937 my ( $species, $num ) =
|
|
1938 ( $funcgen_db =~ /(^[a-z]+_[a-z0-9]+(?:_[a-z0-9]+)?)_funcgen_(?:\d+_)?(\d+)_/ );
|
|
1939 my $dba = Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor->new(
|
|
1940 -group => "funcgen",
|
|
1941 -species => $species.$species_suffix,
|
|
1942 -host => $host,
|
|
1943 -user => $user,
|
|
1944 -pass => $pass,
|
|
1945 -port => $port,
|
|
1946 -wait_timeout => $wait_timeout,
|
|
1947 -dbname => $funcgen_db,
|
|
1948 -no_cache => $no_cache
|
|
1949 );
|
|
1950
|
|
1951 if ($verbose) {
|
|
1952 printf( "%s loaded\n", $funcgen_db );
|
|
1953 }
|
|
1954 }
|
|
1955
|
|
1956 # Register functional genomics multispecies databases
|
|
1957 my @funcgen_multidbs =
|
|
1958 grep { /^\w+_collection_funcgen_\w+$/ } @dbnames;
|
|
1959
|
|
1960 foreach my $multidb (@funcgen_multidbs) {
|
|
1961 my $sth = $dbh->prepare(
|
|
1962 sprintf( 'SELECT species_id, meta_value FROM %s.meta ',
|
|
1963 $dbh->quote_identifier($multidb) )
|
|
1964 . "WHERE meta_key = 'species.db_name'"
|
|
1965 );
|
|
1966
|
|
1967 $sth->execute();
|
|
1968
|
|
1969 my ( $species_id, $species );
|
|
1970 $sth->bind_columns( \( $species_id, $species ) );
|
|
1971
|
|
1972 while ( $sth->fetch() ) {
|
|
1973 my $dba = Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor->new(
|
|
1974 -group => 'funcgen',
|
|
1975 -species => $species.$species_suffix,
|
|
1976 -species_id => $species_id,
|
|
1977 -multispecies_db => 1,
|
|
1978 -host => $host,
|
|
1979 -user => $user,
|
|
1980 -pass => $pass,
|
|
1981 -port => $port,
|
|
1982 -dbname => $multidb,
|
|
1983 -wait_timeout => $wait_timeout,
|
|
1984 -no_cache => $no_cache
|
|
1985 );
|
|
1986
|
|
1987 if ($verbose) {
|
|
1988 printf( "Species '%s' (id:%d) loaded from database '%s'\n",
|
|
1989 $species, $species_id, $multidb );
|
|
1990 }
|
|
1991 }
|
|
1992 } ## end foreach my $multidb (@funcgen_multidbs)
|
|
1993 } ## end else [ if ($@) ]
|
|
1994
|
|
1995 # Compara
|
|
1996
|
|
1997 my @compara_dbs = grep { /^ensembl_compara/ } @dbnames;
|
|
1998
|
|
1999 if (@compara_dbs) {
|
|
2000 my $comp_eval = eval "require Bio::EnsEMBL::Compara::DBSQL::DBAdaptor";
|
|
2001 if ($@ or (!$comp_eval)) {
|
|
2002 # Ignore Compara as code required not there for this
|
|
2003 if ($verbose) {
|
|
2004 printf(
|
|
2005 "Bio::EnsEMBL::Compara::DBSQL::DBAdaptor "
|
|
2006 . "not found so the following compara "
|
|
2007 . "databases will be ignored: %s\n",
|
|
2008 join( ', ', @compara_dbs ) );
|
|
2009 }
|
|
2010 } else {
|
|
2011 foreach my $compara_db (@compara_dbs) {
|
|
2012 # Looking for EnsEMBL Genomes Comparas.
|
|
2013 # ensembl_compara_bacteria_2_53 is registered as
|
|
2014 # 'bacteria', ensembl_compara_pan_homology_2_53 is
|
|
2015 # registered as 'pan_homology', ensembl_compara_53 is
|
|
2016 # registered as 'multi', and the alias 'compara' still
|
|
2017 # operates.
|
|
2018
|
|
2019 my ($species) =
|
|
2020 $compara_db =~ /^ensembl_compara_(\w+)(?:_\d+){2}$/xm;
|
|
2021
|
|
2022 $species ||= 'multi';
|
|
2023
|
|
2024 my $dba = Bio::EnsEMBL::Compara::DBSQL::DBAdaptor->new(
|
|
2025 -group => 'compara',
|
|
2026 -species => $species.$species_suffix,
|
|
2027 -host => $host,
|
|
2028 -user => $user,
|
|
2029 -pass => $pass,
|
|
2030 -port => $port,
|
|
2031 -wait_timeout => $wait_timeout,
|
|
2032 -dbname => $compara_db,
|
|
2033 -no_cache => $no_cache
|
|
2034 );
|
|
2035
|
|
2036 if ($verbose) {
|
|
2037 printf( "%s loaded\n", $compara_db );
|
|
2038 }
|
|
2039 } ## end foreach my $compara_db (@compara_dbs)
|
|
2040 } ## end else [ if ($@)
|
|
2041 } elsif ($verbose) {
|
|
2042 print("No Compara databases found\n");
|
|
2043 }
|
|
2044
|
|
2045 # Ancestral sequences
|
|
2046
|
|
2047 my @ancestral_dbs =
|
|
2048 sort grep { /^ensembl_ancestral/ } @dbnames;
|
|
2049
|
|
2050 if (@ancestral_dbs) {
|
|
2051 my $ancestral_db = shift @ancestral_dbs;
|
|
2052
|
|
2053 my $dba = Bio::EnsEMBL::DBSQL::DBAdaptor->new(
|
|
2054 -group => 'core',
|
|
2055 -species => 'Ancestral sequences'.$species_suffix,
|
|
2056 -host => $host,
|
|
2057 -user => $user,
|
|
2058 -pass => $pass,
|
|
2059 -port => $port,
|
|
2060 -wait_timeout => $wait_timeout,
|
|
2061 -dbname => $ancestral_db,
|
|
2062 -no_cache => $no_cache
|
|
2063 );
|
|
2064
|
|
2065 if ($verbose) {
|
|
2066 printf( "%s loaded\n", $ancestral_db );
|
|
2067
|
|
2068 if (@ancestral_dbs) {
|
|
2069 # If we still had some more then report the problem.
|
|
2070 printf(
|
|
2071 "Multiple ancestral databases found.\n"
|
|
2072 . "Ignoring the following: %s\n",
|
|
2073 join( ', ', @ancestral_dbs ) );
|
|
2074 }
|
|
2075 }
|
|
2076 } elsif ($verbose) {
|
|
2077 print("No ancestral database found\n");
|
|
2078 }
|
|
2079
|
|
2080 # Ontology
|
|
2081
|
|
2082 if ( defined($ontology_version) && $ontology_version != 0 ) {
|
|
2083 require Bio::EnsEMBL::DBSQL::OntologyDBAdaptor;
|
|
2084
|
|
2085 my $dba =
|
|
2086 Bio::EnsEMBL::DBSQL::OntologyDBAdaptor->new(
|
|
2087 '-species' => 'multi' . $species_suffix,
|
|
2088 '-group' => 'ontology',
|
|
2089 '-host' => $host,
|
|
2090 '-port' => $port,
|
|
2091 '-user' => $user,
|
|
2092 '-pass' => $pass,
|
|
2093 '-dbname' => $ontology_db, );
|
|
2094
|
|
2095 if ($verbose) {
|
|
2096 printf( "%s loaded\n", $ontology_db );
|
|
2097 }
|
|
2098 }
|
|
2099 elsif ($verbose) {
|
|
2100 print("No ontology database found\n");
|
|
2101 }
|
|
2102
|
|
2103
|
|
2104 if ( defined($stable_ids_db) && $stable_ids_version != 0 ) {
|
|
2105
|
|
2106 my $dba =
|
|
2107 Bio::EnsEMBL::DBSQL::DBAdaptor->new(
|
|
2108 '-species' => 'multi' . $species_suffix,
|
|
2109 '-group' => 'stable_ids',
|
|
2110 '-host' => $host,
|
|
2111 '-port' => $port,
|
|
2112 '-user' => $user,
|
|
2113 '-pass' => $pass,
|
|
2114 '-dbname' => $stable_ids_db, );
|
|
2115
|
|
2116 if ($verbose) {
|
|
2117 printf( "%s loaded\n", $stable_ids_db );
|
|
2118 }
|
|
2119
|
|
2120 }
|
|
2121
|
|
2122
|
|
2123 Bio::EnsEMBL::Utils::ConfigRegistry->add_alias(
|
|
2124 -species => 'multi'.$species_suffix,
|
|
2125 -alias => ['compara'.$species_suffix] );
|
|
2126
|
|
2127 Bio::EnsEMBL::Utils::ConfigRegistry->add_alias(
|
|
2128 -species => 'multi'.$species_suffix,
|
|
2129 -alias => ['ontology'.$species_suffix] );
|
|
2130
|
|
2131
|
|
2132 Bio::EnsEMBL::Utils::ConfigRegistry->add_alias(
|
|
2133 -species => 'multi'.$species_suffix,
|
|
2134 -alias => ['stable_ids'.$species_suffix] );
|
|
2135
|
|
2136 Bio::EnsEMBL::Utils::ConfigRegistry->add_alias(
|
|
2137 -species => 'Ancestral sequences'.$species_suffix,
|
|
2138 -alias => ['ancestral_sequences'.$species_suffix] );
|
|
2139
|
|
2140 # Register aliases as found in adaptor meta tables.
|
|
2141
|
|
2142 $self->find_and_add_aliases( '-handle' => $dbh,
|
|
2143 '-species_suffix' => $species_suffix );
|
|
2144
|
|
2145 $self->_additional_aliases($species_suffix);
|
|
2146
|
|
2147 $dbh->disconnect();
|
|
2148
|
|
2149 return $self->get_DBAdaptor_count() - $original_count;
|
|
2150
|
|
2151 } ## end sub load_registry_from_db
|
|
2152
|
|
2153
|
|
2154 # Used as a place to push "hack" aliases
|
|
2155 sub _additional_aliases {
|
|
2156 my ($self, $species_suffix) = @_;
|
|
2157
|
|
2158 #Adding branch-68 thirteen-lined ground squirrel "old" aliases
|
|
2159 Bio::EnsEMBL::Utils::ConfigRegistry->add_alias(
|
|
2160 -species => 'ictidomys_tridecemlineatus'.$species_suffix,
|
|
2161 -alias => ['spermophilus_tridecemlineatus'.$species_suffix] );
|
|
2162 Bio::EnsEMBL::Utils::ConfigRegistry->add_alias(
|
|
2163 -species => 'ictidomys_tridecemlineatus'.$species_suffix,
|
|
2164 -alias => ['spermophilus tridecemlineatus'.$species_suffix] );
|
|
2165
|
|
2166 return;
|
|
2167 } # end sub _additional_aliases
|
|
2168
|
|
2169 =head2 _group_to_adaptor_class
|
|
2170
|
|
2171 Arg [1] : The group you wish to decode to an adaptor class
|
|
2172 Example : Bio::EnsEMBL::Registry->_group_to_adaptor_class('core');
|
|
2173 Description : Has an internal lookup of groups to their adaptor classes
|
|
2174 Returntype : String
|
|
2175 Exceptions : Thrown if the group is unknown
|
|
2176 Status : Stable
|
|
2177
|
|
2178 =cut
|
|
2179
|
|
2180 sub _group_to_adaptor_class {
|
|
2181 my ($self, $group) = @_;
|
|
2182 my $class = {
|
|
2183 core => 'Bio::EnsEMBL::DBSQL::DBAdaptor',
|
|
2184 cdna => 'Bio::EnsEMBL::DBSQL::DBAdaptor',
|
|
2185 otherfeatures => 'Bio::EnsEMBL::DBSQL::DBAdaptor',
|
|
2186 rnaseq => 'Bio::EnsEMBL::DBSQL::DBAdaptor',
|
|
2187 vega => 'Bio::EnsEMBL::DBSQL::DBAdaptor',
|
|
2188 variation => 'Bio::EnsEMBL::Variation::DBSQL::DBAdaptor',
|
|
2189 funcgen => 'Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor',
|
|
2190 compara => 'Bio::EnsEMBL::Compara::DBSQL::DBAdaptor',
|
|
2191 }->{$group};
|
|
2192 throw "Group '${group}' is unknown" if ! $class;
|
|
2193 return $class;
|
|
2194 }
|
|
2195
|
|
2196
|
|
2197 =head2 find_and_add_aliases
|
|
2198
|
|
2199 Arg [ADAPTOR] : (optional) Bio::EnsEMBL::DBSQL::DBAdaptor
|
|
2200 The adaptor to use to retrieve aliases from.
|
|
2201
|
|
2202 Arg [GROUP] : (optional) string
|
|
2203 The group you want to find aliases for. If not
|
|
2204 given assumes all types.
|
|
2205
|
|
2206 Arg [HANDLE] : (optional) DBI database handle
|
|
2207 A connected database handle to use instead of
|
|
2208 the database handles stored in the DBAdaptors.
|
|
2209 Bypasses the use of MetaContainer.
|
|
2210
|
|
2211 Arg [SPECIES_SUFFIX]: (optional) string
|
|
2212 This option will append the string to the species
|
|
2213 name in the registry for all databases.
|
|
2214
|
|
2215 Example : Bio::EnsEMBL::Registry->find_and_add_aliases(
|
|
2216 -ADAPTOR => $dba,
|
|
2217 -GROUP => 'core'
|
|
2218 );
|
|
2219
|
|
2220 Description : Looks in the meta container for each database for
|
|
2221 an entry called "species.alias". If any are found
|
|
2222 then the species adaptor is registered to that
|
|
2223 set of aliases. This can work across any adaptor
|
|
2224 which has a MetaContainer. If no MetaContainer
|
|
2225 can be returned from a given adaptor then no alias
|
|
2226 searching is performed.
|
|
2227
|
|
2228 Return type : none
|
|
2229 Exceptions : Throws if an alias is found in more than one species.
|
|
2230 Status : Stable
|
|
2231
|
|
2232 =cut
|
|
2233
|
|
2234 sub find_and_add_aliases {
|
|
2235 my $class = shift ;
|
|
2236
|
|
2237 my ($adaptor, $group, $dbh, $species_suffix ) =
|
|
2238 rearrange( [ 'ADAPTOR', 'GROUP', 'HANDLE', 'SPECIES_SUFFIX' ], @_ );
|
|
2239
|
|
2240 #Can be undef; needs to be something to avoid warnings
|
|
2241 $species_suffix ||= q{};
|
|
2242
|
|
2243 my @dbas;
|
|
2244 if ( defined($adaptor) ) {
|
|
2245 @dbas = ($adaptor);
|
|
2246 } elsif ( defined($dbh) ) {
|
|
2247
|
|
2248 if ( length($species_suffix) > 0 ) {
|
|
2249 my @full = @{ $class->get_all_DBAdaptors( '-GROUP' => $group ) };
|
|
2250
|
|
2251 foreach my $db (@full) {
|
|
2252 if ( $db->species =~ /$species_suffix/ ) {
|
|
2253 push( @dbas, $db );
|
|
2254 }
|
|
2255 }
|
|
2256
|
|
2257 } else {
|
|
2258 @dbas = @{ $class->get_all_DBAdaptors( '-GROUP' => $group ) };
|
|
2259 }
|
|
2260
|
|
2261 } else {
|
|
2262 @dbas = @{ $class->get_all_DBAdaptors( '-GROUP' => $group ) };
|
|
2263 }
|
|
2264
|
|
2265 foreach my $dba (@dbas) {
|
|
2266 my @aliases;
|
|
2267 my $species = $dba->species();
|
|
2268
|
|
2269 if ( defined($dbh) ) {
|
|
2270 my $dbname = $dba->dbc()->dbname();
|
|
2271 my $sth = $dbh->prepare( sprintf(
|
|
2272 "SELECT meta_value FROM %s.meta "
|
|
2273 . "WHERE meta_key = 'species.alias' "
|
|
2274 . "AND species_id = ?",
|
|
2275 $dbh->quote_identifier($dbname) ) );
|
|
2276
|
|
2277 # Execute, and don't care about errors (there will be errors for
|
|
2278 # databases without a 'meta' table.
|
|
2279 $sth->{'PrintError'} = 0;
|
|
2280 $sth->{'RaiseError'} = 0;
|
|
2281 if ( !$sth->execute( $dba->species_id() ) ) { next }
|
|
2282 $sth->{'PrintError'} = $dbh->{'PrintError'};
|
|
2283 $sth->{'RaiseError'} = $dbh->{'RaiseError'};
|
|
2284
|
|
2285 my $alias;
|
|
2286 $sth->bind_columns( \$alias );
|
|
2287 while ( $sth->fetch() ) {
|
|
2288 push( @aliases, $alias );
|
|
2289 }
|
|
2290 } else {
|
|
2291 my $meta_container = eval { $dba->get_MetaContainer() };
|
|
2292
|
|
2293 if ( defined($meta_container) ) {
|
|
2294 push( @aliases,
|
|
2295 @{ $meta_container->list_value_by_key('species.alias') }
|
|
2296 );
|
|
2297 }
|
|
2298
|
|
2299 # Need to disconnect so we do not spam the MySQL servers trying to
|
|
2300 # get aliases. Can only call disonnect if dbc was defined.
|
|
2301 if ( defined( $dba->dbc() ) ) {
|
|
2302 $dba->dbc()->disconnect_if_idle();
|
|
2303 }
|
|
2304 }
|
|
2305
|
|
2306 foreach my $alias (@aliases) {
|
|
2307 my $alias_suffix = $alias.$species_suffix;
|
|
2308 #Lowercase because stored aliases are lowercased
|
|
2309 my $lc_species = lc($species);
|
|
2310 my $lc_alias_suffix = lc($alias_suffix);
|
|
2311 if ( !$class->alias_exists( $alias_suffix )
|
|
2312 && $lc_species ne $lc_alias_suffix )
|
|
2313 {
|
|
2314 $class->add_alias( $species, $alias_suffix );
|
|
2315 } elsif (
|
|
2316 $lc_species ne $class->get_alias( $alias_suffix ) )
|
|
2317 {
|
|
2318 $class->remove_alias( $species, $alias_suffix );
|
|
2319 }
|
|
2320 }
|
|
2321
|
|
2322 } ## end foreach my $dba (@dbas)
|
|
2323 return;
|
|
2324 } ## end sub find_and_add_aliases
|
|
2325
|
|
2326
|
|
2327 =head2 load_registry_from_multiple_dbs
|
|
2328
|
|
2329 Arg [1] : Array of hashes, each hash being a set of arguments to
|
|
2330 load_registry_from_db() (see above).
|
|
2331
|
|
2332 Example :
|
|
2333
|
|
2334 $registry->load_registry_from_multiple_dbs( {
|
|
2335 '-host' => 'ensembldb.ensembl.org',
|
|
2336 '-user' => 'anonymous',
|
|
2337 '-verbose' => '1'
|
|
2338 },
|
|
2339 {
|
|
2340 '-host' => 'server.example.com',
|
|
2341 '-user' => 'anonymouse',
|
|
2342 '-password' => 'cheese',
|
|
2343 '-verbose' => '1'
|
|
2344 } );
|
|
2345
|
|
2346 Description: Will call load_registry_from_db() (see above)
|
|
2347 multiple times and merge the resulting registries
|
|
2348 into one, effectively allowing a user to connect to
|
|
2349 databases on multiple database servers from within
|
|
2350 one program.
|
|
2351
|
|
2352 If a database is found on more than one server, the
|
|
2353 first found instance of that database will be used.
|
|
2354
|
|
2355 Returntype : Int count of the DBAdaptor instances which can be found in the
|
|
2356 registry
|
|
2357
|
|
2358 =cut
|
|
2359
|
|
2360 sub load_registry_from_multiple_dbs {
|
|
2361 my ( $self, @args ) = @_;
|
|
2362
|
|
2363 my $original_count = $self->get_DBAdaptor_count();
|
|
2364
|
|
2365 my %merged_register = %registry_register;
|
|
2366
|
|
2367 foreach my $arg (@args) {
|
|
2368 local %registry_register = ();
|
|
2369
|
|
2370 my $verbose;
|
|
2371
|
|
2372 ($verbose) = rearrange( ['VERBOSE'], %{$arg} );
|
|
2373
|
|
2374 $self->load_registry_from_db( %{$arg} );
|
|
2375
|
|
2376 #
|
|
2377 # Merge the localized %registry_register into %merged_register.
|
|
2378 #
|
|
2379
|
|
2380 # Merge the _SPECIES and _ALIAS sections of %registry_register.
|
|
2381 foreach my $section ( 'Species', 'Alias' ) {
|
|
2382 my $section_key = '_' . uc($section);
|
|
2383
|
|
2384 while ( my ( $key, $value ) =
|
|
2385 each( %{ $registry_register{$section_key} } ) )
|
|
2386 {
|
|
2387 if ( !exists( $merged_register{$section_key}{$key} ) ) {
|
|
2388 $merged_register{$section_key}{$key} = $value;
|
|
2389 } elsif ($verbose) {
|
|
2390 printf( "%s '%s' found on multiple servers, "
|
|
2391 . "using first found\n",
|
|
2392 $section, $key );
|
|
2393 }
|
|
2394 }
|
|
2395 }
|
|
2396 } ## end foreach my $arg (@args)
|
|
2397
|
|
2398 # Add the DBAs from the _SPECIES section into the _DBA section.
|
|
2399 foreach my $species_hash ( values( %{ $merged_register{_SPECIES} } ) )
|
|
2400 {
|
|
2401 foreach my $group_hash ( values( %{$species_hash} ) ) {
|
|
2402 if ( ref($group_hash) eq 'HASH' && exists( $group_hash->{_DB} ) )
|
|
2403 {
|
|
2404 push( @{ $merged_register{_DBA} }, $group_hash->{_DB} );
|
|
2405 }
|
|
2406 }
|
|
2407 }
|
|
2408
|
|
2409 %registry_register = %merged_register;
|
|
2410
|
|
2411 return $self->get_DBAdaptor_count() - $original_count;
|
|
2412 } ## end sub load_registry_from_multiple_dbs
|
|
2413
|
|
2414 #
|
|
2415 # Web specific routines
|
|
2416 #
|
|
2417
|
|
2418 =head2 DEPRECATED load_registry_with_web_adaptors
|
|
2419
|
|
2420 DEPRECATED: Use load_registry_from_db instead.
|
|
2421
|
|
2422 =cut
|
|
2423
|
|
2424 sub load_registry_with_web_adaptors{
|
|
2425 my $class = shift;
|
|
2426
|
|
2427 deprecate('Use the load_registry_from_db instead');
|
|
2428 my $site_eval = eval{ require SiteDefs };
|
|
2429 if ($@ or (!defined($site_eval))){ die "Can't use SiteDefs.pm - $@\n"; }
|
|
2430 SiteDefs->import(qw(:ALL));
|
|
2431
|
|
2432 my $species_eval = eval{ require SpeciesDefs };
|
|
2433 if ($@ or (!defined($species_eval))){ die "Can't use SpeciesDefs.pm - $@\n"; }
|
|
2434 my $conf = new SpeciesDefs();
|
|
2435
|
|
2436 my %species_alias = %{$SiteDefs::ENSEMBL_SPECIES_ALIASES};
|
|
2437
|
|
2438 foreach my $spec (keys %species_alias){
|
|
2439 Bio::EnsEMBL::Registry->add_alias($species_alias{$spec},$spec);
|
|
2440 }
|
|
2441 return;
|
|
2442 }
|
|
2443
|
|
2444 =head2 set_default_track
|
|
2445
|
|
2446 Sets a flag to say that that this species/group are a default track and do not
|
|
2447 need to be added as another web track.
|
|
2448
|
|
2449 Arg [1] : name of the species to get the adaptors for in the registry.
|
|
2450 Arg [2] : name of the type to get the adaptors for in the registry.
|
|
2451 Example : $merged = Bio::EnsEMBL::Registry->set_default_track("Human","core");
|
|
2452 Returntype : none
|
|
2453 Exceptions : none
|
|
2454 Status : At Risk.
|
|
2455
|
|
2456 =cut
|
|
2457
|
|
2458 sub set_default_track {
|
|
2459 my ( $class, $species, $group ) = @_;
|
|
2460
|
|
2461 $species = get_alias($species);
|
|
2462 $registry_register{'def_track'}{$species}{ lc($group) } = 1;
|
|
2463 return;
|
|
2464 }
|
|
2465
|
|
2466 =head2 default_track
|
|
2467
|
|
2468 Check flag to see if this is a default track
|
|
2469
|
|
2470 Arg [1] : name of the species to get the adaptors for in the registry.
|
|
2471 Arg [2] : name of the type to get the adaptors for in the registry.
|
|
2472 Example : $merged = Bio::EnsEMBL::Registry->set_default_track("Human","core");
|
|
2473 Returntype : int
|
|
2474 Exceptions : none
|
|
2475 Status : At Risk.
|
|
2476
|
|
2477 =cut
|
|
2478
|
|
2479 sub default_track {
|
|
2480 my ( $class, $species, $group ) = @_;
|
|
2481
|
|
2482 $species = get_alias($species);
|
|
2483 if (
|
|
2484 defined( $registry_register{'def_track'}{$species}{ lc($group) } ) )
|
|
2485 {
|
|
2486 return 1;
|
|
2487 }
|
|
2488
|
|
2489 return 0;
|
|
2490 }
|
|
2491
|
|
2492
|
|
2493 =head2 add_new_tracks
|
|
2494
|
|
2495 Will add new gene tracks to the configuration of the WEB server if they are
|
|
2496 not of the type default and the configuration already has genes in the display.
|
|
2497
|
|
2498 Arg [1] : hash of the default configuration of the web page
|
|
2499 Returntype : none
|
|
2500 Exceptions : none
|
|
2501 Called by : UserConfig.pm
|
|
2502 Status : At Risk.
|
|
2503
|
|
2504 =cut
|
|
2505
|
|
2506 sub add_new_tracks{
|
|
2507 my($class, $conf, $pos) = @_;
|
|
2508
|
|
2509 my $start = 0;
|
|
2510 my $reg = $class;
|
|
2511 my $species_reg = $reg->get_alias($conf->{'species'},"nothrow");
|
|
2512 my %pars;
|
|
2513 # print STDERR "Species $species_reg check for default tracks\n";
|
|
2514 if(defined($species_reg)){
|
|
2515 foreach my $dba (@{$reg->get_all_DBAdaptors()}){
|
|
2516 if(!$reg->default_track($dba->species,$dba->group)){
|
|
2517 $pars{'available'} = "species ".$reg->get_alias($dba->species());
|
|
2518 $pars{'db_alias'} = $dba->group();
|
|
2519 # print STDERR "Adding new track for ".$dba->species."\t".$dba->group."\n";
|
|
2520 $conf->add_new_track_generictranscript('',$dba->group(), "black",$pos,%pars);
|
|
2521 $pos++;
|
|
2522 }
|
|
2523 }
|
|
2524 }
|
|
2525 return $pos;
|
|
2526
|
|
2527 }
|
|
2528
|
|
2529 =head2 no_version_check
|
|
2530
|
|
2531 getter/setter for whether to run the version checking
|
|
2532
|
|
2533 Arg[0] : (optional) int
|
|
2534 Returntype : int or undef if not set
|
|
2535 Exceptions : none
|
|
2536 Status : At Risk.
|
|
2537
|
|
2538 =cut
|
|
2539
|
|
2540 sub no_version_check {
|
|
2541 my ( $self, $arg ) = @_;
|
|
2542 ( defined $arg )
|
|
2543 && ( $registry_register{'_no_version_check'} = $arg );
|
|
2544
|
|
2545 return $registry_register{'_no_version_check'};
|
|
2546 }
|
|
2547
|
|
2548 =head2 no_cache_warnings
|
|
2549
|
|
2550 Arg[0] : boolean for turning the flag on and off
|
|
2551 Description : Turns off any warnings about not using caching in all available
|
|
2552 adaptors.
|
|
2553 Returntype : boolean Current status
|
|
2554 Exceptions : None
|
|
2555
|
|
2556 =cut
|
|
2557
|
|
2558 sub no_cache_warnings {
|
|
2559 my ($self, $arg) = @_;
|
|
2560 if(defined $arg) {
|
|
2561 $Bio::EnsEMBL::DBSQL::BaseFeatureAdaptor::SILENCE_CACHE_WARNINGS = $arg;
|
|
2562 }
|
|
2563 return $Bio::EnsEMBL::DBSQL::BaseFeatureAdaptor::SILENCE_CACHE_WARNINGS;
|
|
2564 }
|
|
2565
|
|
2566
|
|
2567 =head2 version_check
|
|
2568
|
|
2569 run the database/API code version check for a DBAdaptor
|
|
2570
|
|
2571 Arg[0] : DBAdaptor to check
|
|
2572 Returntype : int 1 if okay, 0 if not the same
|
|
2573 Exceptions : none
|
|
2574 Status : At Risk.
|
|
2575
|
|
2576 =cut
|
|
2577
|
|
2578
|
|
2579 sub version_check {
|
|
2580 my ( $self, $dba ) = @_;
|
|
2581
|
|
2582 # Check the datbase and versions match
|
|
2583 # give warning if they do not.
|
|
2584 my $check = no_version_check();
|
|
2585
|
|
2586 if ( (
|
|
2587 defined( $ENV{HOME} )
|
|
2588 and ( -e $ENV{HOME} . "/.ensemblapi_no_version_check" ) )
|
|
2589 or ( defined($check) and ( $check != 0 ) ) )
|
|
2590 {
|
|
2591 return 1;
|
|
2592 }
|
|
2593
|
|
2594 my $mca =
|
|
2595 $self->get_adaptor( $dba->species(), $dba->group(),
|
|
2596 "MetaContainer" );
|
|
2597
|
|
2598 my $database_version = 0;
|
|
2599 if ( defined($mca) ) {
|
|
2600 $database_version = $mca->get_schema_version();
|
|
2601 }
|
|
2602
|
|
2603 if ( $database_version == 0 ) {
|
|
2604 # Try to work out the version
|
|
2605 if ( $dba->dbc()->dbname() =~ /^_test_db_/x ) {
|
|
2606 return 1;
|
|
2607 }
|
|
2608 if ( $dba->dbc()->dbname() =~ /(\d+)_\S+$/x ) {
|
|
2609 $database_version = $1;
|
|
2610 } elsif ( $dba->dbc()->dbname() =~ /ensembl_compara_(\d+)/x ) {
|
|
2611 $database_version = $1;
|
|
2612 } elsif ( $dba->dbc()->dbname() =~ /ensembl_help_(\d+)/x ) {
|
|
2613 $database_version = $1;
|
|
2614 } elsif ( $dba->dbc()->dbname() =~ /ensembl_ontology_(\d+)/x ) {
|
|
2615 $database_version = $1;
|
|
2616 } elsif ( $dba->dbc()->dbname() =~ /ensembl_stable_ids_(\d+)/x ) {
|
|
2617 $database_version = $1;
|
|
2618 } else {
|
|
2619 warn(
|
|
2620 sprintf(
|
|
2621 "No database version for database %s "
|
|
2622 . ". You must be using a post version 34 database "
|
|
2623 . "with version 34 or later code.\n"
|
|
2624 . "You need to update your database "
|
|
2625 . "or use the appropriate Ensembl software release "
|
|
2626 . "to ensure your script does not crash\n",
|
|
2627 $dba->dbc()->dbname() ) );
|
|
2628 }
|
|
2629 } ## end if ( $database_version...
|
|
2630
|
|
2631 if ( $database_version != software_version() ) {
|
|
2632 warn(
|
|
2633 sprintf(
|
|
2634 "For %s there is a difference in the software release (%s) "
|
|
2635 . "and the database release (%s). "
|
|
2636 . "You should update one of these to ensure that your script "
|
|
2637 . "does not crash.\n",
|
|
2638 $dba->dbc()->dbname(),
|
|
2639 software_version(), $database_version
|
|
2640 ) );
|
|
2641 return 0;
|
|
2642 }
|
|
2643
|
|
2644 return 1; # Ok
|
|
2645 } ## end sub version_check
|
|
2646
|
|
2647
|
|
2648 =head2 get_species_and_object_type
|
|
2649
|
|
2650 Description: Get the species name, object type (gene, transcript,
|
|
2651 translation, or exon etc.), and database type for a
|
|
2652 stable ID.
|
|
2653
|
|
2654 Arg [1] : String stable_id
|
|
2655 The stable ID to find species and object type for.
|
|
2656
|
|
2657 Arg [2] : String known_type (optional)
|
|
2658 The type of the stable ID, if it is known.
|
|
2659
|
|
2660 Arg [3] : String known_species (optional)
|
|
2661 The species, if known
|
|
2662
|
|
2663 Arg [4] : String known_db_type (optional)
|
|
2664 The database type, if known
|
|
2665
|
|
2666 Example : my $stable_id = 'ENST00000326632';
|
|
2667
|
|
2668 my ( $species, $object_type, $db_type ) =
|
|
2669 $registry->get_species_and_object_type($stable_id);
|
|
2670
|
|
2671 my $adaptor =
|
|
2672 $registry->get_adaptor( $species, $db_type,
|
|
2673 $object_type );
|
|
2674
|
|
2675 my $object = $adaptor->fetch_by_stable_id($stable_id);
|
|
2676
|
|
2677 Return type: Array consisting of the species name, object type,
|
|
2678 and database type. The array may be empty if no
|
|
2679 match is found.
|
|
2680
|
|
2681 Exceptions : none
|
|
2682 Status : At Risk.
|
|
2683
|
|
2684 =cut
|
|
2685
|
|
2686 my %stable_id_stmts = (
|
|
2687 gene => 'SELECT m.meta_value '
|
|
2688 . 'FROM %1$s.gene '
|
|
2689 . 'JOIN %1$s.seq_region USING (seq_region_id) '
|
|
2690 . 'JOIN %1$s.coord_system USING (coord_system_id) '
|
|
2691 . 'JOIN %1$s.meta m USING (species_id) '
|
|
2692 . 'WHERE stable_id = ? '
|
|
2693 . 'AND m.meta_key = "species.production_name"',
|
|
2694 transcript => 'SELECT m.meta_value '
|
|
2695 . 'FROM %1$s.transcript '
|
|
2696 . 'JOIN %1$s.seq_region USING (seq_region_id) '
|
|
2697 . 'JOIN %1$s.coord_system USING (coord_system_id) '
|
|
2698 . 'JOIN %1$s.meta m USING (species_id) '
|
|
2699 . 'WHERE stable_id = ? '
|
|
2700 . 'AND m.meta_key = "species.production_name"',
|
|
2701 exon => 'SELECT m.meta_value '
|
|
2702 . 'FROM %1$s.exon '
|
|
2703 . 'JOIN %1$s.seq_region USING (seq_region_id) '
|
|
2704 . 'JOIN %1$s.coord_system USING (coord_system_id) '
|
|
2705 . 'JOIN %1$s.meta m USING (species_id) '
|
|
2706 . 'WHERE stable_id = ? '
|
|
2707 . 'AND m.meta_key = "species.production_name"',
|
|
2708 translation => 'SELECT m.meta_value '
|
|
2709 . 'FROM %1$s.translation tl '
|
|
2710 . 'JOIN %1$s.transcript USING (transcript_id) '
|
|
2711 . 'JOIN %1$s.seq_region USING (seq_region_id) '
|
|
2712 . 'JOIN %1$s.coord_system USING (coord_system_id) '
|
|
2713 . 'JOIN %1$s.meta m USING (species_id) '
|
|
2714 . 'WHERE tl.stable_id = ? '
|
|
2715 . 'AND m.meta_key = "species.production_name"',
|
|
2716 operon => 'SELECT m.meta_value '
|
|
2717 . 'FROM %1$s.operon '
|
|
2718 . 'JOIN %1$s.seq_region USING (seq_region_id) '
|
|
2719 . 'JOIN %1$s.coord_system USING (coord_system_id) '
|
|
2720 . 'JOIN %1$s.meta m USING (species_id) '
|
|
2721 . 'WHERE stable_id = ? '
|
|
2722 . 'AND m.meta_key = "species.production_name"',
|
|
2723 operontranscript => 'SELECT m.meta_value '
|
|
2724 . 'FROM %1$s.operon_transcript '
|
|
2725 . 'JOIN %1$s.seq_region USING (seq_region_id) '
|
|
2726 . 'JOIN %1$s.coord_system USING (coord_system_id) '
|
|
2727 . 'JOIN %1$s.meta m USING (species_id) '
|
|
2728 . 'WHERE stable_id = ? '
|
|
2729 . 'AND m.meta_key = "species.production_name"',
|
|
2730
|
|
2731 );
|
|
2732
|
|
2733
|
|
2734 sub get_species_and_object_type {
|
|
2735 my ($self, $stable_id, $known_type, $known_species, $known_db_type) = @_;
|
|
2736
|
|
2737 #get the stable_id lookup database adaptor
|
|
2738 my $stable_ids_dba = $self->get_DBAdaptor("multi", "stable_ids", 1);
|
|
2739
|
|
2740 if ($stable_ids_dba) {
|
|
2741
|
|
2742 my $statement = 'SELECT name, object_type, db_type FROM stable_id_lookup join species using(species_id) WHERE stable_id = ?';
|
|
2743
|
|
2744 if ($known_species) {
|
|
2745 $statement .= ' AND name = ?';
|
|
2746 }
|
|
2747 if ($known_db_type) {
|
|
2748 $statement .= ' AND db_type = ?';
|
|
2749 }
|
|
2750 if ($known_type) {
|
|
2751 $statement .= ' AND object_type = ?';
|
|
2752 }
|
|
2753
|
|
2754 my $sth = $stable_ids_dba->dbc()->prepare($statement);
|
|
2755 $sth->bind_param(1, $stable_id, SQL_VARCHAR);
|
|
2756 my $param_count = 1;
|
|
2757 if ($known_species) {
|
|
2758 $param_count++;
|
|
2759 $sth->bind_param($param_count, $known_species, SQL_VARCHAR);
|
|
2760 }
|
|
2761 if ($known_db_type) {
|
|
2762 $param_count++;
|
|
2763 $sth->bind_param($param_count, $known_db_type, SQL_VARCHAR);
|
|
2764 }
|
|
2765 if ($known_type) {
|
|
2766 $param_count++;
|
|
2767 $sth->bind_param($param_count, $known_type, SQL_VARCHAR);
|
|
2768 }
|
|
2769 $sth->execute();
|
|
2770 my ($species, $type, $db_type) = $sth->fetchrow_array();
|
|
2771 return ($species ,$type, $db_type);
|
|
2772
|
|
2773 } else {
|
|
2774
|
|
2775 if (defined $known_type && !exists $stable_id_stmts{lc $known_type}) {
|
|
2776 return;
|
|
2777 }
|
|
2778
|
|
2779 my @types = defined $known_type ? ($known_type) : ('Gene', 'Transcript', 'Translation', 'Exon', 'Operon', 'OperonTranscript');
|
|
2780
|
|
2781 if ($known_db_type && $known_db_type ne 'core' && $known_db_type ne 'Core' ) {
|
|
2782 return;
|
|
2783 }
|
|
2784
|
|
2785 my %get_adaptors_args;
|
|
2786 $get_adaptors_args{'-group'} = 'Core';
|
|
2787 if ($known_species) {
|
|
2788 $get_adaptors_args{'-species'} = $known_species;
|
|
2789 }
|
|
2790
|
|
2791 my @dbas = sort { $a->dbc->host cmp $b->dbc->host || $a->dbc->port <=> $b->dbc->port }
|
|
2792 @{$self->get_all_DBAdaptors(%get_adaptors_args)};
|
|
2793 foreach my $dba (@dbas) {
|
|
2794
|
|
2795 foreach my $type (@types) {
|
|
2796 my $statement = sprintf $stable_id_stmts{lc $type}, $dba->dbc->dbname;
|
|
2797
|
|
2798 my $sth = $dba->dbc()->prepare($statement);
|
|
2799 $sth->bind_param(1, $stable_id, SQL_VARCHAR);
|
|
2800 $sth->execute;
|
|
2801
|
|
2802 my $species = $sth->fetchall_arrayref->[0][0];
|
|
2803
|
|
2804 $sth->finish;
|
|
2805
|
|
2806 return ($species, $type, 'Core') if defined $species;
|
|
2807 }
|
|
2808
|
|
2809 } ## end foreach my $dba ( sort { $a...})
|
|
2810
|
|
2811 }
|
|
2812
|
|
2813 return;
|
|
2814 } ## end sub get_species_and_object_type
|
|
2815
|
|
2816 1;
|