Created
December 10, 2010 16:31
-
-
Save balhoff/736432 to your computer and use it in GitHub Desktop.
Code for adding phenotypes and external ontology terms to mx.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddPhenotypesAndOntologyRefs < ActiveRecord::Migration | |
def self.up | |
create_table :phenotypes do |table| | |
table.string :type | |
# common Phenotype attributes | |
table.integer :entity_id # OntologyTerm or OntologyComposition | |
table.string :entity_type # OntologyTerm or OntologyComposition | |
# common CardinalPhenotype attributes (PresenceAbsence & Count) | |
table.integer :within_entity_id # OntologyTerm or OntologyComposition | |
table.string :within_entity_type # OntologyTerm or OntologyComposition | |
# attributes for type=PresenceAbsencePhenotype | |
table.boolean :is_present | |
# attributes for type=CountPhenotype | |
table.integer :minimum | |
table.integer :maximum | |
# attributes for type=QualitativePhenotype | |
table.integer :quality_id # OntologyTerm or OntologyComposition | |
table.string :quality_type # OntologyTerm or OntologyComposition | |
table.integer :dependent_entity_id # OntologyTerm or OntologyComposition | |
table.string :dependent_entity_type # OntologyTerm or OntologyComposition | |
end | |
create_table :ontology_terms do |table| | |
table.string :uri | |
table.string :label | |
table.string :bioportal_ontology_id | |
# more? | |
end | |
create_table :ontology_compositions do |table| | |
table.integer :genus_id # OntologyTerm | |
end | |
create_table :differentiae do |table| | |
table.integer :property_id # OntologyTerm | |
table.integer :value_id # OntologyTerm or OntologyComposition | |
table.string :value_type # OntologyTerm or OntologyComposition | |
table.integer :ontology_composition_id # enclosing OntologyComposition | |
end | |
end | |
def self.down | |
end | |
end | |
class Phenotype < ActiveRecord::Base | |
belongs_to :entity, :polymorphic => true | |
end | |
class CardinalPhenotype < Phenotype | |
belongs_to :within_entity, :polymorphic => true | |
end | |
class PresenceAbsencePhenotype < CardinalPhenotype | |
end | |
class CountPhenotype < CardinalPhenotype | |
end | |
class QualitativePhenotype < Phenotype | |
belongs_to :quality, :polymorphic => true | |
belongs_to :dependent_entity, :polymorphic => true | |
end | |
class OntologyTerm < ActiveRecord::Base | |
end | |
class OntologyComposition < ActiveRecord::Base | |
belongs_to :genus, :class_name => "OntologyTerm" | |
has_many :differentiae | |
end | |
class OntologyTerm < ActiveRecord::Base | |
belongs_to :property, :class_name => "OntologyTerm" | |
belongs_to :value, :polymorphic => true | |
belongs_to :ontology_composition | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment