LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2024] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
CONTACT
Please email comments or questions to the public Ensembl
developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
Questions may also be sent to the Ensembl help desk at
<http://www.ensembl.org/Help/Contact>.
NAME
Bio::EnsEMBL::Registry
SYNOPSIS
use Bio::EnsEMBL::Registry;
my $registry = 'Bio::EnsEMBL::Registry';
$registry->load_all("configuration_file");
$gene_adaptor = $registry->get_adaptor( 'Human', 'Core', 'Gene' );
DESCRIPTION
All Adaptors are stored/registered using this module. This module should then be used to get the adaptors needed.
The registry can be loaded from a configuration file using the load_all method.
If a filename is passed to load_all then this is used. Else if the environment variable ENSEMBL_REGISTRY is set to the name on an existing configuration file, then this is used. Else if the file .ensembl_init in your home directory exist, it is used.
For the Web server ENSEMBL_REGISTRY should be set in SiteDefs.pm. This will then be passed on to load_all.
The registry can also be loaded via the method load_registry_from_db which given a database host will load the latest versions of the Ensembl databases from it.
The four types of registries are for db adaptors, dba adaptors, dna adaptors and the standard type.
db
These are registries for backwards compatibility and enable the subroutines to add other adaptors to connections.
e.g. get_all_db_adaptors, get_db_adaptor, add_db_adaptor, remove_db_adaptor are the old DBAdaptor subroutines which are now redirected to the Registry.
So if before we had
my $sfa = $self->adaptor()->db()->get_db_adaptor('blast');
We now want to change this to
my $sfa =
Bio::EnsEMBL::Registry->get_adaptor( "human", "core", "blast" );
DBA
These are the stores for the DBAdaptors
The Registry will create all the DBConnections needed now if you set up the configuration correctly. So instead of the old commands like
my $db = Bio::EnsEMBL::DBSQL::DBAdaptor->new(...);
my $exon_adaptor = $db->get_ExonAdaptor;
we should now have just
my $exon_adaptor =
Bio::EnsEMBL::Registry->get_adaptor( "human", "core", "exon" );
DNA
This is an internal Registry and allows the configuration of a dnadb. An example here is to set the est database to get its dna data from the core database.
## set the est db to use the core for getting dna data.
# Bio::EnsEMBL::Utils::ConfigRegistry->dnadb_add( "Homo Sapiens",
# "core", "Homo Sapiens", "est" );
adaptors
This is the registry for all the general types of adaptors like GeneAdaptor, ExonAdaptor, Slice Adaptor etc.
These are accessed by the get_adaptor subroutine i.e.
my $exon_adaptor =
Bio::EnsEMBL::Registry->get_adaptor( "human", "core", "exon" );
METHODS
load_all
Will load the registry with the configuration file which is
obtained from the first in the following and in that order.
1) If an argument is passed to this method, this is used as the
name of the configuration file to read.
2) If the environment variable ENSEMBL_REGISTRY is set, this is
used as the name of the configuration file to read.
3) If the file .ensembl_init exist in the home directory, it is
used as the configuration file.
Arg [1] : (optional) string
Name of file to load the registry from.
Arg [2] : (optional) integer
If not 0, will print out all information.
Arg [3] : (optional) integer
If not 0, the database connection will not be
cleared, if 0 or if not set the database connections
will be cleared (this is the default).
Arg [4]: (optional) boolean
This option will turn off caching for slice features,
so, every time a set of features is retrieved,
they will come from the database instead of the
cache. This option is only recommended for advanced
users, specially if you need to store and retrieve
features. It might reduce performance when querying
the database if not used properly. If in doubt, do
not use it or ask in the developer mailing list.
Arg [5]: (optional) boolean
This option will make load_all() throw if the configuration file
is missing and cannot be guessed from the environment
Example : Bio::EnsEMBL::Registry->load_all();
Returntype : Int count of the DBAdaptor instances which can be found in the
registry due to this method being called. Will never be negative
Exceptions : Throws if $throw_if_missing is set and ($config_file is missing
and cannot be guessed from the environment
Status : Stable
clear
Will clear the registry and disconnect from all databases.
Example : Bio::EnsEMBL::Registry->clear();
Returntype : none
Exceptions : none
Status : Stable
add_db
Arg [1] : db (DBAdaptor) to add adaptor to.
Arg [2] : name of the name to add the adaptor to in the registry.
Arg [3] : The adaptor to be added to the registry.
Example : Bio::EnsEMBL::Registry->add_db($db, "lite", $dba);
Returntype : none
Exceptions : none
Status : At Risk.
: This is here for backwards compatibility only and may
: be removed eventually. Solution is to make sure the
: db and the adaptor have the same species and the call
: is then no longer needed.
remove_db
Arg [1] : db (DBAdaptor) to remove adaptor from.
Arg [2] : name to remove the adaptor from in the registry.
Example : my $db = Bio::EnsEMBL::Registry->remove_db($db, "lite");
Returntype : adaptor
Exceptions : none
Status : At Risk.
: This is here for backwards compatibility only and may
: be removed eventually. Solution is to make sure the
: db and the adaptor have the same species and the call
: is then no longer needed.
get_db
Arg [1] : db (DBAdaptor) to get adaptor from.
Arg [2] : name to get the adaptor for in the registry.
Example : my $db = Bio::EnsEMBL::Registry->get_db("Human", "core", "lite");
Returntype : adaptor
Exceptions : See get_DBAdaptor()
Status : At Risk.
: This is here for backwards compatibility only and may
: be removed eventually. Solution is to make sure the
: db and the adaptor have the same species then call
: get_DBAdaptor instead.
get_all_db_adaptors
Arg [1] : db (DBAdaptor) to get all the adaptors from.
Example : my $db = Bio::EnsEMBL::Registry->get_all_db_adaptors($db);
Returntype : adaptor
Exceptions : none
Status : At Risk.
: This is here for backwards compatibility only and
: may be removed eventually. Solution is to make
: sure the dbs all have the same species then call
: get_all_DBAdaptors(-species => "human");
add_DBAdaptor
Arg [1] : name of the species to add the adaptor to in the registry.
Arg [2] : name of the group to add the adaptor to in the registry.
Arg [3] : DBAdaptor to be added to the registry.
Example : Bio::EnsEMBL::Registry->add_DBAdaptor("Human", "core", $dba);
Returntype : none
Exceptions : none
caller : internal
Status : Stable
get_DBAdaptor
Arg [1] : name of the species to get the adaptor for in the registry.
Arg [2] : name of the group to get the adaptor for in the registry.
Arg [3] : if set will not give warnings when looking for alias.
Example : $dba = Bio::EnsEMBL::Registry->get_DBAdaptor("Human", "core");
Returntype : DBAdaptor
Exceptions : If $species is not defined and if no valid internal name
could be found for $species. If thrown check your API and DB
version
Status : Stable
get_all_DBAdaptors
Arg [SPECIES]: (optional) string
species name to get adaptors for
Arg [GROUP] : (optional) string
group name to get adaptors for
Example :
@dba =
@{ Bio::EnsEMBL::Registry->get_all_DBAdaptors() };
@human_dbas =
@{ Bio::EnsEMBL::Registry->get_all_DBAdaptors(
-species => 'human'
) };
Returntype : list of DBAdaptors
Exceptions : none
Status : Stable
get_all_DBAdaptors_by_connection
Arg [1] : DBConnection used to find DBAdaptors
Returntype : reference to list of DBAdaptors
Exceptions : none
Example : @dba = @{ Bio::EnsEMBL::Registry
->get_all_DBAdaptors_by_connection($dbc) };
Status : Stable
get_all_DBAdaptors_by_dbname
Arg [1] : string, name of database
Returntype : reference to list of DBAdaptors
Exceptions : none
Example : @dba = @{ Bio::EnsEMBL::Registry
->get_all_DBAdaptors_by_dbname($dbname) };
Status : Stable
remove_DBAdaptor
Arg [1] : name of the species to get the adaptor for in the registry.
Arg [2] : name of the group to get the adaptor for in the registry.
Example : $dba = Bio::EnsEMBL::Registry->remove_DBAdaptor("Human", "core");
Returntype : none
Exceptions : none
Status : At risk
reset_DBAdaptor
Arg [1]: string - species e.g. homo_sapiens
Arg [2]: string - DB group e.g. core
Arg [3]: string - new dbname
Args [4-7]: string - optional DB parameters, defaults to current db params if omitted
Arg [8]: hashref - Hash ref of additional parameters e.g. eFG dnadb params for auto selecting dnadb
Usage : $reg->reset_registry_db( 'homo_sapiens', 'core',
'homo_sapiens_core_37_35j' );
Description: Resets a DB within the registry.
Exceptions: Throws if mandatory params not supplied
Throws if species name is not already seen by the registry
Throws if no current DB for species/group available
Status : At risk
add_DNAAdaptor
Arg [1] : name of the species to add the adaptor to in the registry.
Arg [2] : name of the group to add the adaptor to in the registry.
Arg [3] : name of the species to get the dna from
Arg [4] : name of the group to get the dna from
Example : Bio::EnsEMBL::Registry->add_DNAAdaptor("Human", "estgene", "Human", "core");
Returntype : none
Exceptions : none
Status : Stable
get_DNAAdaptor
Arg [1] : name of the species to get the adaptor for in the registry.
Arg [2] : name of the group to get the adaptor for in the registry.
Example : $dnaAdap = Bio::EnsEMBL::Registry->get_DNAAdaptor("Human", "core");
Returntype : adaptor
Exceptions : none
Status : Stable
add_adaptor
Arg [1] : name of the species to add the adaptor to in the registry.
Arg [2] : name of the group to add the adaptor to in the registry.
Arg [3] : name of the type to add the adaptor to in the registry.
Arg [4] : The DBAdaptor to be added to the registry.
Arg [5] : (optional) Set to allow overwrites of existing adaptors.
Example : Bio::EnsEMBL::Registry->add_adaptor("Human", "core", "Gene", $adap);
Returntype : none
Exceptions : none
Caller : internal
Status : Stable
add_switchable_adaptor
Arg [1] : String name of the species to add its switchable adaptor into the registry
Arg [2] : String name of the group to add its switchable adaptor into the registry
Arg [3] : String name of the type to add its switchable adaptor into the registry
Arg [4] : Reference switchable adaptor to insert
Arg [5] : Boolean override any existing switchable adaptor
Example : Bio::EnsEMBL::Registry->add_switchable_adaptor("Human", "core", "Gene", $my_other_source);
Returntype : None
Exceptions : Thrown if a valid internal name cannot be found for the given
name. If thrown check your API and DB version. Also thrown if
no type, group or switchable adaptor instance was given
has_switchable_adaptor
Arg [1] : String name of the species to add its switchable adaptor into the registry
Arg [2] : String name of the group to add its switchable adaptor into the registry
Arg [3] : String name of the type to add its switchable adaptor into the registry
Example : Bio::EnsEMBL::Registry->has_switchable_adaptor("Human", "core", "Gene");
Returntype : Boolean indicating if a switchable adaptor is available for your submitted combination
Exceptions : Thrown if a valid internal name cannot be found for the given
name. If thrown check your API and DB version. Also thrown if
no type, group or switchable adaptor instance was given
remove_switchable_adaptor
Arg [1] : name of the species to remove its switchable adaptor from the registry
Arg [2] : name of the group to remove its switchable adaptor from the registry
Arg [3] : name of the type to remove its switchable adaptor from the registry
Example : $adap = Bio::EnsEMBL::Registry->remove_switchable_adaptor("Human", "core", "Gene");
Returntype : The removed adaptor if one was removed. Otherwise undef
Exceptions : Thrown if a valid internal name cannot be found for the given
name. If thrown check your API and DB version. Also thrown if
no type or group was given
get_adaptor
Arg [1] : name of the species to add the adaptor to in the registry.
Arg [2] : name of the group to add the adaptor to in the registry.
Arg [3] : name of the type to add the adaptor to in the registry.
Example : $adap = Bio::EnsEMBL::Registry->get_adaptor("Human", "core", "Gene");
Description : Finds and returns the specified adaptor. This method will also check
if the species, group and adaptor combination satisfy a DNADB condition
(and will return that DNADB's implementation). Also we check for
any available switchable adaptors and will return that if available.
Returntype : adaptor
Exceptions : Thrown if a valid internal name cannot be found for the given
name. If thrown check your API and DB version. Also thrown if
no type or group was given
Status : Stable
get_all_adaptors
Arg [SPECIES] : (optional) string
species name to get adaptors for
Arg [GROUP] : (optional) string
group name to get adaptors for
Arg [TYPE] : (optional) string
type to get adaptors for
Example : @adaps = @{Bio::EnsEMBL::Registry->get_all_adaptors()};
Returntype : ref to list of adaptors
Exceptions : none
Status : Stable
add_alias
Arg [1] : name of the species to add alias for
Arg [2] : name of the alias
Example : Bio::EnsEMBL::Registry->add_alias("Homo Sapiens","Human");
Description: add alternative name for the species.
Returntype : none
Exceptions : none
Status : Stable
remove_alias
Arg [1] : name of the species to remove alias for
Arg [2] : name of the alias
Example : Bio::EnsEMBL::Registry->remove_alias("Homo Sapiens","Human");
Description: remove alternative name for the species.
Returntype : none
Exceptions : none
Status : Stable
get_alias
Arg [1] : name of the possible alias to get species for
Example : Bio::EnsEMBL::Registry->get_alias("Human");
Description: get proper species name.
Returntype : species name
Exceptions : none
Status : Stable
get_all_aliases
Arg [1] : Species name to retrieve aliases for
(may be an alias as well).
Example : Bio::EnsEMBL::Registry->get_all_aliases('Homo sapiens');
Description: Returns all known aliases for a given species (but not the
species name/alias that was given).
Returntype : ArrayRef of all known aliases
Exceptions : none
Status : Development
alias_exists
Arg [1] : name of the possible alias to get species for
Example : Bio::EnsEMBL::Registry->alias_exists("Human");
Description: does the species name exist.
Returntype : 1 if exists else 0
Exceptions : none
Status : Stable
set_disconnect_when_inactive
Example : Bio::EnsEMBL::Registry->set_disconnect_when_inactive();
Description: Set the flag to make sure that the database connection is dropped if
not being used on each database.
Returntype : none
Exceptions : none
Status : Stable
set_reconnect_when_lost
Example : Bio::EnsEMBL::Registry->set_reconnect_when_lost();
Description: Set the flag to make sure that the database connection is not lost before it's used.
This is useful for long running jobs (over 8hrs).
Returntype : none
Exceptions : none
Status : Stable
disconnect_all
Example : Bio::EnsEMBL::Registry->disconnect_all();
Description: disconnect from all the databases.
Returntype : none
Exceptions : none
Status : Stable
Example : Bio::EnsEMBL::Registry->get_DBAdaptor_count();
Description : Returns the count of database adaptors currently held by
the registry
Returntype : Int count of database adaptors currently known
Exceptions : None
change_access
Will change the username and password for a set of databases.
if host,user or database names are missing then these are not checked.
So for example if you do not specify a database then ALL databases on
the specified host and port will be changed.
Arg [1] : name of the host to change access on
Arg [2] : port number to change access on
Arg [3] : name of the user to change access on
Arg [4] : name of the database to change access on
Arg [5] : name of the new user
Arg [6] : new password
Example : Bio::EnsEMBL::Registry->get_alias("Human");
Description: change username and password on one or more databases
Returntype : none
Exceptions : none
Status : Stable
load_registry_from_url
Arg [1] : string $url
Arg [2] : (optional) integer
If not 0, will print out all information.
Arg [3] : (optional) integer
This option will turn off caching for slice features, so,
every time a set of features is retrieved, they will come
from the database instead of the cache. This option is only
recommended for advanced users, specially if you need to
store and retrieve features. It might reduce performance when
querying the database if not used properly. If in doubt, do
not use it or ask in the developer mailing list.
Example : load_registry_from_url(
'mysql://anonymous@ensembldb.ensembl.org:3306');
load_registry_from_url(
'mysql://anonymous@ensembldb.ensembl.org:3306/homo_sapiens_core_65_37?group=core&species=homo_sapiens'
);
load_registry_from_url(
'mysql://anonymous@ensembldb.ensembl.org:3306/homo_sapiens_core_65_37?group=core'
);
Description: Will load the correct versions of the ensembl
databases for the software release it can find on
a database instance into the registry. Also adds
a set of standard aliases. The url format is:
mysql://[[username][:password]@]hostname[:port]. You
can also request a specific version for the databases
by adding a slash and the version number but your
script may crash as the API version won't match the
DB version.
You can also specify a database name which will cause the
loading of a single DBAdaptor instance. Parameters are
mapped from a normal URL parameter set to their DBAdaptor
equivalent. Group must be defined.
Returntype : Int count of the DBAdaptor instances which can be found in the
registry
Exceptions : Thrown if the given URL does not parse according to the above
scheme and if the specified database cannot be connected to
(see L<load_registry_from_db> for more information)
Status : Stable
load_registry_from_db
Arg [HOST] : string
The domain name of the database host to connect to.
Arg [USER] : string
The name of the database user to connect with.
Arg [PASS] : (optional) string
The password to be used to connect to the database.
Arg [PORT] : (optional) integer
The port to use when connecting to the database.
Arg [VERBOSE]: (optional) boolean
Whether to print database messages. This includes a listing
of all available species & databases.
Arg [SPECIES]: (optional) string
By default, all databases that are found on the
server and that corresponds to the correct release
are probed for aliases etc. For some people,
depending on where they are in the world, this might
be a slow operation. With the '-species' argument,
one may reduce the startup time by restricting the
set of databases that are probed to those of a
particular species.
Note that the latin name of the species is required,
e.g., 'homo sapiens', 'gallus gallus', 'callithrix
jacchus' etc. It may be the whole species name,
or only the first part of the name, e.g. 'homo',
'gallus', or 'callithrix'. This will be used in
matching against the name of the databases.
Arg [DB_VERSION]: (optional) integer
By default, only databases corresponding to the
current API version are loaded. This argument
allows the script to use databases from another
version although it might not work properly. This
argument should only be used for production or
testing purposes and if you really know what you are
doing.
Arg [WAIT_TIMEOUT]: (optional) integer
Time in seconds for the wait timeout to happen.
Time after which the connection is deleted if not
used. By default this is 28800 (8 hours), so set
this to greater than this if your connection are
getting deleted. Only set this if you are having
problems and know what you are doing.
Arg [-NO_CACHE]: (optional) boolean
This option will turn off caching for slice features,
so, every time a set of features is retrieved, they
will come from the database instead of the cache. This
option is only recommended for advanced users, specially
if you need to store and retrieve features. It might
reduce performance when querying the database if not
used properly. If in doubt, do not use it or ask in the
developer mailing list.
Arg [SPECIES_SUFFIX]: (optional) string
This option will append the string to the species name
in the registry for all databases found on this server.
Example :
$registry->load_registry_from_db(
-host => 'ensembldb.ensembl.org',
-user => 'anonymous',
-verbose => '1'
);
Description: Will load the correct versions of the Ensembl
databases for the software release it can find on a
database instance into the registry. Also adds a set
of standard aliases.
Returntype : Int count of the DBAdaptor instances which can be found in the
registry due to this method call.
Exceptions : Thrown if the given MySQL database cannot be connected to
or there is any error whilst querying the database.
Status : Stable
_group_to_adaptor_class
Arg [1] : The group you wish to decode to an adaptor class
Example : Bio::EnsEMBL::Registry->_group_to_adaptor_class('core');
Description : Has an internal lookup of groups to their adaptor classes
Returntype : String
Exceptions : Thrown if the group is unknown
Status : Stable
find_and_add_aliases
Arg [ADAPTOR] : (optional) Bio::EnsEMBL::DBSQL::DBAdaptor
The adaptor to use to retrieve aliases from.
Arg [GROUP] : (optional) string
The group you want to find aliases for. If not
given assumes all types.
Arg [HANDLE] : (optional) DBI database handle
A connected database handle to use instead of
the database handles stored in the DBAdaptors.
Bypasses the use of MetaContainer.
Arg [SPECIES_SUFFIX]: (optional) string
This option will append the string to the species
name in the registry for all databases.
Example : Bio::EnsEMBL::Registry->find_and_add_aliases(
-ADAPTOR => $dba,
-GROUP => 'core'
);
Description : Looks in the meta container for each database for
an entry called "species.alias". If any are found
then the species adaptor is registered to that
set of aliases. This can work across any adaptor
which has a MetaContainer. If no MetaContainer
can be returned from a given adaptor then no alias
searching is performed.
Return type : none
Exceptions : Throws if an alias is found in more than one species.
Status : Stable
load_registry_from_multiple_dbs
Arg [1] : Array of hashes, each hash being a set of arguments to
load_registry_from_db() (see above).
Example :
$registry->load_registry_from_multiple_dbs( {
'-host' => 'ensembldb.ensembl.org',
'-user' => 'anonymous',
'-verbose' => '1'
},
{
'-host' => 'server.example.com',
'-user' => 'anonymouse',
'-password' => 'cheese',
'-verbose' => '1'
} );
Description: Will call load_registry_from_db() (see above)
multiple times and merge the resulting registries
into one, effectively allowing a user to connect to
databases on multiple database servers from within
one program.
If a database is found on more than one server, the
first found instance of that database will be used.
Returntype : Int count of the DBAdaptor instances which can be found in the
registry
set_default_track
Sets a flag to say that that this species/group are a default track and do not
need to be added as another web track.
Arg [1] : name of the species to get the adaptors for in the registry.
Arg [2] : name of the type to get the adaptors for in the registry.
Example : $merged = Bio::EnsEMBL::Registry->set_default_track("Human","core");
Returntype : none
Exceptions : none
Status : At Risk.
default_track
Check flag to see if this is a default track
Arg [1] : name of the species to get the adaptors for in the registry.
Arg [2] : name of the type to get the adaptors for in the registry.
Example : $merged = Bio::EnsEMBL::Registry->set_default_track("Human","core");
Returntype : int
Exceptions : none
Status : At Risk.
add_new_tracks
Will add new gene tracks to the configuration of the WEB server if they are
not of the type default and the configuration already has genes in the display.
Arg [1] : hash of the default configuration of the web page
Returntype : none
Exceptions : none
Called by : UserConfig.pm
Status : At Risk.
no_version_check
getter/setter for whether to run the version checking
Arg[0] : (optional) int
Returntype : int or undef if not set
Exceptions : none
Status : At Risk.
no_cache_warnings
Arg[0] : boolean for turning the flag on and off
Description : Turns off any warnings about not using caching in all available
adaptors.
Returntype : boolean Current status
Exceptions : None
version_check
run the database/API code version check for a DBAdaptor
Arg[0] : DBAdaptor to check
Returntype : int 1 if okay, 0 if not the same
Exceptions : none
Status : At Risk.
get_all_species
Arg [1] : String group type, such as core, or otherfeatures
Description: Method for getting all valid species names found in available
databases. This excludes the ancestral sequence databases, and
any species from a non-core database. Specifying a group allows
the list to apply to non-core database types.
Example : my @species_names = @{ $reg->get_all_species() };
Returntype : Listref of species names
get_species_and_object_type
Description: Get the species name, object type (gene, transcript,
translation, or exon etc.), and database type for a
stable ID.
Arg [1] : String stable_id
The stable ID to find species and object type for.
Arg [2] : String known_type (optional)
The type of the stable ID, if it is known.
Arg [3] : String known_species (optional)
The species, if known
Arg [4] : String known_db_type (optional)
The database type, if known
Example : my $stable_id = 'ENST00000326632';
my ( $species, $object_type, $db_type ) =
$registry->get_species_and_object_type($stable_id);
my $adaptor =
$registry->get_adaptor( $species, $db_type,
$object_type );
my $object = $adaptor->fetch_by_stable_id($stable_id);
Return type: Array consisting of the species name, object type,
and database type. The array may be empty if no
match is found.
Exceptions : none
Status : At Risk.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 1457:
Unknown directive: =head