diff options
author | gebele <gebele@in-silico.ch> | 2017-11-07 10:16:33 +0000 |
---|---|---|
committer | gebele <gebele@in-silico.ch> | 2017-11-07 10:16:33 +0000 |
commit | 745103c970b9883808ce95399a8d0a32e5c57342 (patch) | |
tree | 8faf2984cc207bcc8a7808bfd1d8a6b40bf15c05 /application.rb | |
parent | 668e485e63715d0dfa4e6e2f70323fd1ecb95ee6 (diff) |
reordered to store sa prediction
Diffstat (limited to 'application.rb')
-rw-r--r-- | application.rb | 36 |
1 files changed, 18 insertions, 18 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" |