Class Ensembl::Core::DBConnection
In: lib/ensembl/db_connection.rb
Parent: ActiveRecord::Base

DESCRIPTION

The Ensembl::Core::DBConnection is the actual connection established with the Ensembl server.

Methods

connect  

Public Class methods

DESCRIPTION

The Ensembl::Core::DBConnection#connect method makes the connection to the Ensembl core database for a given species. By default, it connects to release 50 for that species. You could use a lower number, but some parts of the API might not work, or worse: give the wrong results.

USAGE

 # Connect to release 50 of human
 Ensembl::Core::DBConnection.connect('homo_sapiens')

 # Connect to release 42 of chicken
 Ensembl::Core::DBConnection.connect('gallus_gallus')

Arguments:

  • species:: species to connect to. Arguments should be in snake_case
  • ensembl_release:: the release of the database to connect to
 (default = 50)

[Source]

    # File lib/ensembl/db_connection.rb, line 62
62:       def self.connect(species, release = Ensembl::ENSEMBL_RELEASE, args = {})
63:         dummy_dbconnection = ( release > 47 ) ? Ensembl::NewDummyDBConnection.connection : Ensembl::OldDummyDBConnection.connection
64:         db_name = nil
65:         
66:         if args[:database]
67:           db_name = args[:database]
68:         else  
69:           db_name = dummy_dbconnection.select_values('show databases').select{|v| v =~ /#{species}_core_#{release.to_s}/}[0]
70:         end
71: 
72:         if db_name.nil?
73:           warn "WARNING: No connection to database established. Check that the species is in snake_case (was: #{species})."
74:         else
75:           port = ( release > 47 ) ? 5306 : nil
76:           establish_connection(
77:                               :adapter => args[:adapter] || Ensembl::DB_ADAPTER,
78:                               :host => args[:host] || Ensembl::DB_HOST,
79:                               :database => args[:database] || db_name,
80:                               :username => args[:username] || Ensembl::DB_USERNAME,
81:                               :password => args[:password] || Ensembl::DB_PASSWORD,
82:                               :port => args[:port] || port
83:                             ) 
84:           self.retrieve_connection                                                       
85:         end
86:         
87:       end

[Validate]