3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
6 Licensed under the Apache License, Version 2.0 (the
"License");
7 you may not use
this file except in compliance with the License.
8 You may obtain a copy of the License at
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an
"AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License
for the specific language governing permissions and
16 limitations under the License.
23 Please email comments or questions to the
public Ensembl
24 developers list at <http:
26 Questions may also be sent to the Ensembl help desk at
39 my $csa = $db->get_CoordSystemAdaptor();
42 # Get all coord systems in the database:
44 foreach my $cs ( @{ $csa->fetch_all() } ) {
45 my $str = join
':', $cs->name(), $cs->version(), $cs->dbID();
51 This is a simple
object which contains a few coordinate system attributes:
52 name,
internal identifier, version. A coordinate system is uniquely defined
53 by its name and version. A version of a coordinate system applies to all
54 sequences within a coordinate system. This should not be confused with
55 individual sequence versions.
57 Take
for example the Human assembly. The version
'NCBI33' applies to
58 to all chromosomes in the NCBI33 assembly (that is the entire
'chromosome'
59 coordinate system). The
'clone' coordinate system in the same database would
60 have no version however. Although the clone sequences have their own sequence
61 versions, there is no version which applies to the entire set of clones.
63 Coordinate system objects are immutable. Their name and version, and other
64 attributes may not be altered after they are created.
74 package Bio::EnsEMBL::CoordSystem;
88 Arg [..] : List of named arguments:
89 -NAME - The name of the coordinate system
90 -VERSION - (optional) The version of the coordinate system.
91 Note that
if the version passed in is undefined,
92 it will be set to the empty
string in the
93 resulting CoordSystem
object.
94 -RANK - The rank of the coordinate system. The highest
95 level coordinate system should have rank 1, the
96 second highest rank 2 and so on. An example of
97 a high level coordinate system is
'chromosome' an
98 example of a lower level coordinate system is
100 -TOP_LEVEL - (optional) Sets whether
this is a top-level coord
101 system. Default = 0. This should only be set to
102 true if you are creating an artificial toplevel
103 coordsystem by the name of
'toplevel'
104 -SEQUENCE_LEVEL - (optional) Sets whether
this is a sequence
105 level coordinate system. Default = 0
106 -DEFAULT - (optional)
107 Whether
this is the
default version of the
108 coordinate systems of
this name. Default = 0
109 -DBID - (optional) The
internal identifier of
this
111 -ADAPTOR - (optional) The adaptor which provides database
112 interaction
for this object
113 -ALIAS_TO - (optional) Sets an alias
for a coordsystem. If set
114 it should only be set to
'chromosome'
116 -VERSION =>
'NCBI33',
121 -SEQUENCE_LEVEL => 0);
122 Description: Creates a
new CoordSystem
object representing a coordinate
133 my $class = ref($caller) || $caller;
135 my $self = $class->SUPER::new(@_);
137 my ( $name, $version, $top_level, $sequence_level, $default, $rank, $alias_to ) =
138 rearrange( [
'NAME',
'VERSION',
139 'TOP_LEVEL',
'SEQUENCE_LEVEL',
144 $top_level = ($top_level) ? 1 : 0;
145 $sequence_level = ($sequence_level) ? 1 : 0;
146 $default = ($default) ? 1 : 0;
149 if ( $top_level == 1 ) {
151 throw(
'RANK argument must be 0 if TOP_LEVEL is 1');
154 if ( defined($name) ) {
155 if ( $name ne
'toplevel' ) {
156 throw(
'The NAME argument must be "toplevel" if TOP_LEVEL is 1');
162 if ( $sequence_level == 1 ) {
163 throw(
"SEQUENCE_LEVEL argument must be 0 if TOP_LEVEL is 1");
171 throw(
"RANK argument must be non-zero unless TOP_LEVEL is 1");
174 if ( !defined($name) ) {
175 throw(
'The NAME argument is required');
176 } elsif ( $name eq
'toplevel' ) {
177 throw(
"Cannot name coord system 'toplevel' "
178 .
"unless TOP_LEVEL is 1" );
183 if ( $rank !~ /^\d+$/ ) {
184 throw(
'The RANK argument must be a positive integer');
187 if ( defined($alias_to) ) {
188 throw(
"The ALIAS_TO argument can only be defined as 'chromosome'") unless $alias_to eq
"chromosome";
191 $self->{
'version'} = $version;
192 $self->{
'name'} = $name;
193 $self->{
'top_level'} = $top_level;
194 $self->{
'sequence_level'} = $sequence_level;
195 $self->{
'default'} = $default;
196 $self->{
'rank'} = $rank;
197 $self->{
'alias_to'} = $alias_to;
205 Arg [1] : (optional)
string $name
206 Example : print $coord_system->name();
207 Description: Getter
for the name of
this coordinate system
217 return $self->{
'name'};
225 Example : print $coord->version();
226 Description: Getter
for the version of
this coordinate system. This
227 will
return an empty
string if no version is defined
for this
239 return '' unless defined $self->{
'version'};
240 return $self->{
'version'};
248 Example : print $coord->species();
249 Description: Shortcut method to get the species
this CoordSystem refers to.
259 return $self->adaptor->db->species;
267 The coord system to
compare to
for equality.
268 Example :
if($coord_sys->equals($other_coord_sys)) { ... }
269 Description: Compares 2 coordinate systems and returns
true if they are
270 equivalent. The definition of equivalent is sharing the same
283 if(!$cs || !ref($cs) || !$cs->isa(
'Bio::EnsEMBL::CoordSystem')) {
284 if ($cs->isa(
'Bio::EnsEMBL::ExternalData::DAS::CoordSystem')) {
285 return $cs->equals($self);
287 throw(
'Argument must be a CoordSystem');
290 if($self->version() eq $cs->version() && $self->{
'name'} eq $cs->name()) {
303 Example :
if($coord_sys->is_top_level()) { ... }
304 Description: Returns
true if this is the toplevel pseudo coordinate system.
305 The toplevel coordinate system is not a real coordinate system
306 which is stored in the database, but it is a placeholder that
307 can be used to request transformations or retrievals to/from
308 the highest defined coordinate system in a given region.
318 return $self->{
'top_level'};
322 =head2 is_sequence_level
325 Example :
if($coord_sys->is_sequence_level()) { ... }
326 Description: Returns
true if this is a sequence level coordinate system
334 sub is_sequence_level {
336 return $self->{
'sequence_level'};
343 Example :
if($coord_sys->is_default()) { ... }
344 Description: Returns
true if this coordinate system is the
default
345 version of the coordinate system of
this name.
355 return $self->{
'default'};
364 Example :
if($cs1->rank() < $cs2->rank()) {
365 print $cs1->name(),
" is a higher level coord system than",
368 Description: Returns the rank of
this coordinate system. A lower number
369 is a higher coordinate system. The highest level coordinate
370 system has a rank of 1 (e.g.
'chromosome'). The toplevel
371 pseudo coordinate system has a rank of 0.
381 return $self->{
'rank'};
389 Example : $coord->alias_to(
'chromosome');
390 Description: Getter/Setter
for the alias of
this coordinate system.
399 my ($self, $alias_to) = @_;
400 if (defined($alias_to)) {
401 throw(
"The alias can only be set to 'chromosome'") unless $alias_to eq
"chromosome";
403 $self->{
'alias_to'} = $alias_to
if defined $alias_to;
404 return $self->{
'alias_to'};