summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2018-04-13 09:12:10 +0000
committergebele <gebele@in-silico.ch>2018-04-13 09:12:10 +0000
commitf78d888a249303379c7934c83d5da11349a44b48 (patch)
tree93bf6e7cb7e9d93c9e5a8d3936359fbbdede511f
parent53da85660cc761fd49b33097ced875e09d3e9eed (diff)
duplicate warning at bottom of batch result file
-rw-r--r--application.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/application.rb b/application.rb
index 8f78845..9c6f63e 100644
--- a/application.rb
+++ b/application.rb
@@ -164,7 +164,13 @@ get '/predict/csv/:task/:model/:filename/?' do
else
header = task.csv
lines = []
- task.predictions[params[:model]].each_with_index{|p,idx| lines << "#{idx+1},#{Prediction.find(p).csv}"}
+ task.predictions[params[:model]].each_with_index do |p,idx|
+ if p.is_a? BSON::ObjectId
+ lines << "#{idx+1},#{Prediction.find(p).csv}"
+ else
+ lines << "#{idx+1},#{p}\n"
+ end
+ end
csv = header + lines.join("")
tempfile.write(csv)
end
@@ -336,6 +342,12 @@ post '/predict/?' do
predictions["Cramer rules, with extensions"] = output["cramer_rules_extensions"].collect{|rule| rule != "nil" ? rule : "none"}
predictions["compounds"] = @compounds.collect{|c| c.id}
+ if @dataset.warnings
+ @dataset.warnings.each do |warning|
+ w = warning.split(".").first
+ csv << w.sub(/,/," and")+"\n"
+ end
+ end
# write csv
t[:csv] = csv
# write predictions
@@ -345,6 +357,12 @@ post '/predict/?' do
# save task
# append predictions as last action otherwise they won't save
# mongoid works with shallow copy via #dup
+ if @dataset.warnings
+ @dataset.warnings.each do |warning|
+ w = warning.split(".").first
+ @predictions["#{model}"] << w.sub(/,/," and")
+ end
+ end
t[:predictions] = @predictions
t.save
end#models