From 3935e9bee66fbfff4f35365eb9cff8c79f5fadd8 Mon Sep 17 00:00:00 2001 From: gebele Date: Thu, 29 Oct 2015 10:09:13 +0000 Subject: patch merge --- application.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'application.rb') diff --git a/application.rb b/application.rb index 9c9cabb..d77842d 100644 --- a/application.rb +++ b/application.rb @@ -259,12 +259,14 @@ post '/predict/?' do # validate identifier input # transfered input if !params[:identifier].blank? - @identifier = params[:identifier] - begin - # get compound from SMILES - @compound = Compound.from_smiles @identifier - rescue - @error_report = "Attention, '#{params[:identifier]}' is not a valid SMILES string." + # remove whitespaces they terminate a SMILES string + # can result in wrong conversion for compound object + @identifier = params[:identifier].gsub(/\s+/, "") + $logger.debug "input:#{@identifier}" + # get compound from SMILES + @compound = Compound.from_smiles @identifier + if @compound.blank? + @error_report = "Attention, '#{@identifier}' is not a valid SMILES string." return haml :error end -- cgit v1.2.3 From dbb60a158ccb84f730089c5b0f61032c169dd92e Mon Sep 17 00:00:00 2001 From: gebele Date: Thu, 29 Oct 2015 12:54:15 +0000 Subject: revert last change after fix in compound lib --- application.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'application.rb') diff --git a/application.rb b/application.rb index d77842d..229f3a1 100644 --- a/application.rb +++ b/application.rb @@ -259,9 +259,7 @@ post '/predict/?' do # validate identifier input # transfered input if !params[:identifier].blank? - # remove whitespaces they terminate a SMILES string - # can result in wrong conversion for compound object - @identifier = params[:identifier].gsub(/\s+/, "") + @identifier = params[:identifier] $logger.debug "input:#{@identifier}" # get compound from SMILES @compound = Compound.from_smiles @identifier -- cgit v1.2.3 From 1d6588b35b4ffff16717e24b42a0d396d5347f95 Mon Sep 17 00:00:00 2001 From: gebele Date: Tue, 26 Jan 2016 12:53:40 +0000 Subject: batch merge --- application.rb | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'application.rb') diff --git a/application.rb b/application.rb index 229f3a1..fc7e415 100644 --- a/application.rb +++ b/application.rb @@ -202,21 +202,34 @@ get '/predict/?:csv?' do model = array[0] prediction = array[1] compound = key.smiles + mw = key.molecular_weight endpoint = "#{model.endpoint.gsub('_', ' ')} (#{model.species})" if prediction[:confidence] == "measured" - type = "" - pred = prediction[:value].numeric? ? "#{prediction[:value].round(3)} (#{model.unit})" : prediction[:value] - confidence = "measured activity" + if prediction[:value].is_a?(Array) + prediction[:value].each do |value| + type = "" + weight = Compound.from_smiles(compound).mmol_to_mg(value, mw) + pred = value.numeric? ? "#{'%.2e' % value} (#{model.unit}) | #{'%.2e' % weight} (mg/kg_bw/day)" : value + confidence = "measured activity" + @csv += "\"#{compound}\",\"#{endpoint}\",\"#{type}\",\"#{pred}\",\"#{confidence}\"\n" + end + else + type = "" + weight = Compound.from_smiles(compound).mmol_to_mg(prediction[:value], mw) + pred = prediction[:value].numeric? ? "#{'%.2e' % prediction[:value]} (#{model.unit}) | #{'%.2e' % weight} (mg/kg_bw/day)" : prediction[:value] + confidence = "measured activity" + end elsif prediction[:neighbors].size > 0 + weight = Compound.from_smiles(compound).mmol_to_mg(prediction[:value], mw) type = model.model.class.to_s.match("Classification") ? "Classification" : "Regression" - pred = prediction[:value].numeric? ? "#{'%.2e' % prediction[:value]} #{model.unit}" : prediction[:value] + pred = prediction[:value].numeric? ? "#{'%.2e' % prediction[:value]} (#{model.unit}) | #{'%.2e' % weight} (mg/kg_bw/day)" : prediction[:value] confidence = prediction[:confidence] else type = "" pred = "Not enough similar compounds in training dataset." confidence = "" end - @csv += "\"#{compound}\",\"#{endpoint}\",\"#{type}\",\"#{pred}\",\"#{confidence}\"\n" + @csv += "\"#{compound}\",\"#{endpoint}\",\"#{type}\",\"#{pred}\",\"#{confidence}\"\n" unless prediction[:value].is_a?(Array) end end @csv -- cgit v1.2.3 From 9eb9fd8ab470d6c44c70e0af0808204bdda2b161 Mon Sep 17 00:00:00 2001 From: gebele Date: Thu, 17 Mar 2016 11:28:18 +0000 Subject: snapshot, works only with png plots --- application.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'application.rb') diff --git a/application.rb b/application.rb index fc7e415..a4dc7c4 100644 --- a/application.rb +++ b/application.rb @@ -31,6 +31,18 @@ end get '/predict/modeldetails/:model' do model = OpenTox::Model::Prediction.find params[:model] + crossvalidations = model.crossvalidations + confidence_plots = crossvalidations.collect{|cv| [cv.id, cv.confidence_plot]} + confidence_plots.each do |confp| + File.open(File.join('public', "confp#{confp[0]}.png"), 'w'){|file| file.write(confp[1])} unless File.exists? File.join('public', "confp#{confp[0]}.png") + end + if model.regression? + correlation_plots = crossvalidations.collect{|cv| [cv.id, cv.correlation_plot]} + correlation_plots.each do |corrp| + File.open(File.join('public', "corrp#{corrp[0]}.png"), 'w'){|file| file.write(corrp[1])} unless File.exists? File.join('public', "corrp#{corrp[0]}.png") + end + end + return haml :model_details, :layout=> false, :locals => {:model => model} end -- cgit v1.2.3 From 510822b13d48344ffe4e047a4415ebdb218dadc0 Mon Sep 17 00:00:00 2001 From: gebele Date: Thu, 24 Mar 2016 19:41:37 +0000 Subject: updated for latest lazar changes; introduced 95% prediction interval --- application.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'application.rb') diff --git a/application.rb b/application.rb index a4dc7c4..6c6a73f 100644 --- a/application.rb +++ b/application.rb @@ -32,16 +32,16 @@ end get '/predict/modeldetails/:model' do model = OpenTox::Model::Prediction.find params[:model] crossvalidations = model.crossvalidations - confidence_plots = crossvalidations.collect{|cv| [cv.id, cv.confidence_plot]} - confidence_plots.each do |confp| - File.open(File.join('public', "confp#{confp[0]}.png"), 'w'){|file| file.write(confp[1])} unless File.exists? File.join('public', "confp#{confp[0]}.png") - end - if model.regression? - correlation_plots = crossvalidations.collect{|cv| [cv.id, cv.correlation_plot]} - correlation_plots.each do |corrp| - File.open(File.join('public', "corrp#{corrp[0]}.png"), 'w'){|file| file.write(corrp[1])} unless File.exists? File.join('public', "corrp#{corrp[0]}.png") - end - end + #confidence_plots = crossvalidations.collect{|cv| [cv.id, cv.confidence_plot]} + #confidence_plots.each do |confp| + # File.open(File.join('public', "confp#{confp[0]}.svg"), 'w'){|file| file.write(confp[1])} unless File.exists? File.join('public', "confp#{confp[0]}.svg") + #end + #if model.regression? + # correlation_plots = crossvalidations.collect{|cv| [cv.id, cv.correlation_plot]} + # correlation_plots.each do |corrp| + # File.open(File.join('public', "corrp#{corrp[0]}.svg"), 'w'){|file| file.write(corrp[1])} unless File.exists? File.join('public', "corrp#{corrp[0]}.svg") + # end + #end return haml :model_details, :layout=> false, :locals => {:model => model} end -- cgit v1.2.3 From df8ed98fcc052da2641c26897a8dd0592f274e53 Mon Sep 17 00:00:00 2001 From: gebele Date: Fri, 15 Apr 2016 09:59:43 +0000 Subject: reactivated info buttons; changed unit for fish; introduced FAQ --- application.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'application.rb') diff --git a/application.rb b/application.rb index 6c6a73f..cebe4f2 100644 --- a/application.rb +++ b/application.rb @@ -1,4 +1,5 @@ require_relative 'helper.rb' +require 'rdiscount' include OpenTox #require File.join(ENV["HOME"],".opentox","config","lazar-gui.rb") # until added to ot-tools @@ -304,6 +305,11 @@ post '/predict/?' do end end +get '/faq' do + @faq = RDiscount.new(File.read("FAQ.md")).to_html + haml :faq, :layout => :faq_layout +end + get '/style.css' do headers 'Content-Type' => 'text/css; charset=utf-8' scss :style -- cgit v1.2.3 From 9d6043aef3836e0678942dccda2d8eeda0dc17b4 Mon Sep 17 00:00:00 2001 From: gebele Date: Wed, 20 Apr 2016 14:49:21 +0000 Subject: keep back faq --- application.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'application.rb') diff --git a/application.rb b/application.rb index cebe4f2..7b774bc 100644 --- a/application.rb +++ b/application.rb @@ -304,12 +304,12 @@ post '/predict/?' do haml :prediction end end - +=begin get '/faq' do @faq = RDiscount.new(File.read("FAQ.md")).to_html haml :faq, :layout => :faq_layout end - +=end get '/style.css' do headers 'Content-Type' => 'text/css; charset=utf-8' scss :style -- cgit v1.2.3 From 171d6e675a0e1c209340d2988e3a39d06999d18c Mon Sep 17 00:00:00 2001 From: gebele Date: Thu, 12 May 2016 10:21:50 +0000 Subject: added start and stop script --- application.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'application.rb') diff --git a/application.rb b/application.rb index 7b774bc..1fa0663 100644 --- a/application.rb +++ b/application.rb @@ -1,5 +1,5 @@ -require_relative 'helper.rb' -require 'rdiscount' +#require_relative 'helper.rb' +#require 'rdiscount' include OpenTox #require File.join(ENV["HOME"],".opentox","config","lazar-gui.rb") # until added to ot-tools -- cgit v1.2.3 From 769f704a2b4e2d83256f580317ed8c0b48cc4f45 Mon Sep 17 00:00:00 2001 From: gebele Date: Wed, 8 Jun 2016 13:47:51 +0000 Subject: bumped version; added version to GUI --- application.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'application.rb') diff --git a/application.rb b/application.rb index 1fa0663..b9c267c 100644 --- a/application.rb +++ b/application.rb @@ -25,6 +25,7 @@ get '/?' do end get '/predict/?' do + @version = File.read("VERSION").chomp @models = OpenTox::Model::Prediction.all @endpoints = @models.collect{|m| m.endpoint}.sort.uniq @models.count <= 0 ? (haml :info) : (haml :predict) -- cgit v1.2.3 From f86c084311282036ffa7b4588c0fa0d5b59af95b Mon Sep 17 00:00:00 2001 From: gebele Date: Thu, 24 Nov 2016 16:03:09 +0000 Subject: several fixes; works with lazar tree e111369ce5564f159b3f5f85c92afdd22352eaa1 --- application.rb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'application.rb') diff --git a/application.rb b/application.rb index b9c267c..5f64b84 100644 --- a/application.rb +++ b/application.rb @@ -1,5 +1,5 @@ #require_relative 'helper.rb' -#require 'rdiscount' +require 'rdiscount' include OpenTox #require File.join(ENV["HOME"],".opentox","config","lazar-gui.rb") # until added to ot-tools @@ -20,20 +20,24 @@ helpers do end +before do + @version = File.read("VERSION").chomp +end + get '/?' do redirect to('/predict') end get '/predict/?' do - @version = File.read("VERSION").chomp @models = OpenTox::Model::Prediction.all + @models = @models.delete_if{|m| m.model.name =~ /\b(Net cell association)\b/} @endpoints = @models.collect{|m| m.endpoint}.sort.uniq @models.count <= 0 ? (haml :info) : (haml :predict) end get '/predict/modeldetails/:model' do model = OpenTox::Model::Prediction.find params[:model] - crossvalidations = model.crossvalidations + crossvalidations = OpenTox::Validation::RepeatedCrossValidation.find(model.repeated_crossvalidation_id).crossvalidations #confidence_plots = crossvalidations.collect{|cv| [cv.id, cv.confidence_plot]} #confidence_plots.each do |confp| # File.open(File.join('public', "confp#{confp[0]}.svg"), 'w'){|file| file.write(confp[1])} unless File.exists? File.join('public', "confp#{confp[0]}.svg") @@ -45,7 +49,7 @@ get '/predict/modeldetails/:model' do # end #end - return haml :model_details, :layout=> false, :locals => {:model => model} + return haml :model_details, :layout=> false, :locals => {:model => model, :crossvalidations => crossvalidations} end get '/jme_help/?' do @@ -305,6 +309,12 @@ post '/predict/?' do haml :prediction end end + +get '/license' do + @license = RDiscount.new(File.read("LICENSE.md")).to_html + haml :license, :layout => false +end + =begin get '/faq' do @faq = RDiscount.new(File.read("FAQ.md")).to_html -- cgit v1.2.3