Class: Ensembl::Core::Collection

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

Overview

Class to describe and handle multi-species databases

Class Method Summary collapse

Class Method Details

.checkBoolean

Method to check if the current core database is a multi-species db. Returns a boolean value.

Returns:

  • (Boolean)

    True if current db is multi-species db; otherwise false.



20
21
22
23
24
25
26
# File 'lib/ensembl/core/collection.rb', line 20

def self.check()
  host,user,password,db_name,port = Ensembl::Core::DBConnection.get_info
  if db_name =~/(\w+)_collection_core_.*/ 
    return true
  end
  return false
end

.find_all_coord_by_table_name(table_name, species_id) ⇒ Array<Integer>

Returns an array with all the coord_system_id associated with a particular species and a table_name. Used inside Slice#method_missing to filter the coord_system_id using a particular species_id.

Parameters:

  • table_name (String)

    Table name

  • species_id (Integer)

    ID of species in the database

Returns:

  • (Array<Integer>)

    Array containing coord_system IDs.



55
56
57
58
# File 'lib/ensembl/core/collection.rb', line 55

def self.find_all_coord_by_table_name(table_name,species_id)
  all_ids = CoordSystem.find_all_by_species_id(species_id)
  return MetaCoord.find_all_by_coord_system_id_and_table_name(all_ids,table_name)
end

.get_species_id(species) ⇒ Integer

Returns the species_id of a particular species present in the database.

Parameters:

  • species (String)

    Name of species

Returns:

  • (Integer)

    Species ID in the database.



39
40
41
42
43
44
45
46
47
# File 'lib/ensembl/core/collection.rb', line 39

def self.get_species_id(species)
  species = species.downcase
  meta = Meta.find_by_sql("SELECT * FROM meta WHERE LOWER(meta_value) = '#{species}'")[0]
  if meta.nil?
    return nil
  else
    return meta.species_id
  end
end

.speciesArray<String>

Returns an array with all the Species present in a collection database.

Returns:

  • (Array<String>)

    Array containing species names in colleciton



31
32
33
# File 'lib/ensembl/core/collection.rb', line 31

def self.species()
  return Meta.find_all_by_meta_key("species.db_name").collect {|m| m.meta_value}
end