From 745103c970b9883808ce95399a8d0a32e5c57342 Mon Sep 17 00:00:00 2001 From: gebele Date: Tue, 7 Nov 2017 10:16:33 +0000 Subject: reordered to store sa prediction --- application.rb | 36 ++++++++++++++++++------------------ views/layout.haml | 3 +-- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/application.rb b/application.rb index c2c4fa7..13de7ab 100644 --- a/application.rb +++ b/application.rb @@ -211,27 +211,27 @@ post '/predict/?' do prediction_object = Prediction.new prediction_object[:compound] = compound.id prediction_object[:model] = m.id + if type == "Classification"# consensus mutagenicity + sa_prediction = KaziusAlerts.predict(compound.smiles) + lazar_mutagenicity = prediction + confidence = 0 + lazar_mutagenicity_val = (lazar_mutagenicity[:value] == "non-mutagenic" ? false : true) + if sa_prediction[:prediction] == false && lazar_mutagenicity_val == false + confidence = 0.85 + elsif sa_prediction[:prediction] == true && lazar_mutagenicity_val == true + confidence = 0.85 * ( 1 - sa_prediction[:error_product] ) + elsif sa_prediction[:prediction] == false && lazar_mutagenicity_val == true + confidence = 0.11 + elsif sa_prediction[:prediction] == true && lazar_mutagenicity_val == false + confidence = ( 1 - sa_prediction[:error_product] ) - 0.57 + end + prediction["Consensus prediction"] = sa_prediction[:prediction] == false ? "non-mutagenic" : "mutagenic" + prediction["Consensus confidence"] = confidence.signif(3) + prediction["Structural alerts for mutagenicity"] = sa_prediction[:matches].blank? ? "none" : sa_prediction[:matches].collect{|a| a.first}.join("; ") + end prediction_object[:prediction] = prediction prediction_object.save end - if type == "Classification"# consensus mutagenicity - sa_prediction = KaziusAlerts.predict(compound.smiles) - lazar_mutagenicity = prediction - confidence = 0 - lazar_mutagenicity_val = (lazar_mutagenicity[:value] == "non-mutagenic" ? false : true) - if sa_prediction[:prediction] == false && lazar_mutagenicity_val == false - confidence = 0.85 - elsif sa_prediction[:prediction] == true && lazar_mutagenicity_val == true - confidence = 0.85 * ( 1 - sa_prediction[:error_product] ) - elsif sa_prediction[:prediction] == false && lazar_mutagenicity_val == true - confidence = 0.11 - elsif sa_prediction[:prediction] == true && lazar_mutagenicity_val == false - confidence = ( 1 - sa_prediction[:error_product] ) - 0.57 - end - prediction["Consensus prediction"] = sa_prediction[:prediction] == false ? "non-mutagenic" : "mutagenic" - prediction["Consensus confidence"] = confidence.signif(3) - prediction["Structural alerts for mutagenicity"] = sa_prediction[:matches].blank? ? "none" : sa_prediction[:matches].collect{|a| a.first}.join("; ") - end # regression unless prediction[:value].blank? if type == "Regression" diff --git a/views/layout.haml b/views/layout.haml index 9d73848..bac662a 100644 --- a/views/layout.haml +++ b/views/layout.haml @@ -25,8 +25,7 @@ %header.page-header %div.row %div.col-md-2 - %a{:href=> to("/predict")} - %img.media-object{:src=>"/images/IST_logo_s.png", :alt=>"logo", :width=>"150px", :heigth=>"150px", :style=>"margin:0 3em 0 2em;"} + %img.media-object{:src=>"/images/IST_logo_s.png", :alt=>"logo", :width=>"150px", :heigth=>"150px", :style=>"margin:0 3em 0 2em;"} %div.col-md-8 %h1.media-heading lazar toxicity predictions -- cgit v1.2.3