Saturday, June 23, 2007

Modeling Ensembl Mart using ActiveRecord

First, I make a Ruby script for modeling ensembl mart.

#!/usr/bin/env ruby

require 'rubygems'
require_gem 'activerecord'

ActiveRecord::Base.pluralize_table_names = false

ActiveRecord::Base.establish_connection(
:adapter => 'mysql',
:database => 'ensembl_mart_40',
:host => 'ensembldb.ensembl.org',
:username => 'anonymous',
:password => ''
)

class
Agilentprobe < ActiveRecord::Base
set_table_name "
mmusculus_gene_ensembl__xref_agilentprobe__dm"
set_primary_key "gene_id_key"
end


Second, I make a searching program for Agilentprobe talbe in
Ensembl Mart using above modeling code.

#!/usr/bin/env ruby

require '
ensembl'

agilentprobe = Agilentprobe.find_by_dbprimary_id('A_52_P654624')

puts
agilentprobe.dbprimary_id
puts
agilentprobe.gene_id_key
puts
agilentprobe.gene_stable_id
puts
agilentprobe.transcript_id_key
puts
agilentprobe.transcript_stable_id
puts
agilentprobe.translation_id

Let's run it!

$ ruby run_
ensembl.rb
A_52_P654624
209556
ENSMUSG00000058140
263491
ENSMUST00000081249
251942
ENSMUSP00000080006

1 comment:

Louisa said...

Well written article.