Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save rtirrell/459327 to your computer and use it in GitHub Desktop.
require "dm-core"
require "dm-timestamps"
# Note, a GSE etc could have two of the same field (i.e. Pubmed so check for that
# and make an array instead)
# child_key: set of fields identifying child model
# parent_key: set of fields identifying parent model
# GDS
# has 1 GSE
# has n GDSSubsets
# GDSSubset
# belongs_to GDS
# has n samples (GDSSubsets)
# GDSSubsetMember
# belongs_to GDSSubset
# has 1 GSM
# GSE
# # does not necessarily belong to a GDS
# has n GSMs
# GSM
# has 1 GPL
# has n measurements (
# GPL
# has n GSMs
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
# 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
has n, :gse_gsms, "GSEGSM", :child_key => [:gse], :parent_key => [:gse]
has n, :gsm_objects, "GSM", :through => :gse_gsm
has n, :_fields, "GSEField", :child_key => [:gse], :parent_key => [:gse]
end
class GSEField < GEO
storage_names[:expr_geo] = "gse"
belongs_to :gse_object, "GSE", :child_key => [:gse], :parent_key => [:gse], :key => true
property :field, String, :key => true
property :value, String
end
class GSEGSM < GEO
storage_names[:expr_geo] = "gse_gsm"
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, :_fields, "GSMField", :child_key => [:gsm], :parent_key => [:gsm]
# a sample may be associated with more than one series.
has n, :gse_gsm, "GSEGSM", :child_key => [:gsm], :parent_key => [:gsm]
has n, :gse_object, "GSE", :through => :gse_gsm
# key is apparently optional here.
# has n, :measurements, "GSMGeneData", :child_key => [:gsm],
# :parent_key => [:gsm]#, :key => true
# this is incorrect syntax.
# has n, :platforms, "GPL", :child_key => [:gsm], :parent_key => [:gsm], :through => :gsm_gpl
# parent_key should be optional?
# has n, :gsm_gpls, "GSMGPL", :child_key => [:gsm]
end
# class GSMField < GEO
# storage_names[:expr_geo] = "gsm"
#
# belongs_to :gsm_object, "GSM", :child_key => [: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