From 66334c4479e993fdf75535629700c84edbc7ba6c Mon Sep 17 00:00:00 2001 From: gebele Date: Mon, 6 Nov 2017 14:37:21 +0000 Subject: various small fixes --- application.rb | 16 +++++++++------- views/prediction.haml | 27 ++++++++++++++++++--------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/application.rb b/application.rb index 13df650..5baec21 100644 --- a/application.rb +++ b/application.rb @@ -50,6 +50,8 @@ get '/task/?' do smiles = compound.smiles task = Task.find(params[:predictions].to_s) unless task.predictions[params[:model]].nil? + model = Model::Validation.find params[:model].to_s + type = (model.regression? ? "Regression" : "Classification") if params[:model] == "Cramer" prediction = task.predictions[params[:model]] html = "" @@ -67,20 +69,20 @@ get '/task/?' do sorter = [] if prediction[:info] sorter << {"Info" => prediction[:info]} - if prediction[:measurements_string].kind_of?(Array) - sorter << {"Measured activity" => "#{prediction[:measurements_string].join(";")}
#{prediction[:converted_measurements].join(";")}"} + if prediction["measurements_string"].kind_of?(Array) + sorter << {"Measured activity" => "#{prediction["measurements_string"].join(";")}
#{prediction["converted_measurements"].join(";")}"} else - sorter << {"Measured activity" => "#{prediction[:measurements_string]}
#{prediction[:converted_measurements]}"} + sorter << {"Measured activity" => "#{prediction["measurements_string"]}
#{prediction["converted_measurements"]}"} end end # regression - if prediction[:prediction_interval] - sorter << {"Prediction" => "#{prediction[:prediction_value]}
#{prediction[:converted_prediction_value]}"} - sorter << {"95% Prediction interval" => "#{prediction[:interval]}
#{prediction[:converted_interval]}"} + if prediction[:value] && type == "Regression" + sorter << {"Prediction" => "#{prediction["prediction_value"]}
#{prediction["converted_prediction_value"]}"} + sorter << {"95% Prediction interval" => "#{prediction[:interval]}
#{prediction["converted_interval"]}"} sorter << {"Warnings" => prediction[:warnings].join("
")} # classification - elsif prediction[:probabilities] + elsif prediction[:value] && type == "Classification" sorter << {"Consensus prediction" => prediction["Consensus prediction"]} sorter << {"Consensus confidence" => prediction["Consensus confidence"]} sorter << {"Structural alerts for mutagenicity" => prediction["Structural alerts for mutagenicity"]} diff --git a/views/prediction.haml b/views/prediction.haml index 872ee1e..4660112 100644 --- a/views/prediction.haml +++ b/views/prediction.haml @@ -63,7 +63,8 @@ =hash[:matches].blank? ? "none" : hash[:matches].join("; ") / check for prediction %p - - if prediction[:neighbors] and !prediction[:value].nil? + / regression + - if prediction[:value] %b.title= ("Lazar #{@models[i].endpoint.gsub('_', ' ').downcase} (#{@models[i].species}):" if sa_prediction) %p / check for database hit @@ -118,16 +119,24 @@ =prediction[:warnings].join("
") - else - %p - if !prediction[:info].blank? - :plain - This compound was part of the training dataset. All information
- from this compound was removed from the training data before the
- prediction, to obtain unbiased results. + %p + :plain + This compound was part of the training dataset. All information
+ from this compound was removed from the training data before the
+ prediction, to obtain unbiased results. + %p + %b Measured activity: + %br + - if prediction[:measurements].is_a?(Array) + = (type == "Regression") ? prediction[:measurements].collect{|value| "#{value.delog10.signif(3)} (#{unit})
#{@compound.mmol_to_mg(value.delog10).signif(3)} #{unit =~ /mmol\/L/ ? "(mg/L)" : "(mg/kg_bw/day)"}"}.join("
") : prediction[:measurements].join(", ") + - else + = (type == "Regression") ? "#{prediction[:measurements].delog10.signif(3)} (#{unit})
#{@compound.mmol_to_mg(prediction[:measurements].delog10).signif(3)} #{(unit =~ /\b(mmol\/L)\b/) ? "(mg/L)" : "(mg/kg_bw/day)"}" : prediction[:measurements] - if !prediction[:warnings].blank? - %b Warnings: - %br - =prediction[:warnings].join("
") + %p + %b Warnings: + %br + =prediction[:warnings].join("
") / show Cramer rules if checked - if @toxtree == true -- cgit v1.2.3