From fa1137da0ed761f37d38b0cdd6002cb07fda99b9 Mon Sep 17 00:00:00 2001 From: gebele Date: Tue, 22 May 2018 14:10:56 +0000 Subject: adjusted warnings and endpoint for html and csv --- application.rb | 11 ++++------- helper.rb | 15 +++------------ 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/application.rb b/application.rb index 75664de..8223bbe 100644 --- a/application.rb +++ b/application.rb @@ -95,17 +95,15 @@ get '/task/?' do elsif !prediction[:value] && type == "Regression" sorter << {"Prediction" => ""} sorter << {"95% Prediction interval" => ""} - sorter << {"Warnings" => prediction[:warnings].join("
")} + sorter << {"Warnings" => prediction[:warnings].last =~ /similar/ ? prediction[:warnings].last : prediction[:warnings].join("
")} # classification elsif prediction[:value] && type == "Classification" - sorter << {"Lazar mutagenicity (Salmonella typhimurium)" => ""} sorter << {"Prediction" => prediction[:value]} sorter << {"Probability" => prediction[:probabilities].collect{|k,v| "#{k}: #{v.signif(3)}"}.join("
")} elsif !prediction[:value] && type == "Classification" - sorter << {"Lazar mutagenicity (Salmonella typhimurium)" => ""} sorter << {"Prediction" => ""} sorter << {"Probability" => ""} - sorter << {"Warnings" => prediction[:warnings].join("
")} + sorter << {"Warnings" => prediction[:warnings].last =~ /similar/ ? prediction[:warnings].last : prediction[:warnings].join("
")} end sorter.each_with_index do |hash,idx| k = hash.keys[0] @@ -260,9 +258,8 @@ post '/predict/?' do # add header for classification if type == "Classification" av = m.prediction_feature.accept_values - header = "ID,Input,Endpoint,Unique SMILES,inTrainingSet,Measurements,Consensus Prediction,Consensus Confidence,"\ - "Structural alerts for mutagenicity,Lazar Prediction,"\ - "Lazar predProbability #{av[0]},Lazar predProbability #{av[1]},inApplicabilityDomain,Note\n" + header = "ID,Input,Endpoint,Unique SMILES,inTrainingSet,Measurements,"\ + "Lazar Prediction,Lazar predProbability #{av[0]},Lazar predProbability #{av[1]},inApplicabilityDomain,Note\n" end # predict compounds p = 100.0/@compounds.size diff --git a/helper.rb b/helper.rb index c4c6d2b..aa2ae79 100644 --- a/helper.rb +++ b/helper.rb @@ -79,11 +79,8 @@ helpers do prediction[:probabilities].each{|k,v| output['probabilities'] << v.signif(3)} end - line += "Consensus mutagenicity,#{compound.smiles},"\ + line += "#{output['model_name']},#{compound.smiles},"\ "\"#{prediction[:info] ? prediction[:info] : "no"}\",\"#{output['measurements'].join("; ") if prediction[:info]}\","\ - "#{prediction['Consensus prediction']},"\ - "#{prediction['Consensus confidence']},"\ - "#{prediction['Structural alerts for mutagenicity']},"\ "#{output['prediction_value']},"\ "#{!prediction[:probabilities].blank? ? output['probabilities'].first : ""},"\ "#{!prediction[:probabilities].blank? ? output['probabilities'].last : ""},"\ @@ -100,20 +97,14 @@ helpers do "from this compound was removed from the training data before the "\ "prediction to obtain unbiased results." end - note = "\"#{prediction[:warnings].join(" ")}\"" - - output['warnings'] = prediction[:warnings] - output['info'] = prediction[:info] if prediction[:info] + note = "\"#{prediction[:warnings].last =~ /similar/ ? prediction[:warnings].last : prediction[:warnings].join(" ")}\"" if model.regression? line += "#{output['model_name']},#{compound.smiles},#{prediction[:info] ? prediction[:info] : "no"},"\ "#{prediction[:measurements].collect{|m| m.delog10.signif(3)}.join("; ") if prediction[:info]},,,,,,,"+ [inApp,note].join(",")+"\n" else - line += "Consensus mutagenicity,#{compound.smiles},"\ + line += "#{output['model_name']},#{compound.smiles},"\ "\"#{prediction[:info] ? prediction[:info] : "no"}\",\"#{output['measurements'].join("; ") if prediction[:info]}\","\ - "#{prediction['Consensus prediction']},"\ - "#{prediction['Consensus confidence']},"\ - "#{prediction['Structural alerts for mutagenicity']},"\ "#{output['prediction_value']},"\ "#{!prediction[:probabilities].blank? ? output['probabilities'].first : ""},"\ "#{!prediction[:probabilities].blank? ? output['probabilities'].last : ""},"\ -- cgit v1.2.3