Skip to content

Instantly share code, notes, and snippets.

@rtirrell
Created June 30, 2010 22:00
Show Gist options
  • Select an option

  • Save rtirrell/459283 to your computer and use it in GitHub Desktop.

Select an option

Save rtirrell/459283 to your computer and use it in GitHub Desktop.
require "dm-core"
require "dm-timestamps"
module GORM
class GEO
def self.inherited(subclass)
subclass.class_eval do
include DataMapper::Resource
def self.default_repository_name; :expr_geo; end
end
end
end
class GDS < GEO
storage_names[:expr_geo] = "gds"
property :gds, Integer, :key => true
property :channel, Integer
property :gpl_organism, String
property :feature, Integer
property :pubmed, Integer
property :sample_organism, String
property :sample_type, String
property :technology, String
property :title, String
property :type, String
has 1, :gds_gse, "GDSGSE", :child_key => [:gds], :parent_key => [:gds]
has 1, :gse_object, "GSE", :through => :gds_gse
end
class GDSGSE < GEO
storage_names[:expr_geo] = "gds_gse"
belongs_to :gds_object, "GDS", :child_key => [:gds], :parent_key => [:gds], :key => true
belongs_to :gse_object, "GSE", :child_key => [:gse], :parent_key => [:gse], :key => true
end
class GSE < GEO
storage_names[:expr_geo] = "gse_list"
property :gse, Integer, :key => true
has n, :_fields, "GSEField", :child_key => [:gse], :parent_key => [:gse]
has n, :gsm_objects, "GSM", :through => :gse_gsm
# But it doesn't necessarily have either of these.
has 1, :gds_gse, "GDSGSE", :child_key => [:gse], :parent_key => [:gse]
has 1, :gds_object, "GDS", :through => :gds_gse
# def gsms
# repository.adapter.select(%Q{
# SELECT gsm FROM gse_gsm WHERE gse = ?
# }, gse)
# end
end
class GSEField < GEO
storage_names[:expr_geo] = "gse"
belongs_to :gse_object, "GSE", :child_key => [:gse], :parent_key => [:gse], :key => true
property :gse, Integer, :key => true
property :field, String, :key => true
property :value, String
end
class GSEGSM < GEO
storage_names[:expr_geo] = "gse_gsm"
# parent key: parent identifies the child by
# child key: child identifies the parent by.
# if the (only) object attribute is belongs_to, :gse_object, "GSE"
# and no key information is given, [gse, gse_object_field, gse_object_gse]
# and the parent_key is gse, [gse_object_gse]
# and the child_key is gse, [gse, gse_object_field]
# and both keys are gse, [gse]
belongs_to :gse_object, "GSE", :child_key => [:gse], :parent_key => [:gse], :key => true
belongs_to :gsm_object, "GSM", :child_key => [:gsm], :parent_key => [:gsm], :key => true
end
class GSM < GEO
storage_names[:expr_geo] = "gsm_list"
property :gsm, Integer, :key => true
has n, :attributes, "GSMField", :child_key => [:gsm], :parent_key => [:gsm]
# for has n:
# with no keys, get gsm_gsm, gsm_channel, gsm_field.
# with just child key at gsm, get [gsm, gsm_channel, gsm_field].
# with just parent key at gsm, get [gsm_gsm] (table name + field name)
# with both, get [gsm]!
has 1, :gse_gsm, "GSEGSM", :child_key => [:gsm], :parent_key => [:gsm]
# something else for parent and child key.
has 1, :gse_object, "GSE", :through => :gse_gsm
end
class GSMField < GEO
storage_names[:expr_geo] = "gsm"
belongs_to :gsm_object, "GSM", :parent_key => [:gsm], :key => true
property :channel, Integer, :key => true
property :field, String, :key => true
property :value, String
end
# class GSMGeneData < GEO
# storage_names[:expr_geo] = "gsm_gene_data"
# property :id, String, :key => true
# property :val, Integer
# end
#
# class GSMGPL < GEO
# storage_names[:expr_geo] = "gsm_gpl"
# belongs_to :gsm_object, "GSM", :child_key => [:gsm], :parent_key => [:gsm], :key => true
# belongs_to :gpl_object, "GPL", :child_key => [:gpl], :parent_key => [:gpl], :key => true
# end
#
# class GPL < GEO
# storage_names[:expr_geo] = "gpl_list"
# property :gpl, Integer, :key => true
# has n, :attributes, "GPLField", :child_key => [:gpl]
# has n, :gsm_gpls, "GSMGPL", :child_key => [:gpl], :parent_key => [:gpl]
# end
#
# class GPLField < GEO
# storage_names[:expr_geo] = "gpl"
# property :field, String, :key => true
# property :value, String, :key => true
# end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment