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::DBSQL::CoordSystemAdaptor
SYNOPSIS
use Bio::EnsEMBL::Registry;
Bio::EnsEMBL::Registry->load_registry_from_db(
-host => 'ensembldb.ensembl.org',
-user => 'anonymous'
);
$csa = Bio::EnsEMBL::Registry->get_adaptor( "human", "core",
"coordsystem" );
#
# Get all coord systems in the database:
#
foreach my $cs ( @{ $csa->fetch_all() } ) {
print $cs->name, ' ', $cs->version, "\n";
}
#
# Fetching by name:
#
# use the default version of coord_system 'chromosome' (e.g. NCBI33):
$cs = $csa->fetch_by_name('chromosome');
# get an explicit version of coord_system 'chromosome':
$cs = $csa->fetch_by_name( 'chromsome', 'NCBI34' );
# get all coord_systems of name 'chromosome':
foreach $cs ( @{ $csa->fetch_all_by_name('chromosome') } ) {
print $cs->name, ' ', $cs->version, "\n";
}
#
# Fetching by rank:
#
$cs = $csa->fetch_by_rank(2);
#
# Fetching the pseudo coord system 'toplevel'
#
# Get the default top_level coord system:
$cs = $csa->fetch_top_level();
# can also use an alias in fetch_by_name:
$cs = $csa->fetch_by_name('toplevel');
# can also request toplevel using rank=0
$cs = $csa->fetch_by_rank(0);
#
# Fetching by sequence level:
#
# Get the coord system which is used to store sequence:
$cs = $csa->fetch_sequence_level();
# can also use an alias in fetch_by_name:
$cs = $csa->fetch_by_name('seqlevel');
#
# Fetching by id
#
$cs = $csa->fetch_by_dbID(1);
DESCRIPTION
This adaptor allows the querying of information from the coordinate system adaptor.
Note that many coordinate systems do not have a concept of a version for the entire coordinate system (though they may have a per-sequence version). The 'chromosome' coordinate system usually has a version (i.e. the assembly version) but the clonal coordinate system does not (despite having individual sequence versions). In the case where a coordinate system does not have a version an empty string ('') is used instead.
METHODS
new
Arg [1] : See BaseAdaptor for arguments (none specific to this
subclass)
Example : $cs = $db->get_CoordSystemAdaptor(); #better than new()
Description: Creates a new CoordSystem adaptor and caches the contents
of the coord_system table in memory.
Returntype : Bio::EnsEMBL::DBSQL::CoordSystemAdaptor
Exceptions : none
Caller :
Status : Stable
fetch_all
Arg [1] : none
Example : foreach my $cs (@{$csa->fetch_all()}) {
print $cs->name(), ' ', $cs->version(), "\n";
}
Description: Retrieves every coordinate system defined in the DB.
These will be returned in ascending order of rank. I.e.
The highest coordinate system with rank=1 would be first in the
array.
Returntype : listref of Bio::EnsEMBL::CoordSystems
Exceptions : none
Caller : general
Status : Stable
fetch_by_rank
Arg [1] : int $rank
Example : my $cs = $coord_sys_adaptor->fetch_by_rank(1);
Description: Retrieves a CoordinateSystem via its rank. 0 is a special
rank reserved for the pseudo coordinate system 'toplevel'.
undef is returned if no coordinate system of the specified rank
exists.
Returntype : Bio::EnsEMBL::CoordSystem
Exceptions : none
Caller : general
Status : Stable
fetch_by_name
Arg [1] : string $name
The name of the coordinate system to retrieve. Alternatively
this may be an alias for a real coordinate system. Valid
aliases are 'toplevel' and 'seqlevel'.
Arg [2] : string $version (optional)
The version of the coordinate system to retrieve. If not
specified the default version will be used.
Example : $coord_sys = $csa->fetch_by_name('clone');
$coord_sys = $csa->fetch_by_name('chromosome', 'NCBI33');
# toplevel is an pseudo coord system representing the highest
# coord system in a given region
# such as the chromosome coordinate system
$coord_sys = $csa->fetch_by_name('toplevel');
#seqlevel is an alias for the sequence level coordinate system
#such as the clone or contig coordinate system
$coord_sys = $csa->fetch_by_name('seqlevel');
Description: Retrieves a coordinate system by its name
Returntype : Bio::EnsEMBL::CoordSystem
Exceptions : throw if no name argument provided
warning if no version provided and default does not exist
Caller : general
Status : Stable
fetch_all_by_name
Arg [1] : string $name
The name of the coordinate system to retrieve. This can be
the name of an actual coordinate system or an alias for a
coordinate system. Valid aliases are 'toplevel' and 'seqlevel'.
Example : foreach my $cs (@{$csa->fetch_all_by_name('chromosome')}){
print $cs->name(), ' ', $cs->version();
}
Description: Retrieves all coordinate systems of a particular name
Returntype : listref of Bio::EnsEMBL::CoordSystem objects
Exceptions : throw if no name argument provided
Caller : general
Status : Stable
fetch_all_by_version
Arg [1] : string $version
The version of the coordinate systems to retrieve.
Example : foreach my $cs (@{$csa->fetch_all_by_version('GRCh37')}){
print $cs->name(), ' ', $cs->version();
}
Description: Retrieves all coordinate systems of a particular version
Returntype : ArrayRef of Bio::EnsEMBL::CoordSystem objects
Exceptions : throw if no name argument provided
Caller : general
Status : Stable
fetch_by_dbID
Arg [1] : int dbID
Example : $cs = $csa->fetch_by_dbID(4);
Description: Retrieves a coord_system via its internal
identifier, or undef if no coordinate system with the provided
id exists.
Returntype : Bio::EnsEMBL::CoordSystem or undef
Exceptions : thrown if no coord_system exists for specified dbID
Caller : general
Status : Stable
fetch_top_level
Arg [1] : none
Example : $cs = $csa->fetch_top_level();
Description: Retrieves the toplevel pseudo coordinate system.
Returntype : Bio::EnsEMBL::CoordSystem object
Exceptions : none
Caller : general
Status : Stable
fetch_sequence_level
Arg [1] : none
Example : ($id, $name, $version) = $csa->fetch_sequence_level();
Description: Retrieves the coordinate system at which sequence
is stored at.
Returntype : Bio::EnsEMBL::CoordSystem
Exceptions : throw if no sequence_level coord system exists at all
throw if multiple sequence_level coord systems exists
Caller : general
Status : Stable
get_default_version
Arg [1] : none
Example : $version = $csa->get_default_version();
Description: Retrieves the default version of the assembly
Returntype : String
Exceptions : throw if no default version is defined
Caller : general
Status : Stable
get_all_versions
Arg [1] : none
Example : @versions = $csa->get_all_versions();
Description: Retrieves all the available versions of assemblies
Returntype : Listref of versions (strings)
Exceptions : throw if no version is defined
Caller : general
Status : Stable
get_mapping_path
Arg [1] : Bio::EnsEMBL::CoordSystem $cs1
Arg [2] : Bio::EnsEMBL::CoordSystem $cs2
Example : foreach my $cs @{$csa->get_mapping_path($cs1,$cs2);
Description: Given two coordinate systems this will return a mapping path
between them if one has been defined. Allowed Mapping paths are
explicitly defined in the meta table. The following is an
example:
mysql> select * from meta where meta_key = 'assembly.mapping';
+---------+------------------+--------------------------------------+
| meta_id | meta_key | meta_value |
+---------+------------------+--------------------------------------+
| 20 | assembly.mapping | chromosome:NCBI34|contig |
| 21 | assembly.mapping | clone|contig |
| 22 | assembly.mapping | supercontig|contig |
| 23 | assembly.mapping | chromosome:NCBI34|contig|clone |
| 24 | assembly.mapping | chromosome:NCBI34|contig|supercontig |
| 25 | assembly.mapping | supercontig|contig|clone |
+---------+------------------+--------------------------------------+
For a one-step mapping path to be valid there needs to be
a relationship between the two coordinate systems defined in
the assembly table. Two step mapping paths work by building
on the one-step mapping paths which are already defined.
The first coordinate system in a one step mapping path must
be the assembled coordinate system and the second must be
the component.
Example of use:
my $cs1 = $cs_adaptor->fetch_by_name('contig');
my $cs2 = $cs_adaptor->fetch_by_name('chromosome');
my @path = @{$cs_adaptor->get_mapping_path($cs1,$cs2)};
if(!@path) {
print "No mapping path.";
}
elsif(@path == 2) {
print "2 step mapping path.";
print "Assembled = " . $path[0]->name() . "\n";
print "Component = " . $path[1]->name() . "\n";
} else {
print "Multi step mapping path\n";
}
Returntype : reference to a list of Bio::EnsEMBL::CoordSystem objects
Exceptions : none
Caller : general
Status : Stable
store_mapping_path
Arg [1] : Bio::EnsEMBL::CoordSystem $cs1
Arg [2] : Bio::EnsEMBL::CoordSystem $cs2
Arg [3..n] : Bio::EnsEMBL::CoordSystem $cs3..$csN
Example : my $pathref = $csa->store_mapping_path($cs1,$cs2);
Description: Given two or more coordinate systems this will store
mapping paths between them in the database.
For example, if $cs1 represents chrs of version
V1, $cs2 represents contigs, and $cs3 clones then, unless
they already exist, the following entries will be created
in the meta table;
+------------------+---------------------+
| meta_key | meta_value |
+------------------+---------------------+
| assembly.mapping | chr:V1|clone |
| assembly.mapping | clone|contig |
| assembly.mapping | chr:V1|clone|contig |
+------------------+---------------------+
For a one-step mapping path to be valid there needs to be
a relationship between the two coordinate systems defined in
the assembly table. Two step mapping paths work by building
on the one-step mapping paths which are already defined.
The first coordinate system in a one step mapping path must
be the assembled coordinate system and the second must be
the component.
Returntype : reference to a list of lists of new meta_value mapping strings
created for assembly.mapping
Exceptions : CoordSystems with no rank/duplicated rank
Caller : general
Status : Experimental
store_multiple_mapping_path
Arg [1] : Bio::EnsEMBL::CoordSystem $cs1
Arg [2] : Bio::EnsEMBL::CoordSystem $cs2
Arg [3..n] : Bio::EnsEMBL::CoordSystem $cs3..$csN
Example : my $pathref = $csa->store_multiple_mapping_path($cs1,$cs2);
Description: Given two or more coordinate systems this will store
multiple mapping paths between them in the database.
Works similarly to the store_mapping_path method
But will presume every coord system can be mapped in multiple
ways to the other coord systems
This is represented by the use of '#' instead of '|'
in the mapping key
Returntype : reference to a list of lists of new meta_value mapping strings
created for assembly.mapping
Exceptions : CoordSystems with no rank/duplicated rank
Caller : general
Status : Experimental
fetch_by_attrib
Arg [1] : string attrib
Arg [2] : (optional) string version
Example : $csa->fetch_by_attrib('default_version','NCBIM37');
Description: Retrieves a CoordSystem object from the database that have the specified
attrib and version, if no version is specified, returns the default version
Returntype : Bio::EnsEMBL::CoordSystem object
Exceptions : throw when attrib not present
Caller : general
Status : Stable
fetch_all_by_attrib
Arg [1] : string attrib
Example : $csa->fetch_all_by_attrib('default_version');
Description: Retrieves all CoordSystem object from the database that have the specified
attrib.
Returntype : reference to a list of Bio::EnsEMBL::CoordSystem objects
Exceptions : throw when attrib not present
Caller : general
Status : Stable
store
Arg [1] : Bio::EnsEMBL::CoordSystem
Example : $csa->store($coord_system);
Description: Stores a CoordSystem object in the database.
Returntype : none
Exceptions : Warning if CoordSystem is already stored in this database.
Caller : none
Status : Stable
remove
Arg [1] : Bio::EnsEMBL::CoordSystem
Example : $csa->remove($coord_system);
Description: Removes a CoordSystem object from the database.
Returntype : none
Exceptions : Warning if CoordSystem is not stored in this database.
Caller : none
Status : Stable