summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Maunz <andreas@maunz.de>2012-04-03 16:26:50 +0200
committerAndreas Maunz <andreas@maunz.de>2012-04-03 16:26:50 +0200
commit9a228a9fcfd85f69f81dd0d70f3ed5829cb7aead (patch)
treee2e67dba130411ab4d9b8e4872ba812fb76ccd48
parente1f52a8f81f59b8ef81aed87f53ce755fb25ace6 (diff)
Added openbabel
-rw-r--r--fs.rb (renamed from feature_selection.rb)0
-rw-r--r--pc.rb54
2 files changed, 49 insertions, 5 deletions
diff --git a/feature_selection.rb b/fs.rb
index 469fa87..469fa87 100644
--- a/feature_selection.rb
+++ b/fs.rb
diff --git a/pc.rb b/pc.rb
index f297014..5c38052 100644
--- a/pc.rb
+++ b/pc.rb
@@ -3,12 +3,12 @@
# Author: Andreas Maunz
-# Get a list of OpenBabel algorithms
-# @return [text/uri-list] URIs of OpenBabel algorithms
+# Get a list of pc algorithms
+# @return [text/uri-list] URIs of algorithms
get '/pc' do
algorithms = YAML::load_file File.join(ENV['HOME'], ".opentox", "config", "pc_descriptors.yaml")
response['Content-Type'] = 'text/uri-list'
- list = (algorithms.keys << "AllDescriptors").join("\n") + "\n"
+ list = (algorithms.keys.sort << "AllDescriptors").collect { |name| url_for("/pc/#{name}",:full) }.join("\n") + "\n"
case request.env['HTTP_ACCEPT']
when /text\/html/
content_type "text/html"
@@ -28,7 +28,7 @@ get '/pc/:descriptor' do
if params[:descriptor] != "AllDescriptors"
descriptors = descriptors[params[:descriptor]]
else
- alg_params << { DC.description => "Descriptor Category, one or more of '#{descriptors.collect { |id, info| info[:category] }.uniq.sort.join(",")}'", OT.paramScope => "optional", DC.title => "category" }
+ alg_params << { DC.description => "Physico-chemical type, one or more of '#{descriptors.collect { |id, info| info[:pc_type] }.uniq.sort.join(",")}'", OT.paramScope => "optional", DC.title => "pc_type" }
alg_params << { DC.description => "Software Library, one or more of '#{descriptors.collect { |id, info| info[:lib] }.uniq.sort.join(",")}'", OT.paramScope => "optional", DC.title => "lib" }
descriptors = {:id => "AllDescriptors", :name => "All PC descriptors" }
end
@@ -44,7 +44,7 @@ get '/pc/:descriptor' do
RDF.type => [OTA.DescriptorCalculation],
}
algorithm.metadata[OT.parameters] = alg_params
- algorithm.metadata[DC.description] << (", category: " + descriptors[:category]) unless descriptors[:id] == "AllDescriptors"
+ algorithm.metadata[DC.description] << (", pc_type: " + descriptors[:pc_type]) unless descriptors[:id] == "AllDescriptors"
algorithm.metadata[DC.description] << (", lib: " + descriptors[:lib]) unless descriptors[:id] == "AllDescriptors"
# Deliver
@@ -65,3 +65,47 @@ get '/pc/:descriptor' do
end
end
+# Run pc descriptor calculation algorithm on dataset
+#
+# @param [String] dataset_uri URI of the training dataset
+# @return [text/uri-list] Task URI
+post '/pc' do
+ response['Content-Type'] = 'text/uri-list'
+ raise OpenTox::NotFoundError.new "Parameter 'dataset_uri' missing." unless params[:dataset_uri]
+
+ descriptors = YAML::load_file File.join(ENV['HOME'], ".opentox", "config", "pc_descriptors.yaml")
+ params[:pc_type] = descriptors.collect { |id,info| info[:pc_type]}.uniq.sort.join(',') unless params[:pc_type]
+
+ task = OpenTox::Task.create("PC descriptor calculation for dataset ", @uri) do |task|
+ Rjb.load(nil,["-Xmx64m"]) # start vm
+ byteArray = Rjb::import('java.io.ByteArrayOutputStream'); printStream = Rjb::import('java.io.PrintStream');
+ out = byteArray.new() ; Rjb::import('java.lang.System').out = printStream.new(out) # joelib is too verbose
+ s = Rjb::import('JoelibFc') # import main class
+ OpenTox::Algorithm.pc_descriptors( { :dataset_uri => params[:dataset_uri], :pc_type => params[:pc_type], :rjb => s, :task => task, :lib => params[:lib] } )
+ end
+ raise OpenTox::ServiceUnavailableError.newtask.uri+"\n" if task.status == "Cancelled"
+ halt 202,task.uri.to_s+"\n"
+end
+
+# Run pc descriptor calculation algorithm on dataset
+#
+# @param [String] dataset_uri URI of the training dataset
+# @return [text/uri-list] Task URI
+post '/pc/:descriptor' do
+ response['Content-Type'] = 'text/uri-list'
+ raise OpenTox::NotFoundError.new "Parameter 'dataset_uri' missing." unless params[:dataset_uri]
+
+ descriptors = YAML::load_file File.join(ENV['HOME'], ".opentox", "config", "pc_descriptors.yaml")
+ params[:pc_type] = descriptors.collect { |id,info| info[:pc_type]}.uniq.sort.join(',')
+
+ task = OpenTox::Task.create("PC descriptor calculation for dataset ", @uri) do |task|
+ Rjb.load(nil,["-Xmx64m"]) # start vm
+ byteArray = Rjb::import('java.io.ByteArrayOutputStream'); printStream = Rjb::import('java.io.PrintStream');
+ out = byteArray.new() ; Rjb::import('java.lang.System').out = printStream.new(out) # joelib is too verbose
+ s = Rjb::import('JoelibFc') # import main class
+ OpenTox::Algorithm.pc_descriptors( { :dataset_uri => params[:dataset_uri], :pc_type => params[:pc_type], :descriptor => params[:descriptor], :rjb => s, :task => task } )
+ end
+ raise OpenTox::ServiceUnavailableError.newtask.uri+"\n" if task.status == "Cancelled"
+ halt 202,task.uri.to_s+"\n"
+end
+