summaryrefslogtreecommitdiff
path: root/application.rb
diff options
context:
space:
mode:
Diffstat (limited to 'application.rb')
-rw-r--r--application.rb61
1 files changed, 61 insertions, 0 deletions
diff --git a/application.rb b/application.rb
index aa88ecb..51ce621 100644
--- a/application.rb
+++ b/application.rb
@@ -1,7 +1,19 @@
+ENV["JAVA_HOME"] = "/usr/lib/jvm/java-6-sun" unless ENV["JAVA_HOME"]
+ENV["JOELIB2"] = File.join File.expand_path(File.dirname(__FILE__)),"java"
+deps = []
+deps << "#{ENV["JAVA_HOME"]}/lib/tools.jar"
+deps << "#{ENV["JAVA_HOME"]}/lib/classes.jar"
+deps << "#{ENV["JOELIB2"]}"
+jars = Dir[ENV["JOELIB2"]+"/*.jar"].collect {|f| File.expand_path(f) }
+deps = deps + jars
+ENV["CLASSPATH"] = deps.join(":")
+
+
require 'rubygems'
gem "opentox-ruby", "~> 3"
require 'opentox-ruby'
require 'profiler'
+require 'rjb'
set :lock, true
@@ -340,6 +352,55 @@ post '/:id' do
halt 202,task.uri.to_s+"\n"
end
+
+# Create PC descriptors
+#
+# @param [String] pc_type
+# @return [text/uri-list] Task ID
+get '/:id/pcdesc' do
+algorithm = OpenTox::Algorithm::Generic.new(url_for('/dataset/id/pcdesc',:full))
+ algorithm.metadata = {
+ DC.title => 'Physico-chemical (PC) descriptor calculation',
+ DC.creator => "andreas@maunz.de, vorgrimmlerdavid@gmx.de",
+ RDF.type => [OT.Algorithm,OTA.PatternMiningSupervised],
+ OT.parameters => [
+ { DC.description => "Dataset URI", OT.paramScope => "mandatory", DC.title => "dataset_uri" },
+ { DC.description => "PC type", OT.paramScope => "mandatory", DC.title => "pc_type" },
+ ]
+ }
+ case request.env['HTTP_ACCEPT']
+ when /text\/html/
+ content_type "text/html"
+ OpenTox.text_to_html algorithm.to_yaml
+ when /application\/x-yaml/
+ content_type "application/x-yaml"
+ algorithm.to_yaml
+ else
+ response['Content-Type'] = 'application/rdf+xml'
+ algorithm.to_rdfxml
+ end
+end
+
+
+
+post '/:id/pcdesc' do
+ response['Content-Type'] = 'text/uri-list'
+ raise "No PC type given" unless params["pc_type"]
+
+ task = OpenTox::Task.create("PC descriptor calculation for dataset ", @uri) do |task|
+ types = params[:pc_type].split(",")
+ if types.include?("joelib")
+ Rjb.load(nil,["-Xmx64m"])
+ s = Rjb::import('JoelibFc')
+ end
+ OpenTox::Algorithm.pc_descriptors( { :dataset_uri => @uri, :pc_type => params[:pc_type], :rjb => s, :task => task } )
+ end
+ raise OpenTox::ServiceUnavailableError.newtask.uri+"\n" if task.status == "Cancelled"
+ halt 202,task.uri.to_s+"\n"
+end
+
+
+
# Deletes datasets that have been created by a crossvalidatoin that does not exist anymore
# (This can happen if a crossvalidation fails unexpectedly)
delete '/cleanup' do