summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.de>2010-03-16 17:35:34 +0100
committerChristoph Helma <helma@in-silico.de>2010-03-16 17:35:34 +0100
commit506952dff164c3535ece28859778260f69d748fa (patch)
treed71d895346d07ac0d31f2a2b4e76fa0742ff4eab
parenta5144cd21c5c6537d2e95e608b970e750a421986 (diff)
OWL-DL export added
-rw-r--r--application.rb17
-rw-r--r--lazar.rb29
2 files changed, 28 insertions, 18 deletions
diff --git a/application.rb b/application.rb
index b43b11f..14c4aa6 100644
--- a/application.rb
+++ b/application.rb
@@ -21,23 +21,6 @@ get '/?' do # get index of models
Model.all.collect{|m| m.uri}.join("\n") + "\n"
end
-get '/:id/?' do
- model = Model.get(params[:id])
- halt 404, "Model #{uri} not found." unless model
- accept = request.env['HTTP_ACCEPT']
- accept = "application/rdf+xml" if accept == '*/*' or accept =~ /html/ or accept == '' or accept.nil?
- case accept
- when "application/rdf+xml"
- response['Content-Type'] = 'application/rdf+xml'
- model.owl
- when /yaml/
- response['Content-Type'] = 'application/x-yaml'
- model.yaml
- else
- halt 400, "Unsupported MIME type '#{accept}'"
- end
-end
-
delete '/:id/?' do
begin
Model.get(params[:id]).destroy!
diff --git a/lazar.rb b/lazar.rb
index ae32734..51a6c20 100644
--- a/lazar.rb
+++ b/lazar.rb
@@ -38,7 +38,7 @@ class Lazar < Model
end
if (classification != nil)
- feature_uri = lazar.dependent_variable + "_lazar_prediction"
+ feature_uri = lazar.dependent_variable + "_lazar_classification"
prediction.compounds << compound_uri
prediction.features << feature_uri
prediction.data[compound_uri] = [] unless prediction.data[compound_uri]
@@ -72,6 +72,33 @@ class Lazar < Model
end
end
+ def to_owl
+ data = YAML.load(yaml)
+ owl = OpenTox::Owl.new 'Model', uri
+ owl.source = "http://github.com/helma/opentox-model"
+ #owl.algorithm = data.algorithm
+ owl.dependentVariable = data.activity_dataset_uri
+ owl.independentVariables = data.feature_dataset_uri
+ owl.rdf
+ end
+
+end
+
+get '/:id/?' do
+ model = Lazar.get(params[:id])
+ halt 404, "Model #{uri} not found." unless model
+ accept = request.env['HTTP_ACCEPT']
+ accept = "application/rdf+xml" if accept == '*/*' or accept =~ /html/ or accept == '' or accept.nil?
+ case accept
+ when "application/rdf+xml"
+ response['Content-Type'] = 'application/rdf+xml'
+ model.to_owl
+ when /yaml/
+ response['Content-Type'] = 'application/x-yaml'
+ model.yaml
+ else
+ halt 400, "Unsupported MIME type '#{accept}'"
+ end
end
post '/?' do # create model