Saturday, June 23, 2007

Mapping Agilent Microarray ID to Affymetrix GeneChip using ActiveRecord

First, I make ActiveRecord model script (ensembl.rb) for Agilentprobe
table in EnsemblMart.


#!/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 <>

Next, I make ID translation program (
affyprobe2moe4302.rb) using above script.

#!/usr/bin/env ruby

require 'ensembl'
agilentid = 'A_52_P654624'
agilentprobe = Agilentprobe.find_by_dbprimary_id('A_52_P654624')
moe4302 = Moe4302.find_all_by_gene_id_key(agilentprobe.gene_id_key)
moe4302.each do |entry|
puts [aglentid,
entry.gene_stable_id, entry.transcript_stable_id, entry.translation_stable_id,
entry.dbprimary_id].join("\t")
end
Let's run it!

$ ruby affyprobe2moe4302.rb
A_52_P654624    ENSMUSG00000058140      ENSMUST00000081249      ENSMUSP00000080006      1429452_x_at
A_52_P654624 ENSMUSG00000058140 ENSMUST00000081249 ENSMUSP00000080006 1435353_a_at
A_52_P654624 ENSMUSG00000058140 ENSMUST00000071829 ENSMUSP00000071732 1429452_x_at

No comments: