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

DESCRIPTION

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

Methods

connect  

Public Class methods

DESCRIPTION

The Ensembl::Variation::DBConnection#connect method makes the connection to the Ensembl variation 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::Variation::DBConnection.connect('homo_sapiens')

 # Connect to release 42 of chicken
 Ensembl::Variation::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 119
119:       def self.connect(species, release = Ensembl::ENSEMBL_RELEASE, args = {})
120:         dummy_dbconnection = ( release > 47 ) ? Ensembl::NewDummyDBConnection.connection : Ensembl::OldDummyDBConnection.connection
121:         db_name = nil
122:         if args[:database]
123:           db_name = args[:database]
124:         else  
125:           db_name = dummy_dbconnection.select_values('show databases').select{|v| v =~ /#{species}_variation_#{release.to_s}/}[0]
126:         end
127:         
128:         if db_name.nil?
129:           warn "WARNING: No connection to database established. Check that the species is in snake_case (was: #{species})."
130:         else
131:           port = ( release > 47 ) ? 5306 : nil
132:           establish_connection(
133:                               :adapter => Ensembl::DB_ADAPTER,
134:                               :host => args[:host] || Ensembl::DB_HOST,
135:                               :database => db_name,
136:                               :username => args[:username] || Ensembl::DB_USERNAME,
137:                               :password => args[:password] || Ensembl::DB_PASSWORD,
138:                               :port => args[:port] || port
139:                             )
140:           self.retrieve_connection                                                                                                                             
141:         end
142:         
143:       end

[Validate]