Created
February 18, 2011 16:26
-
-
Save balhoff/833914 to your computer and use it in GitHub Desktop.
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
require 'rubygems' | |
require 'rdf' | |
require 'rdf/rdfxml' | |
# Phenotype1 == (has_part some (leg and has_part min 10 seta and has_part max 30 seta)) | |
graph = RDF::Graph.new | |
has_part = RDF::URI.new("http://example.org/has_part") | |
graph << RDF::Statement.new(has_part, RDF.type, RDF::OWL.ObjectProperty) | |
leg = RDF::URI.new("http://example.org/leg") | |
graph << RDF::Statement.new(leg, RDF.type, RDF::OWL.Class) | |
seta = RDF::URI.new("http://example.org/seta") | |
graph << RDF::Statement.new(seta, RDF.type, RDF::OWL.Class) | |
has_min_10_seta = RDF::Node.new | |
graph << RDF::Statement.new(has_min_10_seta, RDF.type, RDF::OWL.Class) | |
graph << RDF::Statement.new(has_min_10_seta, RDF.type, RDF::OWL.Restriction) | |
graph << RDF::Statement.new(has_min_10_seta, RDF::OWL.onClass, seta) | |
graph << RDF::Statement.new(has_min_10_seta, RDF::OWL.onProperty, has_part) | |
graph << RDF::Statement.new(has_min_10_seta, RDF::OWL.minQualifiedCardinality, 10) | |
has_max_30_seta = RDF::Node.new | |
graph << RDF::Statement.new(has_max_30_seta, RDF.type, RDF::OWL.Class) | |
graph << RDF::Statement.new(has_max_30_seta, RDF.type, RDF::OWL.Restriction) | |
graph << RDF::Statement.new(has_max_30_seta, RDF::OWL.onClass, seta) | |
graph << RDF::Statement.new(has_max_30_seta, RDF::OWL.onProperty, has_part) | |
graph << RDF::Statement.new(has_max_30_seta, RDF::OWL.maxQualifiedCardinality, 30) | |
leg_with_between_10_and_30_seta = RDF::Node.new | |
graph << RDF::Statement.new(leg_with_between_10_and_30_seta, RDF.type, RDF::OWL.Class) | |
leg_with_between_10_and_30_seta_members = RDF::List[leg, has_min_10_seta, has_max_30_seta] | |
graph.insert *(leg_with_between_10_and_30_seta_members.statements.to_a) | |
graph << RDF::Statement.new(leg_with_between_10_and_30_seta, RDF::OWL.intersectionOf, leg_with_between_10_and_30_seta_members.subject) | |
has_leg_with_between_10_and_30_seta = RDF::Node.new | |
graph << RDF::Statement.new(has_leg_with_between_10_and_30_seta, RDF.type, RDF::OWL.Class) | |
graph << RDF::Statement.new(has_leg_with_between_10_and_30_seta, RDF.type, RDF::OWL.Restriction) | |
graph << RDF::Statement.new(has_leg_with_between_10_and_30_seta, RDF::OWL.onProperty, has_part) | |
graph << RDF::Statement.new(has_leg_with_between_10_and_30_seta, RDF::OWL.someValuesFrom, leg_with_between_10_and_30_seta) | |
phenotype1 = RDF::URI.new("http://example.org/phenotype1") | |
graph << RDF::Statement.new(phenotype1, RDF.type, RDF::OWL.Class) | |
state = RDF::URI.new("http://example.org/state") | |
graph << RDF::Statement.new(state, RDF.type, RDF::OWL.Class) | |
state1 = RDF::URI.new("http://example.org/state1") | |
graph << RDF::Statement.new(state1, RDF.type, state) | |
graph << RDF::Statement.new(state1, RDF::RDFS.label, "leg has more than 10 and less than 30 setae") | |
describes_state = RDF::URI.new("http://example.org/describe_state") | |
graph << RDF::Statement.new(describes_state, RDF.type, RDF::OWL.AnnotationProperty) | |
graph << RDF::Statement.new(phenotype1, describes_state, state1) | |
graph << RDF::Statement.new(phenotype1, RDF::OWL.equivalentClass, has_leg_with_between_10_and_30_seta) | |
#rdf = RDF::Writer.for(:ntriples).buffer {|writer| writer << graph } | |
rdf = RDF::RDFXML::Writer.buffer {|writer| writer << graph } | |
puts rdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment