From 332c68dc1bc59538a8a749ef592d5700ba316357 Mon Sep 17 00:00:00 2001 From: gebele Date: Thu, 9 Nov 2017 16:10:20 +0000 Subject: fixed cramer details;changed message for wrong file format --- application.rb | 24 +++++++++++++----------- views/batch.haml | 14 +++++++++++--- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/application.rb b/application.rb index 21955b5..223b81a 100644 --- a/application.rb +++ b/application.rb @@ -49,15 +49,11 @@ get '/task/?' do predictions = task.predictions[params[:model]] pageSize = params[:pageSize].to_i - 1 pageNumber= params[:pageNumber].to_i - 1 - prediction_object = Prediction.find predictions[pageNumber] - prediction = prediction_object.prediction - compound = Compound.find prediction_object.compound - model = Model::Validation.find prediction_object.model - image = compound.svg - smiles = compound.smiles if params[:model] == "Cramer" - task = Task.find(params[:turi].to_s) - prediction = task.predictions[params[:model]] + prediction = predictions + compound = Compound.find prediction["compounds"][pageNumber] + image = compound.svg + smiles = compound.smiles html = "" html += "" string = "" html += "#{string}
#{image}
#{smiles}
" @@ -66,6 +62,12 @@ get '/task/?' do string += "
" else + prediction_object = Prediction.find predictions[pageNumber] + prediction = prediction_object.prediction + compound = Compound.find prediction_object.compound + model = Model::Validation.find prediction_object.model + image = compound.svg + smiles = compound.smiles type = (model.regression? ? "Regression" : "Classification") html = "" html += "" @@ -158,7 +160,7 @@ post '/predict/?' do # process batch prediction if !params[:fileselect].blank? if params[:fileselect][:filename] !~ /\.csv$/ - bad_request_error "Please submit a csv file." + bad_request_error "Wrong file extension for '#{params[:fileselect][:filename]}'. Please upload a CSV file." end File.open('tmp/' + params[:fileselect][:filename], "w") do |f| f.write(params[:fileselect][:tempfile].read) @@ -185,7 +187,6 @@ post '/predict/?' do @models = params[:selection].keys # for single predictions in batch - @@compounds_ids = @compounds.collect{|c| c.id.to_s} @tasks = [] @models.each{|m| t = Task.new; t.save; @tasks << t} @predictions = {} @@ -277,7 +278,7 @@ post '/predict/?' do end # collect prediction_object ids predictions << prediction_id - t.update_percent((counter*p).ceil) + t.update_percent((counter*p).ceil > 100 ? 100 : (counter*p).ceil) counter += 1 end # write csv @@ -302,6 +303,7 @@ post '/predict/?' do predictions = {} predictions["Cramer rules"] = output["cramer_rules"].collect{|rule| rule != "nil" ? rule : "none"} predictions["Cramer rules, with extensions"] = output["cramer_rules_extensions"].collect{|rule| rule != "nil" ? rule : "none"} + predictions["compounds"] = @compounds.collect{|c| c.id} # write csv t[:csv] = csv diff --git a/views/batch.haml b/views/batch.haml index 0f0e3b9..c770247 100644 --- a/views/batch.haml +++ b/views/batch.haml @@ -29,11 +29,16 @@ var aClient = new HttpClient(); aClient.get(uri, function(res) { var response = JSON.parse(res); - progress(response['percent'],id); + if (model_id == "Cramer"){ + $("img.circle").show(); + }else{ + progress(response['percent'],id); + } if (response['percent'] == 100){ window.clearInterval(markers[id]); $("a#downbutton_"+id).removeClass("disabled"); $("a#detailsbutton_"+id).removeClass("disabled"); + $("img.circle").hide(); }; }); }; @@ -110,8 +115,11 @@ %a.btn.btn-default.btn-xs.disabled{:id => "downbutton_#{idx}", :href=>"#{to("/predict/csv/#{task}/#{model}/#{@filename}")}", :title=>"download", :style=>"font-size:small;"} %span.glyphicon.glyphicon-download-alt CSV - %div{:id=>"progress_#{idx}", :style=>"width:100%;height:3px;position:relative;background-color:#ccc;"} - %div{:id=>"bar_#{idx}", :style=>"background-color: #4CAF50;width:10px;height:3px;position:absolute;"} + - if model == "Cramer" + %img.h2{:src=>"/images/wait30trans.gif", :id=>"circle", :class=>"circle", :alt=>"wait", :style=>"display:none;"} + - if model != "Cramer" + %div{:id=>"progress_#{idx}", :style=>"width:100%;height:3px;position:relative;background-color:#ccc;"} + %div{:id=>"bar_#{idx}", :style=>"background-color: #4CAF50;width:10px;height:3px;position:absolute;"} - # increase interval timer for large datasets - ctimer = ((@compounds.size/1000) == 0 ? 1000 : ((@compounds.size/1000)*1000)) :javascript -- cgit v1.2.3
#{image}
#{smiles}