summaryrefslogtreecommitdiff
path: root/application.rb
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2015-03-11 16:49:24 +0100
committergebele <gebele@in-silico.ch>2015-03-11 16:49:24 +0100
commit8969a13eb7872857cd81a4fa847677c226aa8a72 (patch)
treed016aa5fa96c24d4f7b6678132114386be29642c /application.rb
parent12002a6390b10c3c12462936484ba967da2478e4 (diff)
marked descriptor links;resize body if many models;fixed progress status
Diffstat (limited to 'application.rb')
-rw-r--r--application.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/application.rb b/application.rb
index 360db1d..3f3d5f0 100644
--- a/application.rb
+++ b/application.rb
@@ -10,6 +10,13 @@ helpers do
@@models = []
models = `curl -k GET -H accept:text/uri-list #{$model[:uri]}`.split("\n")
.collect{|m| model = OpenTox::Model::Lazar.find m; @@models << model if model.type.flatten.to_s =~ /PredictionModel/}
+
+ class Numeric
+ def percent_of(n)
+ self.to_f / n.to_f * 100.0
+ end
+ end
+
end
get '/?' do
@@ -232,7 +239,15 @@ post '/predict/?' do
# predict with selected models
# one prediction in 'pa' array = OpenTox::Dataset
# all collected predictions in '@predictions' array
+ # add task for progressBar
+ total = @prediction_models.size
+ toptask = OpenTox::Task.find params[:task_uri]
+ toptask.metadata
+ toptask[RDF::OT.hasStatus] = "Running"
+ toptask[RDF::OT.percentageCompleted] = "10"
+ toptask.put
@prediction_models.each_with_index do |m, idx|
+ idx = idx+1
# define type (classification|regression)
m.type.join =~ /classification/i ? (@model_type << "classification") : (@model_type << "regression")
@@ -244,6 +259,8 @@ post '/predict/?' do
pa = []
pa << prediction
@predictions << pa
+ toptask[RDF::OT.percentageCompleted] = idx.percent_of(total).round(1)
+ toptask.put
end
haml :prediction
end