Class: Ensembl::Core::CoordSystem

Inherits:
DBConnection
  • Object
show all
Defined in:
lib/ensembl/core/activerecord.rb

Overview

DESCRIPTION

The CoordSystem class describes the coordinate system to which a given SeqRegion belongs. It is an interface to the coord_system table of the Ensembl mysql database.

Two virtual coordinate systems exist for every species:

  • toplevel: the coordinate system with rank 1

  • seqlevel: the coordinate system that contains the seq_regions

with the sequence

This class uses ActiveRecord to access data in the Ensembl database. See the general documentation of the Ensembl module for more information on what this means and what methods are available.

USAGE

coord_system = Ensembl::Core::CoordSystem.find_by_name('chromosome')
if coord_system == CoordSystem.toplevel
puts coord_system.name + " is the toplevel coordinate system."
end

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DBConnection

connect

Class Method Details

.find_default_by_name(name) ⇒ Object

DESCRIPTION

The CoordSystem#find_default_by_name class method returns the coordinate system by that name with the lowest rank. Normally, a lower rank means a ‘bigger’ coordinate system. The ‘chromosome’ typically has rank 1. However, there might be more than one coordinate system with the name chromosome but with different version (e.g. in human, there is one for the NCBI36 and one for the NCBI35 version). The older version of these is typically given a high number and the one with the new version is the ‘default’ system.


Arguments

none

Returns

CoordSystem object



277
278
279
280
281
282
283
284
# File 'lib/ensembl/core/activerecord.rb', line 277

def self.find_default_by_name(name)
  all_coord_systems_with_name = Ensembl::Core::CoordSystem.find_all_by_name(name)
  if all_coord_systems_with_name.length == 1
    return all_coord_systems_with_name[0]
  else
    return all_coord_systems_with_name.select{|cs| cs.attrib =~ /default_version/}[0]
  end
end

.find_seqlevelObject

DESCRIPTION

The CoordSystem#find_seqlevel class method returns the seqlevel coordinate system.


Arguments

none

Returns

CoordSystem object



261
262
263
# File 'lib/ensembl/core/activerecord.rb', line 261

def self.find_seqlevel
  return CoordSystem.find_by_sql("SELECT * FROM coord_system WHERE attrib LIKE '%sequence_level%'")[0]
end

.find_toplevelObject

DESCRIPTION

The CoordSystem#find_toplevel class method returns the toplevel coordinate system.


Arguments

none

Returns

CoordSystem object



251
252
253
# File 'lib/ensembl/core/activerecord.rb', line 251

def self.find_toplevel
  return CoordSystem.find_by_rank(1)
end

Instance Method Details

#name_with_versionObject

DESCRIPTION

The CoordSystem#name_with_version returns a string containing the name and version of the coordinate system. If no version is available, then just the name is returned


Arguments

none

Returns

String object



293
294
295
296
297
298
299
# File 'lib/ensembl/core/activerecord.rb', line 293

def name_with_version
  if self.version.nil?
    return name
  else
    return [name, version].join(':')
  end
end

#seqlevel?Boolean

DESCRIPTION

The CoordSystem#seqlevel? method checks if this coordinate system is the seqlevel coordinate system or not.


Arguments

none

Returns

TRUE or FALSE

Returns:

  • (Boolean)


237
238
239
240
241
242
243
# File 'lib/ensembl/core/activerecord.rb', line 237

def seqlevel?
  if self == CoordSystem.find_by_sql("SELECT * FROM coord_system WHERE attrib LIKE '%sequence_level%'")[0]
    return true
  else
    return false
  end
end

#toplevel?Boolean

DESCRIPTION

The CoordSystem#toplevel? method checks if this coordinate system is the toplevel coordinate system or not.


Arguments

none

Returns

TRUE or FALSE

Returns:

  • (Boolean)


223
224
225
226
227
228
229
# File 'lib/ensembl/core/activerecord.rb', line 223

def toplevel?
  if self == CoordSystem.find_by_rank(1)
    return true
  else
    return false
  end
end