From 020cdb5c7974815a7ebe7cf976f026010acd6ef2 Mon Sep 17 00:00:00 2001 From: gebele Date: Mon, 21 Sep 2015 10:01:55 +0200 Subject: batch selection by tab --- application.rb | 3 +- unicorn.rb | 2 +- views/batch.haml | 86 +++++++++++++++++++++++++++------------------------ views/layout.haml | 2 +- views/predict.haml | 28 +++++++++-------- views/prediction.haml | 2 +- views/style.scss | 23 ++++++++++++-- 7 files changed, 86 insertions(+), 60 deletions(-) diff --git a/application.rb b/application.rb index 07af20b..4b36e7b 100644 --- a/application.rb +++ b/application.rb @@ -4,7 +4,7 @@ include OpenTox # DG: workaround for https://github.com/sinatra/sinatra/issues/808 # Date: 18/11/2013 -set :protection, :except => :path_traversal +#set :protection, :except => :path_traversal configure :development do $logger = Logger.new(STDOUT) @@ -205,6 +205,7 @@ post '/predict/?' do File.open('tmp/' + params[:fileselect][:filename], "w") do |f| f.write(params[:fileselect][:tempfile].read) end + @filename = params[:fileselect][:filename] input = OpenTox::Dataset.from_csv_file File.join "tmp", params[:fileselect][:filename] dataset = OpenTox::Dataset.find input.id @compounds = dataset.compounds diff --git a/unicorn.rb b/unicorn.rb index 4e65aaa..7f8d4a2 100644 --- a/unicorn.rb +++ b/unicorn.rb @@ -1,2 +1,2 @@ -worker_processes 4 +#worker_processes 4 timeout 6000 diff --git a/views/batch.haml b/views/batch.haml index 8fbc8cc..7cf1d77 100644 --- a/views/batch.haml +++ b/views/batch.haml @@ -1,44 +1,50 @@ -/ displays all prediction result in first table -%div.table-responsive - %table.table.table-bordered{:id=>"batch", :style=>"background-color:white;"} - %thead - %tr - %h3 Batch Prediction Results: +%div.well + %a.btn.btn-warning{:href => to('/predict')} Make New Prediction + / displays all prediction result in first table + %div.table-responsive + %table.table.table-bordered{:id=>"batch", :style=>"background-color:white;"} + %thead + %tr + %h3.col-md-4 Batch Prediction Results: + %h3.col-md-8= @filename - %tbody - / key = compound, values = array of arrays with model, prediction - - @batch.each do |key, values| - - compound = key - %tr - %td{:style=>"vertical-align:top;"} - %p= compound.svg - %p= compound.smiles - / array = single prediction [endpoint, result] - - values.each_with_index do |array,i| + %tbody + / key = compound, values = array of arrays with model, prediction + - @batch.each do |key, values| + - compound = key + %tr %td{:style=>"vertical-align:top;"} - - model = array[0] - - prediction = array[1] - %b{:class => "title"} - = "#{model.endpoint.gsub('_', ' ')} (#{model.species})" - %p - - if prediction[:confidence] == "measured" - %p - / TODO fix scientific notation from database - %b Measured activity: - = prediction[:value].numeric? ? "#{prediction[:value].round(3)} (#{model.unit})" : prediction[:value] - %p Compound is part of the training dataset - - elsif prediction[:neighbors].size > 0 - %p - / model type (classification|regression) - %b Type: - = model.model.class.to_s.match("Classification") ? "Classification" : "Regression" - %br - %b Prediction: - / TODO scientific notation - = prediction[:value].numeric? ? "#{'%.2e' % prediction[:value]} #{model.unit}" : prediction[:value] - %br - / TODO probability - %b Confidence: - = prediction[:confidence].round(3) + %p= compound.svg + %p= compound.smiles + / array = single prediction [endpoint, result] + - values.each_with_index do |array,i| + %td{:style=>"vertical-align:top;"} + - model = array[0] + - prediction = array[1] + %b{:class => "title"} + = "#{model.endpoint.gsub('_', ' ')} (#{model.species})" %p + - if prediction[:confidence] == "measured" + %p + / TODO fix scientific notation from database + %b Measured activity: + = prediction[:value].numeric? ? "#{prediction[:value].round(3)} (#{model.unit})" : prediction[:value] + %p Compound is part of the training dataset + - elsif prediction[:neighbors].size > 0 + %p + / model type (classification|regression) + %b Type: + = model.model.class.to_s.match("Classification") ? "Classification" : "Regression" + %br + %b Prediction: + / TODO scientific notation + = prediction[:value].numeric? ? "#{'%.2e' % prediction[:value]} #{model.unit}" : prediction[:value] + %br + / TODO probability + %b Confidence: + = prediction[:confidence].round(3) + %p + - else + %p + Not enough similar compounds in training dataset. %p diff --git a/views/layout.haml b/views/layout.haml index 60f2bb3..94a24e9 100644 --- a/views/layout.haml +++ b/views/layout.haml @@ -24,7 +24,7 @@ %div.row %div.col-md-2 %a{:href=> to("/predict")} - %img.media-object{:src=>"/images/ist_logo.png", :alt=>"logo", :style=>"margin:0 3em 0 2em;"} + %img.media-object{:src=>"/images/ist_logo.png", :alt=>"logo", :style=>"margin:0 3em 1em 2em;"} %div.col-md-8 %h1.media-heading{:style=>"margin: 0 0 0 1em;"} Lazar Toxicity Predictions diff --git a/views/predict.haml b/views/predict.haml index 917a04a..5528a6e 100644 --- a/views/predict.haml +++ b/views/predict.haml @@ -1,19 +1,21 @@ %link{ :href=>"/jsme/jsa.css", :rel=>"stylesheet"} %script{:src=>"/jsme/jsme.nocache.js"} :javascript + $(function() { + $('a[data-toggle="tab"]').on('click', function (e) { + localStorage.setItem('lastTab', $(e.target).attr('href')); + }); + var lastTab = localStorage.getItem('lastTab'); + if (lastTab) { + $('a[href="'+lastTab+'"]').click(); + } + }); + function getTab(){ t = $('.nav-tabs li.active').text(); return t.trim(); }; function showcircle() { - /*if (checksmiles() && checkboxes()){ - button = document.getElementById("submit"); - image = document.getElementById("circle"); - button.parentNode.replaceChild(image, button); - $("img.circle").show(); - return true; - }; - return false;*/ switch (getTab()){ case "single": if (checksmiles() && checkboxes()){ @@ -92,11 +94,11 @@ %ul.nav.nav-tabs{:role=>"tablist"} - ["single", "batch"].each do |select| %li{:class => ("active" if select == "single")} - %a{:href => "div##{select}", :id => "linkTab#{select}", :data=> {:toggle=>"tab"}} + %a{:href => "##{select}", :id => "linkTab#{select}", :aria=>{:controls=>"#{select}"}, :data=> {:toggle=>"tab"}} = select - %div.tab-content - #single.tab-pane.fade-in.active + %div.tab-content{:id=>"predict"} + #single.tab-pane.fade-in.active{:role=>"tabpanel"} %h2 1. Draw a chemical structure #insert %p @@ -110,12 +112,12 @@ %br %input{:type => 'text', :name => 'identifier', :id => 'identifier', :size => '60'} - #batch.tab-pane.fade-in + #batch.tab-pane.fade-in{:role=>"tabpanel"} %h2 1. Select a file to upload Browse (csv): %span.btn.btn-default.btn-file %input{:type=>"file", :name=> "fileselect", :id=>"fileselect"} - + %fieldset#middle.well %h2 2. Select one or more endpoints diff --git a/views/prediction.haml b/views/prediction.haml index 3cdfbd6..87f8511 100644 --- a/views/prediction.haml +++ b/views/prediction.haml @@ -6,7 +6,7 @@ }); }); %div.well - %a.btn.btn-warning{:href => to('/predict')} New Prediction + %a.btn.btn-warning{:href => to('/predict')} Make New Prediction / displays all prediction result in first table %div.table-responsive diff --git a/views/style.scss b/views/style.scss index fd05c3e..67c6ea7 100644 --- a/views/style.scss +++ b/views/style.scss @@ -5,6 +5,23 @@ table.table-borderless tbody tr td{ h4.head-back, h5.head-back{ background-color: #E7E7E7; } -//.btn:focus{ - //background: #f0ad4e; -//} + +#top.well { + padding: 0; +} + +#predict.tab-content { + //background-color: white; + border-left: 1px solid #ddd; + border-right: 1px solid #ddd; + padding: 10px; +} + +.nav-tabs { + background-color: #E7E7E7; + margin-bottom: 0; +} + +.nav-tabs li.active a:hover { + background-color: #f5f5f5; +} -- cgit v1.2.3