Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save rtirrell/458070 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)
# 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 GEOAnnotator
module ORM
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 => :gdsgse
end
class GDSGSE < GEO
storage_names[:expr_geo] = "gds_gse"
belongs_to :gds_object, "GDS", :child_key => [:gds],
:parent_key => [:gds], :key => true
# child_key is parent's key INTO the child, parent_key is child's key
# INTO the parent.
belongs_to :gse_object, "GSE", :child_key => [:gse],
:parent_key => [:gse]
end
class GSE < GEO
storage_names[:expr_geo] = "gse"
property :gse, Integer, :key => true
property :field, String, :key => true
property :value, String
has n, :gsms, "GSM"
end
class GSM < GEO
storage_names[:expr_geo] = "gsm"
property :gsm, Integer, :key => true
property :channel, Integer, :key => true
property :field, String, :key => true
property :value, String
has n, :measurements, "GSMGeneData"
end
class GSMGeneData < GEO
storage_names[:expr_geo] = "gsm_gene_data"
property :id, String, :key => true
property :value, Integer
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment