summaryrefslogtreecommitdiff
path: root/application.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.de>2009-10-06 09:59:50 +0200
committerChristoph Helma <helma@in-silico.de>2009-10-06 09:59:50 +0200
commit1e5762d6328ba3d261a420adaeeff441cfbd5fa2 (patch)
tree8054c5fab4b29d18d4cbd13fb5716506e4551258 /application.rb
parent58a4e153cbe073e3c22a0b122326f5f5521a8bf6 (diff)
Passes tests in opentox-test
Diffstat (limited to 'application.rb')
-rw-r--r--application.rb104
1 files changed, 3 insertions, 101 deletions
diff --git a/application.rb b/application.rb
index b5d8d4e..c86fe66 100644
--- a/application.rb
+++ b/application.rb
@@ -1,103 +1,5 @@
-['rubygems', 'sinatra', 'redis', 'builder', 'opentox-ruby-api-wrapper'].each do |lib|
- require lib
-end
-
-load File.join(File.dirname(__FILE__), 'model.rb')
-
-case ENV['RACK_ENV']
-when 'production'
- @@redis = Redis.new :db => 0
-when 'development'
- @@redis = Redis.new :db => 1
-when 'test'
- @@redis = Redis.new :db => 2
- @@redis.flush_db
-end
+require 'rubygems'
+require 'opentox-ruby-api-wrapper'
+require 'lazar.rb'
set :default_content, :yaml
-
-helpers do
-
- def find
- uri = uri(params[:splat].first)
- halt 404, "Dataset \"#{uri}\" not found." unless @model = Model.find(uri)
- end
-
- def uri(name)
- uri = url_for("/model/", :full) + URI.encode(name)
- end
-end
-
-get '/algorithms' do
- url_for("/algorithm/classification", :full)
-end
-
-post '/algorithm/classification/?' do # create a model
- #halt 403,
- activity_dataset_uri = OpenTox::Dataset.find(:uri => params[:dataset_uri]).uri
- feature_dataset_uri = OpenTox::Algorithm::Fminer.create(activity_dataset_uri)
- Model.create(:activity_dataset_uri => activity_dataset_uri, :feature_dataset_uri => feature_dataset_uri).uri
-end
-
-get '/models/?' do # get index of models
- Model.find_all.join("\n")
-end
-
-get '/model/*/?' do
- #halt 404, "Model #{name} not found." unless @model = Model.find(request.url)
- find
- @model.to_yaml
-end
-
-delete '/model/*' do
- name = params[:splat].first
- halt 404, "Model #{name} not found." unless @model = Model.find(request.url)
- @model.destroy
- "Model #{params[:id]} succesfully deleted."
-end
-
-post '/model/*' do # create prediction
- name = params[:splat].first
- halt 404, "Model #{name} not found." unless @model = Model.find(request.url)
- compound = OpenTox::Compound.new :uri => params[:compound_uri]
- @model.predict(compound)
-end
-
-# PREDICTIONS
-get '/model/*/predictions?' do # get dataset URI
- name = params[:splat].first
- halt 404, "Model #{name} not found." unless @model = Model.find(request.url)
- # Dataset.find
-end
-
-get '/model/*/prediction/*' do # display prediction for a compound
- name = params[:splat].first
- compound_uri = params[:splat][1]
- halt 404, "Model #{name} not found." unless @model = Model.find(request.url)
- # prediction not found
- #prediction.to_yaml
- #xml prediction
-end
-
-get '/model/*/prediction/*/neighbors' do
- name = params[:splat].first
- compound_uri = params[:splat][1]
- halt 404, "Model #{name} not found." unless @model = Model.find(request.url)
- # prediction not found
- # prediction.neighbors
-end
-
-get '/model/*/prediction/*/features' do
- name = params[:splat].first
- compound_uri = params[:splat][1]
- halt 404, "Model #{name} not found." unless @model = Model.find(request.url)
- # prediction not found
- # prediction not found
- # prediction.features
-end
-
-delete '/model/*/prediction/*' do # display prediction for a compound
- name = params[:splat].first
- halt 404, "Model #{name} not found." unless @model = Model.find(request.url)
- # Prediction.destroy
-end