diff options
author | gebele <gebele@in-silico.ch> | 2018-05-22 14:10:56 +0000 |
---|---|---|
committer | gebele <gebele@in-silico.ch> | 2018-05-22 14:10:56 +0000 |
commit | fa1137da0ed761f37d38b0cdd6002cb07fda99b9 (patch) | |
tree | 3bb4fcd72e2062cea7dfcc849275af76613b9d30 | |
parent | 4187e0d88763f631d3f4f157203cc955067945e7 (diff) |
adjusted warnings and endpoint for html and csv
-rw-r--r-- | application.rb | 11 | ||||
-rw-r--r-- | 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("</br>")} + sorter << {"Warnings" => prediction[:warnings].last =~ /similar/ ? prediction[:warnings].last : prediction[:warnings].join("</br>")} # 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("</br>")} elsif !prediction[:value] && type == "Classification" - sorter << {"Lazar mutagenicity (Salmonella typhimurium)" => ""} sorter << {"Prediction" => ""} sorter << {"Probability" => ""} - sorter << {"Warnings" => prediction[:warnings].join("</br>")} + sorter << {"Warnings" => prediction[:warnings].last =~ /similar/ ? prediction[:warnings].last : prediction[:warnings].join("</br>")} 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 @@ -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 : ""},"\ |