From 347d49d5a0697cba6c8644914f51feb9ff4ecf35 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 17 Aug 2011 14:12:16 +0200 Subject: add subjectids where missing and some code cleanup --- application.rb | 52 +++++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/application.rb b/application.rb index 3b88700..a60e597 100644 --- a/application.rb +++ b/application.rb @@ -81,7 +81,7 @@ end get '/models/?' do @models = ToxCreateModel.all.sort(:order => "DESC") @models.each{|m| raise "internal redis error: model is nil" unless m} - subjectstring = session[:subjectid] ? "?subjectid=#{CGI.escape(session[:subjectid])}" : "" + subjectstring = @subjectid ? "?subjectid=#{CGI.escape(@subjectid)}" : "" haml :models, :locals=>{:models=>@models, :subjectstring => subjectstring} end @@ -145,7 +145,7 @@ end get '/model/:id/:view/?' do response['Content-Type'] = 'text/plain' model = ToxCreateModel.get(params[:id]) - subjectstring = session[:subjectid] ? "?subjectid=#{CGI.escape(session[:subjectid])}" : "" + subjectstring = @subjectid ? "?subjectid=#{CGI.escape(@subjectid)}" : "" begin case params[:view] when "model" @@ -199,7 +199,7 @@ end post '/feature' do session[:dataset] = params[:dataset] @features = [] - OpenTox::Dataset.new(params[:dataset]).load_features.each do |uri,metadata| + OpenTox::Dataset.new(params[:dataset], @subjectid).load_features(@subjectid).each do |uri,metadata| @features << OpenTox::Feature.find(uri, @subjectid) if metadata[OWL.sameAs].match(/#{session[:echa]}/) end haml :feature @@ -218,18 +218,16 @@ post '/models' do # create a new model redirect url_for('/create') end - subjectid = session[:subjectid] ? session[:subjectid] : nil - if params[:dataset] and params[:prediction_feature] - @dataset = OpenTox::Dataset.new(params[:dataset],subjectid) + @dataset = OpenTox::Dataset.new(params[:dataset], @subjectid) name = @dataset.load_metadata[DC.title] - @prediction_feature = OpenTox::Feature.find params[:prediction_feature], subjectid + @prediction_feature = OpenTox::Feature.find params[:prediction_feature], @subjectid @dataset.load_compounds elsif params[:file][:filename] name = params[:file][:filename].sub(/\..*$/,"") end - @model = ToxCreateModel.create(:name => name, :subjectid => subjectid) + @model = ToxCreateModel.create(:name => name, :subjectid => @subjectid) @model.update :web_uri => url_for("/model/#{@model.id}", :full), :warnings => "" task = OpenTox::Task.create("Toxcreate Task - Uploading dataset and creating lazar model",url_for("/models",:full)) do |task| @@ -238,33 +236,33 @@ post '/models' do # create a new model unless params[:dataset] and params[:prediction_feature] begin - @dataset = OpenTox::Dataset.create(nil, subjectid) + @dataset = OpenTox::Dataset.create(nil, @subjectid) # check format by extension - not all browsers provide correct content-type]) case File.extname(params[:file][:filename]) when ".csv" csv = params[:file][:tempfile].read - @dataset.load_csv(csv, subjectid) + @dataset.load_csv(csv, @subjectid) when ".xls", ".xlsx" excel_file = params[:file][:tempfile].path + File.extname(params[:file][:filename]) File.rename(params[:file][:tempfile].path, excel_file) # add extension, spreadsheet does not read files without extensions - @dataset.load_spreadsheet(Excel.new excel_file, subjectid) + @dataset.load_spreadsheet(Excel.new excel_file, @subjectid) if @dataset.metadata[OT.Errors] raise "Incorrect file format. Please follow the instructions for #{link_to "Excel", "/help"} or #{link_to "CSV", "/help"} formats." end when ".sdf" sdf = params[:file][:tempfile].read - @dataset.load_sdf(sdf, subjectid) + @dataset.load_sdf(sdf, @subjectid) else raise "#{params[:file][:filename]} has an unsupported file type." end - @dataset.save(subjectid) + @dataset.save(@subjectid) rescue => e error "Dataset creation failed '#{e.message}'",e end if @dataset.features.keys.size != 1 error "More than one feature in dataset #{params[:file][:filename]}. Please delete irrelvant columns and try again." else - @prediction_feature = OpenTox::Feature.find(@dataset.features.keys.first,subjectid) + @prediction_feature = OpenTox::Feature.find(@dataset.features.keys.first,@subjectid) end end @@ -276,7 +274,7 @@ post '/models' do # create a new model @model.update :warnings => @dataset.metadata[OT.Warnings] unless @dataset.metadata[OT.Warnings] and @dataset.metadata[OT.Warnings].empty? task.progress(15) begin - lazar = OpenTox::Model::Lazar.create( {:dataset_uri => @dataset.uri, :prediction_feature => @prediction_feature.uri, :subjectid => subjectid}, + lazar = OpenTox::Model::Lazar.create( {:dataset_uri => @dataset.uri, :prediction_feature => @prediction_feature.uri, :subjectid => @subjectid}, OpenTox::SubTask.new(task,15,25)) rescue => e error "Model creation failed",e # Please check if the input file is in a valid #{link_to "Excel", "/help"} or #{link_to "CSV", "/help"} format." @@ -297,7 +295,7 @@ post '/models' do # create a new model crossvalidation = OpenTox::Crossvalidation.create( { :algorithm_uri => lazar.metadata[OT.algorithm], :dataset_uri => lazar.parameter("dataset_uri"), - :subjectid => subjectid, + :subjectid => @subjectid, :prediction_feature => lazar.parameter("prediction_feature"), :algorithm_params => "feature_generation_uri=#{lazar.parameter("feature_generation_uri")}" }, nil, OpenTox::SubTask.new(task,25,80)) @@ -306,7 +304,7 @@ post '/models' do # create a new model LOGGER.debug "Validation URI: #{@model.validation_uri}" # create summary - validation = crossvalidation.statistics(subjectid) + validation = crossvalidation.statistics(@subjectid) @model.update(:nr_predictions => validation.metadata[OT.numInstances].to_i - validation.metadata[OT.numUnpredicted].to_i) if validation.metadata[OT.classificationStatistics] @model.update(:correct_predictions => validation.metadata[OT.classificationStatistics][OT.percentCorrect].to_f) @@ -332,9 +330,9 @@ post '/models' do # create a new model begin @model.update :status => "Creating validation report" - validation_report_uri = crossvalidation.find_or_create_report(subjectid, OpenTox::SubTask.new(task,80,90)) #unless @model.dirty? + validation_report_uri = crossvalidation.find_or_create_report(@subjectid, OpenTox::SubTask.new(task,80,90)) #unless @model.dirty? @model.update :validation_report_uri => validation_report_uri, :status => "Creating QMRF report" - qmrf_report = OpenTox::Crossvalidation::QMRFReport.create(@model.uri, subjectid, OpenTox::SubTask.new(task,90,99)) + qmrf_report = OpenTox::Crossvalidation::QMRFReport.create(@model.uri, @subjectid, OpenTox::SubTask.new(task,90,99)) @model.update(:validation_qmrf_uri => qmrf_report.uri, :status => "Completed") rescue => e error "Model report creation failed",e @@ -353,7 +351,7 @@ post '/models' do # create a new model end post '/predict/?' do # post chemical name to model - subjectid = session[:subjectid] ? session[:subjectid] : nil + @identifier = params[:identifier] unless params[:selection] and params[:identifier] != '' flash[:notice] = "Please enter a compound identifier and select an endpoint from the list." @@ -372,15 +370,15 @@ post '/predict/?' do # post chemical name to model confidence = nil title = nil db_activities = [] - lazar = OpenTox::Model::Lazar.find model.uri - prediction_dataset_uri = lazar.run({:compound_uri => @compound.uri, :subjectid => subjectid}) + lazar = OpenTox::Model::Lazar.find model.uri, @subjectid + prediction_dataset_uri = lazar.run({:compound_uri => @compound.uri, :subjectid => @subjectid}) LOGGER.debug "Prediction dataset_uri: #{prediction_dataset_uri}" if lazar.value_map @value_map = lazar.value_map else @value_map = nil end - prediction_dataset = OpenTox::LazarPrediction.find(prediction_dataset_uri, subjectid) + prediction_dataset = OpenTox::LazarPrediction.find(prediction_dataset_uri, @subjectid) if prediction_dataset.metadata[OT.hasSource].match(/dataset/) @predictions << { :title => model.name, @@ -388,7 +386,7 @@ post '/predict/?' do # post chemical name to model } else predicted_feature = prediction_dataset.metadata[OT.dependentVariables] - prediction = OpenTox::Feature.find(predicted_feature, subjectid) + prediction = OpenTox::Feature.find(predicted_feature, @subjectid) if prediction.metadata[OT.error] @predictions << { :title => model.name, @@ -418,14 +416,14 @@ post "/lazar/?" do # get detailed prediction @page = 0 @page = params[:page].to_i if params[:page] @model_uri = params[:model_uri] - lazar = OpenTox::Model::Lazar.find @model_uri - prediction_dataset_uri = lazar.run(:compound_uri => params[:compound_uri], :subjectid => session[:subjectid]) + lazar = OpenTox::Model::Lazar.find @model_uri, @subjectid + prediction_dataset_uri = lazar.run(:compound_uri => params[:compound_uri], :subjectid => @subjectid) if lazar.value_map @value_map = lazar.value_map else @value_map = nil end - @prediction = OpenTox::LazarPrediction.find(prediction_dataset_uri, session[:subjectid]) + @prediction = OpenTox::LazarPrediction.find(prediction_dataset_uri, @subjectid) @compound = OpenTox::Compound.new(params[:compound_uri]) haml :lazar end -- cgit v1.2.3 From 69fd5215ea35842fa8c8d8d9e8a767eae2f2c577 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 17 Aug 2011 14:40:11 +0200 Subject: remove delete link when deleting --- public/javascripts/toxcreate.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/javascripts/toxcreate.js b/public/javascripts/toxcreate.js index 91789f8..ee783ce 100755 --- a/public/javascripts/toxcreate.js +++ b/public/javascripts/toxcreate.js @@ -207,6 +207,7 @@ jQuery.fn.deleteModel = function(type, options) { if(confirm(opts.confirm_message)) { $("div#model_" + opts.id).fadeTo("slow",0.5); $("span#model_" + opts.id + "_status").html("Deleting"); + $("a#delete_" + opts.id).html(""); $.ajax({ type: opts.method, url: opts.action, -- cgit v1.2.3 From 282ca3f261897df3324ecdf7040d1a7b1c37edd9 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Thu, 18 Aug 2011 10:47:06 +0200 Subject: replace weighted_auc with average_auc --- model.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model.rb b/model.rb index e433893..bab5bde 100644 --- a/model.rb +++ b/model.rb @@ -31,7 +31,7 @@ class ToxCreateModel < Ohm::Model attribute :nr_compounds attribute :nr_predictions attribute :correct_predictions - attribute :weighted_area_under_roc + attribute :average_area_under_roc attribute :sensitivity attribute :specificity attribute :r_square -- cgit v1.2.3 From 12b3295738445c941b03b15c34ec9e7f2fb56816 Mon Sep 17 00:00:00 2001 From: mr Date: Thu, 18 Aug 2011 13:06:04 +0200 Subject: optimize ToxCreateModel deletion --- application.rb | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/application.rb b/application.rb index a60e597..8ace27c 100644 --- a/application.rb +++ b/application.rb @@ -31,7 +31,7 @@ helpers do private def delete_model(model, subjectid=nil) - task = OpenTox::Task.create("Deleting model: #{model.uri}",url_for("/delete",:full)) do |task| + task = OpenTox::Task.create("Deleting model: #{model.web_uri}", url_for("/delete",:full)) do |task| begin OpenTox::RestClientWrapper.put(File.join(model.task_uri, "Cancelled"), "Cancelled",{:subjectid => subjectid}) if model.task_uri rescue LOGGER.warn "Cannot cancel task #{model.task_uri}" end task.progress(15) delete_dependent(model.uri, subjectid) if model.uri @@ -49,15 +49,25 @@ helpers do if model.feature_dataset delete_dependent(model.feature_dataset, subjectid) if model.feature_dataset.match(CONFIG[:services]["opentox-dataset"]) end + task.progress(95) + model.delete + unless ToxCreateModel.get(model.id) + begin + aa = OpenTox::Authorization.delete_policies_from_uri(model.web_uri, @subjectid) + LOGGER.debug "Policy deleted for ToxCreateModel URI: #{model.web_uri} with result: #{aa}" + rescue + LOGGER.warn "Policy delete error for ToxCreateModel URI: #{model.web_uri}" + end + end task.progress(100) - "" + url_for("/models",:full) end end def delete_dependent(uri, subjectid=nil) begin - RestClient.delete(uri, :subjectid => subjectid) if subjectid - RestClient.delete(uri) if !subjectid + OpenTox::RestClientWrapper.delete(uri, :subjectid => subjectid) if subjectid + OpenTox::RestClientWrapper.delete(uri) if !subjectid rescue LOGGER.warn "Can not delete uri: #{uri}" end @@ -451,18 +461,10 @@ delete '/model/:id/?' do model = ToxCreateModel.get(params[:id]) raise OpenTox::NotFoundError.new("Model with id: #{params[:id]} not found!") unless model begin - delete_model(model, @subjectid) - model.delete - unless ToxCreateModel.get(params[:id]) - begin - aa = OpenTox::Authorization.delete_policies_from_uri(model.web_uri, @subjectid) - LOGGER.debug "Policy deleted for Dataset URI: #{uri} with result: #{aa}" - rescue - LOGGER.warn "Policy delete error for Dataset URI: #{uri}" - end - end + delete_model(model, @subjectid) flash[:notice] = "#{model.name} model deleted." rescue + LOGGER.error "#{model.name} model delete error." flash[:notice] = "#{model.name} model delete error." end redirect url_for('/models') -- cgit v1.2.3 From b41552185b21f706e7f507020925f3253c38321d Mon Sep 17 00:00:00 2001 From: mguetlein Date: Mon, 22 Aug 2011 11:25:06 +0200 Subject: unify cookies --- application.rb | 5 +++-- helper.rb | 30 ------------------------------ 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/application.rb b/application.rb index a60e597..ac19da5 100644 --- a/application.rb +++ b/application.rb @@ -9,8 +9,9 @@ require 'ftools' require File.join(File.dirname(__FILE__),'model.rb') require File.join(File.dirname(__FILE__),'helper.rb') -use Rack::Session::Cookie, :expire_after => 28800, - :secret => "ui6vaiNi-change_me" +#moved to wrapper->environment +#use Rack::Session::Cookie, :expire_after => 28800, +# :secret => "ui6vaiNi-change_me" use Rack::Flash set :lock, true diff --git a/helper.rb b/helper.rb index 698fd3e..80707c3 100644 --- a/helper.rb +++ b/helper.rb @@ -1,35 +1,5 @@ helpers do - def login(username, password) - logout - session[:subjectid] = OpenTox::Authorization.authenticate(username, password) - #LOGGER.debug "ToxCreate login user #{username} with subjectid: " + session[:subjectid].to_s - if session[:subjectid] != nil - session[:username] = username - return true - else - session[:username] = "" - return false - end - end - - def logout - if session[:subjectid] != nil - session[:subjectid] = nil - session[:username] = "" - return true - end - return false - end - - def logged_in() - return true if !AA_SERVER - if session[:subjectid] != nil - return OpenTox::Authorization.is_token_valid(session[:subjectid]) - end - return false - end - def is_authorized(uri, action) if OpenTox::Authorization.server && session[:subjectid] != nil return OpenTox::Authorization.authorized?(uri, action, session[:subjectid]) -- cgit v1.2.3 From a4b6e68acf76949a1765177b6d5b8c454990cb8a Mon Sep 17 00:00:00 2001 From: mguetlein Date: Mon, 22 Aug 2011 12:20:12 +0200 Subject: replace weighted_auc with average_auc [2] --- application.rb | 2 +- views/classification_validation.haml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application.rb b/application.rb index d2ee131..eb86916 100644 --- a/application.rb +++ b/application.rb @@ -320,7 +320,7 @@ post '/models' do # create a new model if validation.metadata[OT.classificationStatistics] @model.update(:correct_predictions => validation.metadata[OT.classificationStatistics][OT.percentCorrect].to_f) @model.update(:confusion_matrix => validation.confusion_matrix.to_yaml) - @model.update(:weighted_area_under_roc => validation.metadata[OT.classificationStatistics][OT.weightedAreaUnderRoc].to_f) + @model.update(:average_area_under_roc => validation.metadata[OT.classificationStatistics][OT.averageAreaUnderRoc].to_f) validation.metadata[OT.classificationStatistics][OT.classValueStatistics].each do |m| if m[OT.classValue] =~ TRUE_REGEXP #HACK: estimate true feature value correctly diff --git a/views/classification_validation.haml b/views/classification_validation.haml index f25a321..9f5c2c9 100644 --- a/views/classification_validation.haml +++ b/views/classification_validation.haml @@ -3,9 +3,9 @@ = sprintf("%.2f", model.correct_predictions.to_f) if model.correct_predictions = '%' %dt - %a{:href => "http://en.wikipedia.org/wiki/Receiver_operating_characteristic", :rel => "external"} Weighted area under ROC: + %a{:href => "http://en.wikipedia.org/wiki/Receiver_operating_characteristic", :rel => "external"} Average area under ROC: %dd - = sprintf("%.3f", model.weighted_area_under_roc.to_f) if model.weighted_area_under_roc + = sprintf("%.3f", model.average_area_under_roc.to_f) if model.average_area_under_roc %dt %a{:href => "http://en.wikipedia.org/wiki/Sensitivity_and_specificity", :rel => "external"} Specificity: %dd= sprintf("%.3f", model.specificity.to_f) if model.specificity -- cgit v1.2.3 From 3b7a80f1af7e8b68f2f8bc9fd137ec9be5658c20 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 22 Aug 2011 11:09:28 +0000 Subject: integers in confusion matrix, average area under roc --- application.rb | 3 ++- views/classification_validation.haml | 12 ++++++------ views/model.haml | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/application.rb b/application.rb index 8ace27c..9eafcbe 100644 --- a/application.rb +++ b/application.rb @@ -319,7 +319,8 @@ post '/models' do # create a new model if validation.metadata[OT.classificationStatistics] @model.update(:correct_predictions => validation.metadata[OT.classificationStatistics][OT.percentCorrect].to_f) @model.update(:confusion_matrix => validation.confusion_matrix.to_yaml) - @model.update(:weighted_area_under_roc => validation.metadata[OT.classificationStatistics][OT.weightedAreaUnderRoc].to_f) + #@model.update(:weighted_area_under_roc => validation.metadata[OT.classificationStatistics][OT.weightedAreaUnderRoc].to_f) + @model.update(:weighted_area_under_roc => validation.metadata[OT.classificationStatistics][OT.averageAreaUnderRoc].to_f) validation.metadata[OT.classificationStatistics][OT.classValueStatistics].each do |m| if m[OT.classValue] =~ TRUE_REGEXP #HACK: estimate true feature value correctly diff --git a/views/classification_validation.haml b/views/classification_validation.haml index f25a321..dd2a7ae 100644 --- a/views/classification_validation.haml +++ b/views/classification_validation.haml @@ -3,7 +3,7 @@ = sprintf("%.2f", model.correct_predictions.to_f) if model.correct_predictions = '%' %dt - %a{:href => "http://en.wikipedia.org/wiki/Receiver_operating_characteristic", :rel => "external"} Weighted area under ROC: + %a{:href => "http://en.wikipedia.org/wiki/Receiver_operating_characteristic", :rel => "external"} Average area under ROC: %dd = sprintf("%.3f", model.weighted_area_under_roc.to_f) if model.weighted_area_under_roc %dt @@ -24,21 +24,21 @@ %tr - (1..cm[0].size-1).each do |i| %th{:bgcolor => "#CCD2DC"} - = cm[0][i] + = cm[0][i].to_i %tr %th{:rowspan => (cm.size - 1)} Predicted - (0..cm[1].size-1).each do |i| - if i == 0 %th{:bgcolor => "#CCD2DC"} - = cm[1][i] + = cm[1][i].to_i - else - %td= cm[1][i] + %td= cm[1][i].to_i - if cm.size > 2 - (2..cm.size-1).each do |i| %tr - (0..cm[i].size-1).each do |j| - if j == 0 %th{:bgcolor => "#CCD2DC"} - = cm[i][j] + = cm[i][j].to_i - else - %td= cm[i][j] + %td= cm[i][j].to_i diff --git a/views/model.haml b/views/model.haml index e688ae9..f0fd660 100644 --- a/views/model.haml +++ b/views/model.haml @@ -29,9 +29,9 @@ - if is_authorized(model.web_uri, "DELETE") %a{:href => url_for("/model/#{model.id}"), :id => "delete_#{model.id}", :class => 'delete_link'} - if model.status =~ /Completed|Error|Cancelled/ - (delete) +  (delete) - else - (stop) +  (stop) %span %br -- cgit v1.2.3 From 8656f259932b03c3ddf7f5eff755d70ab7fbe3eb Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 22 Aug 2011 12:54:35 +0000 Subject: confusion matrix class names fixed --- views/classification_validation.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/views/classification_validation.haml b/views/classification_validation.haml index 362a76f..47e1f75 100644 --- a/views/classification_validation.haml +++ b/views/classification_validation.haml @@ -24,13 +24,13 @@ %tr - (1..cm[0].size-1).each do |i| %th{:bgcolor => "#CCD2DC"} - = cm[0][i].to_i + = cm[0][i] %tr %th{:rowspan => (cm.size - 1)} Predicted - (0..cm[1].size-1).each do |i| - if i == 0 %th{:bgcolor => "#CCD2DC"} - = cm[1][i].to_i + = cm[1][i] - else %td= cm[1][i].to_i - if cm.size > 2 @@ -39,6 +39,6 @@ - (0..cm[i].size-1).each do |j| - if j == 0 %th{:bgcolor => "#CCD2DC"} - = cm[i][j].to_i + = cm[i][j] - else %td= cm[i][j].to_i -- cgit v1.2.3 From c71f69b610b270b9c25cf58e84a035078905fa46 Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 22 Aug 2011 15:28:27 +0200 Subject: remove subjectidstring for unified cookies --- application.rb | 8 +++----- public/javascripts/toxcreate.js | 14 +++++++------- views/model.haml | 18 +++++++++--------- views/models.haml | 6 +++--- views/validation.haml | 2 +- 5 files changed, 23 insertions(+), 25 deletions(-) diff --git a/application.rb b/application.rb index eb86916..9ef50f8 100644 --- a/application.rb +++ b/application.rb @@ -92,8 +92,7 @@ end get '/models/?' do @models = ToxCreateModel.all.sort(:order => "DESC") @models.each{|m| raise "internal redis error: model is nil" unless m} - subjectstring = @subjectid ? "?subjectid=#{CGI.escape(@subjectid)}" : "" - haml :models, :locals=>{:models=>@models, :subjectstring => subjectstring} + haml :models, :locals=>{:models=>@models} end get '/model/:id/status/?' do @@ -156,13 +155,12 @@ end get '/model/:id/:view/?' do response['Content-Type'] = 'text/plain' model = ToxCreateModel.get(params[:id]) - subjectstring = @subjectid ? "?subjectid=#{CGI.escape(@subjectid)}" : "" begin case params[:view] when "model" - haml :model, :locals=>{:model=>model,:subjectstring => subjectstring}, :layout => false + haml :model, :locals=>{:model=>model}, :layout => false when /validation/ - haml :validation, :locals=>{:model=>model,:subjectstring => subjectstring}, :layout => false + haml :validation, :locals=>{:model=>model}, :layout => false else return "unable to render model: id #{params[:id]}, view #{params[:view]}" end diff --git a/public/javascripts/toxcreate.js b/public/javascripts/toxcreate.js index ee783ce..0e82040 100755 --- a/public/javascripts/toxcreate.js +++ b/public/javascripts/toxcreate.js @@ -18,20 +18,20 @@ $(function() { return this.replace(/^\s+|\s+$/g, ''); } - checkStati = function(stati, subjectstr) { + checkStati = function(stati) { stati = stati.split(", "); $("body") var newstati = new Array; $.each(stati, function(){ - checkProgress(this, subjectstr); - if(checkStatus(this, subjectstr) > 0) newstati.push(this); + checkProgress(this); + if(checkStatus(this) > 0) newstati.push(this); }); - if (newstati.length > 0) var statusCheck = setTimeout('checkStati("' + newstati.join(", ") + '", "' + subjectstr + '")',10000); + if (newstati.length > 0) var statusCheck = setTimeout('checkStati("' + newstati.join(", ") + '")',10000); }; - checkStatus = function(id, subjectstr) { + checkStatus = function(id) { if(id == "") return -1; - var opts = {method: 'get', action: 'model/' + id + '/status' + subjectstr, id: id}; + var opts = {method: 'get', action: 'model/' + id + '/status', id: id}; var status_changed = $.ajax({ type: opts.method, url: opts.action, @@ -62,7 +62,7 @@ $(function() { }; - checkProgress = function(id, subjectstr) { + checkProgress = function(id) { var task = $("input#model_" + id + "_task").attr('value'); var opts = {action: task + "/percentageCompleted" , id: id}; var progress_changed = $.ajax({ diff --git a/views/model.haml b/views/model.haml index e688ae9..670ba1a 100644 --- a/views/model.haml +++ b/views/model.haml @@ -65,26 +65,26 @@ %dt Training dataset: %dd - if model.training_dataset.match(/ambit/i) - %a{:href => "#{model.training_dataset}#{subjectstring}", :rel => "external"} Ambit database + %a{:href => "#{model.training_dataset}", :rel => "external"} Ambit database - else - %a{:href => "#{model.training_dataset}.xls#{subjectstring}"} Excel sheet + %a{:href => "#{model.training_dataset}.xls"} Excel sheet , -#%a{:href => "#{model.training_dataset}.rdf"} RDF/XML -#%em (experts) , - %a{:href => "#{model.training_dataset}.sdf#{subjectstring}" } SDF + %a{:href => "#{model.training_dataset}.sdf" } SDF , - %a{:href => "#{model.training_dataset}.yaml#{subjectstring}" } YAML + %a{:href => "#{model.training_dataset}.yaml" } YAML %em (experts) - if model.feature_dataset %dt Feature dataset: %dd -#%a{:href => "#{model.feature_dataset}.rdf"} RDF/XML -#, - %a{:href => "#{model.feature_dataset}.xls#{subjectstring}"} Excel sheet + %a{:href => "#{model.feature_dataset}.xls"} Excel sheet , - %a{:href => "#{model.feature_dataset}.sdf#{subjectstring}"} SDF + %a{:href => "#{model.feature_dataset}.sdf"} SDF , - %a{:href => "#{model.feature_dataset}.yaml#{subjectstring}"} YAML + %a{:href => "#{model.feature_dataset}.yaml"} YAML %em (experts) - if model.uri %dt Model: @@ -94,7 +94,7 @@ -#, - if model.validation_qmrf_uri %a{:href => File.join(model.validation_qmrf_uri,"editor")} QMRF Editor, - %a{:href => "#{model.uri}.yaml#{subjectstring}"} YAML + %a{:href => "#{model.uri}.yaml"} YAML %em (experts, models cannot be represented in Excel) - = haml :validation, :locals=>{:model=>model,:subjectstring => subjectstring}, :layout => false + = haml :validation, :locals=>{:model=>model}, :layout => false diff --git a/views/models.haml b/views/models.haml index 9ab2858..a1ef8ba 100644 --- a/views/models.haml +++ b/views/models.haml @@ -3,7 +3,7 @@ :javascript $(function() { if(#{stati != 0}) { - setTimeout('checkStati("#{stati_to_check}", "#{subjectstring}")',5000); + setTimeout('checkStati("#{stati_to_check}", "")',5000); } var reload_validation = true; }); @@ -20,6 +20,6 @@ - if @models - @models.each do |model| - = haml :model, :locals=>{:model=>model,:subjectstring=>subjectstring}, :layout => false --if @models.size == 0 + = haml :model, :locals=>{:model=>model}, :layout => false +-if @models.size == 0 .notice There are currently no models. You have to create a model first. diff --git a/views/validation.haml b/views/validation.haml index b8a6eaa..0a094d6 100644 --- a/views/validation.haml +++ b/views/validation.haml @@ -7,7 +7,7 @@ - if model.validation_report_uri %dt Detailed report: %dd - %a{:href => model.validation_report_uri + subjectstring, :target => "_blank"} show + %a{:href => model.validation_report_uri, :target => "_blank"} show %dt Number of predictions: %dd= model.nr_predictions.to_s - case model.type -- cgit v1.2.3 From f5eccd4ce22acb2fa05e84fb80e8385cce235d51 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 22 Aug 2011 16:23:00 +0000 Subject: NA inserted if valdiation parameters missing --- views/classification_validation.haml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/views/classification_validation.haml b/views/classification_validation.haml index 47e1f75..e06cb65 100644 --- a/views/classification_validation.haml +++ b/views/classification_validation.haml @@ -5,13 +5,24 @@ %dt %a{:href => "http://en.wikipedia.org/wiki/Receiver_operating_characteristic", :rel => "external"} Average area under ROC: %dd - = sprintf("%.3f", model.average_area_under_roc.to_f) if model.average_area_under_roc + - if model.average_area_under_roc + = sprintf("%.3f", model.average_area_under_roc.to_f) + - else + = 'NA' %dt %a{:href => "http://en.wikipedia.org/wiki/Sensitivity_and_specificity", :rel => "external"} Specificity: -%dd= sprintf("%.3f", model.specificity.to_f) if model.specificity +%dd + - if model.specificity + = sprintf("%.3f", model.specificity.to_f) + - else + = 'NA' %dt %a{:href => "http://en.wikipedia.org/wiki/Sensitivity_and_specificity", :rel => "external"} Sensitivity: -%dd= sprintf("%.3f", model.sensitivity.to_f) if model.sensitivity +%dd + - if model.sensitivity + = sprintf("%.3f", model.sensitivity.to_f) + - else + = 'NA' %dt %a{:href => "http://en.wikipedia.org/wiki/Confusion_matrix", :rel => "external"} Confusion Matrix: - if model.confusion_matrix -- cgit v1.2.3 From db81a67c87a4f048f297d60ee60a7632f4595854 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 24 Aug 2011 16:22:13 +0200 Subject: A&A do not show models without allow for GET request --- views/models.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/views/models.haml b/views/models.haml index a1ef8ba..e4f35b6 100644 --- a/views/models.haml +++ b/views/models.haml @@ -20,6 +20,7 @@ - if @models - @models.each do |model| - = haml :model, :locals=>{:model=>model}, :layout => false + - if is_authorized(model.web_uri, "GET") + = haml :model, :locals=>{:model=>model}, :layout => false -if @models.size == 0 .notice There are currently no models. You have to create a model first. -- cgit v1.2.3 From c242bfc291a7dab733c424968509709813e6e331 Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 30 Aug 2011 17:07:56 +0200 Subject: add model sorting --- application.rb | 15 ++++++++++- helper.rb | 5 ++++ views/models.haml | 8 +++--- views/models_navigation.haml | 61 ++++++++++++++++++++++++++++++++++++++++++++ views/style.sass | 23 +++++++++++++++++ 5 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 views/models_navigation.haml diff --git a/application.rb b/application.rb index 9ef50f8..c03915c 100644 --- a/application.rb +++ b/application.rb @@ -90,7 +90,20 @@ get '/login' do end get '/models/?' do - @models = ToxCreateModel.all.sort(:order => "DESC") + @page = params[:page] ? params[:page].to_i : 0 + order = params["order"] == "ASC" ? "ASC" : "DESC" + params["order"] = order + sort_by = params["sort_by"] + if sort_by + case sort_by + when "name", "created_at", "type", "id" + @models = ToxCreateModel.all.sort_by(sort_by.to_sym, :order => "#{order} ALPHA") + end + else + params["sort_by"] = "id" + end + + @models = ToxCreateModel.all.sort(:order => "DESC") unless @models @models.each{|m| raise "internal redis error: model is nil" unless m} haml :models, :locals=>{:models=>@models} end diff --git a/helper.rb b/helper.rb index 80707c3..799135b 100644 --- a/helper.rb +++ b/helper.rb @@ -91,5 +91,10 @@ helpers do haml :neighbors_navigation, :layout => false end + def models_navigation + @page = 0 unless @page + haml :models_navigation, :layout => false + end + end diff --git a/views/models.haml b/views/models.haml index a1ef8ba..d3ee8c0 100644 --- a/views/models.haml +++ b/views/models.haml @@ -17,9 +17,11 @@ = haml :regression, :layout => false = haml :similarity, :layout => false = haml :significant_fragments, :layout => false - -- if @models - - @models.each do |model| +- first = 5*@page +- last = first+4 += models_navigation +- if @models[first..last] + - @models[first..last].each do |model| = haml :model, :locals=>{:model=>model}, :layout => false -if @models.size == 0 .notice There are currently no models. You have to create a model first. diff --git a/views/models_navigation.haml b/views/models_navigation.haml new file mode 100644 index 0000000..fa5bd31 --- /dev/null +++ b/views/models_navigation.haml @@ -0,0 +1,61 @@ +.models_navigation + + %form{:name => "nav", :action => url_for('/models'), :method => "get", :id => "nav"} + %input{:type => :hidden, :name => :sort_by, :id => "sort_by", :value => params[:sort_by]} + %input{:type => :hidden, :name => :order, :id => "order", :value => params[:order]} + %input{:type => :hidden, :name => :subjectid, :value => session[:subjectid]} + %input{:type => :hidden, :name => :page, :id => "page", :value => params[:page]} + + Models are sorted by: + - ["id","created_at","name","type"].each do |s| + - idname = s == "created_at" ? "date" : s + - if params[:sort_by] == s + %div{:id => idname, :class => "active"} + %span="#{idname}" + - if params[:order] == "ASC" + #up{:class => "link"}= "⇓" + - else + #down{:class => "link"}= "⇑" + - else + %div{:id => idname, :class => "link"}="#{idname}" + | + models: + + #prev= "prev" unless @page.to_i == 0 + + - if @models.size < 5*@page+5 + - last = @models.size + - else + - last = 5*@page+5 + + = "(#{5*@page+1}-#{last}/#{@models.size})" + + #next= "next" unless 5*@page.to_i+5 >= @models.size + + - js = "" + - ["id","created_at","name","type"].each do |s| + - idname = s == "created_at" ? "date" : s + - js += "$('##{idname}').click(function() \{ \n " + - js += " $('#sort_by').val('#{s}');\n " + - js += " $('#nav').submit();\n " + - js += "});\n " + + :javascript + $("#prev").click(function() { + $("#page").val(#{@page-1}); + $("#nav").submit(); + }); + $("#next").click(function() { + $("#page").val(#{@page+1}); + $("#nav").submit(); + }); + #{js} + $("#down").click(function() { + $("#order").val("ASC"); + $("#nav").submit(); + }); + $("#up").click(function() { + $("#order").val("DESC"); + $("#nav").submit(); + }); + \ No newline at end of file diff --git a/views/style.sass b/views/style.sass index 15ae256..9f055e4 100644 --- a/views/style.sass +++ b/views/style.sass @@ -267,3 +267,26 @@ dl margin-left: 16px margin-right: 16px float: left + +.models_navigation + #prev + @extend a + display: inline + cursor: pointer + #next + @extend a + display: inline + cursor: pointer + .link + @extend a + display: inline + cursor: pointer + .active + display: inline + color: #000 + font-weight: bold + padding: 0 1px + .thin + font-weight: 100 + span + text-decoration: underline -- cgit v1.2.3 From aeb03ab4a64353d51830d14dbd82f5d19c7254c6 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 31 Aug 2011 11:22:21 +0200 Subject: sorting for id --- application.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/application.rb b/application.rb index c03915c..13bc02d 100644 --- a/application.rb +++ b/application.rb @@ -96,8 +96,10 @@ get '/models/?' do sort_by = params["sort_by"] if sort_by case sort_by - when "name", "created_at", "type", "id" + when "name", "created_at", "type" @models = ToxCreateModel.all.sort_by(sort_by.to_sym, :order => "#{order} ALPHA") + when "id" + @models = ToxCreateModel.all.sort(:order => "#{order}") end else params["sort_by"] = "id" -- cgit v1.2.3 From c6e75e0028c8e3d45a236b8d79f3c0d15092da61 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 31 Aug 2011 12:47:42 +0200 Subject: optimize models navigation | put authorized to view model to application.rb --- application.rb | 1 + public/arrow_down.png | Bin 0 -> 411 bytes public/arrow_up.png | Bin 0 -> 394 bytes views/models.haml | 3 +-- views/models_navigation.haml | 6 ++++-- views/style.sass | 2 -- 6 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 public/arrow_down.png create mode 100644 public/arrow_up.png diff --git a/application.rb b/application.rb index 13bc02d..12784f0 100644 --- a/application.rb +++ b/application.rb @@ -107,6 +107,7 @@ get '/models/?' do @models = ToxCreateModel.all.sort(:order => "DESC") unless @models @models.each{|m| raise "internal redis error: model is nil" unless m} + @models.delete_if{|m| !is_authorized(m.web_uri, "GET")} haml :models, :locals=>{:models=>@models} end diff --git a/public/arrow_down.png b/public/arrow_down.png new file mode 100644 index 0000000..d298656 Binary files /dev/null and b/public/arrow_down.png differ diff --git a/public/arrow_up.png b/public/arrow_up.png new file mode 100644 index 0000000..70417dc Binary files /dev/null and b/public/arrow_up.png differ diff --git a/views/models.haml b/views/models.haml index 6a181df..1419e37 100644 --- a/views/models.haml +++ b/views/models.haml @@ -17,11 +17,10 @@ = haml :regression, :layout => false = haml :similarity, :layout => false = haml :significant_fragments, :layout => false --# - if is_authorized(model.web_uri, "GET") - first = 5*@page - last = first+4 -= models_navigation += models_navigation if @models.size > 1 - if @models[first..last] - @models[first..last].each do |model| = haml :model, :locals=>{:model=>model}, :layout => false diff --git a/views/models_navigation.haml b/views/models_navigation.haml index fa5bd31..d324fce 100644 --- a/views/models_navigation.haml +++ b/views/models_navigation.haml @@ -13,9 +13,11 @@ %div{:id => idname, :class => "active"} %span="#{idname}" - if params[:order] == "ASC" - #up{:class => "link"}= "⇓" + #up{:class => "link"} + %img{:src => "arrow_down.png", :alt => 'in ascending order', :title => 'in ascending order'}/ - else - #down{:class => "link"}= "⇑" + #down{:class => "link"} + %img{:src => "arrow_up.png", :alt => 'in descending order', :title => 'in descending order'}/ - else %div{:id => idname, :class => "link"}="#{idname}" | diff --git a/views/style.sass b/views/style.sass index 9f055e4..56eee02 100644 --- a/views/style.sass +++ b/views/style.sass @@ -288,5 +288,3 @@ dl padding: 0 1px .thin font-weight: 100 - span - text-decoration: underline -- cgit v1.2.3 From 2fadf0789c47b49e5c47997d6e392faa7da88230 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 31 Aug 2011 16:10:51 +0200 Subject: sorting functionality for models page --- public/arrow_left.png | Bin 0 -> 374 bytes public/arrow_left_inactive.png | Bin 0 -> 364 bytes public/arrow_right.png | Bin 0 -> 386 bytes public/arrow_right_inactive.png | Bin 0 -> 400 bytes views/models_navigation.haml | 31 ++++++++++++++++++------------- views/style.sass | 1 - 6 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 public/arrow_left.png create mode 100644 public/arrow_left_inactive.png create mode 100644 public/arrow_right.png create mode 100644 public/arrow_right_inactive.png diff --git a/public/arrow_left.png b/public/arrow_left.png new file mode 100644 index 0000000..8d18c67 Binary files /dev/null and b/public/arrow_left.png differ diff --git a/public/arrow_left_inactive.png b/public/arrow_left_inactive.png new file mode 100644 index 0000000..52c11bf Binary files /dev/null and b/public/arrow_left_inactive.png differ diff --git a/public/arrow_right.png b/public/arrow_right.png new file mode 100644 index 0000000..7fe64a8 Binary files /dev/null and b/public/arrow_right.png differ diff --git a/public/arrow_right_inactive.png b/public/arrow_right_inactive.png new file mode 100644 index 0000000..496f79e Binary files /dev/null and b/public/arrow_right_inactive.png differ diff --git a/views/models_navigation.haml b/views/models_navigation.haml index d324fce..4b3ba2d 100644 --- a/views/models_navigation.haml +++ b/views/models_navigation.haml @@ -3,15 +3,14 @@ %form{:name => "nav", :action => url_for('/models'), :method => "get", :id => "nav"} %input{:type => :hidden, :name => :sort_by, :id => "sort_by", :value => params[:sort_by]} %input{:type => :hidden, :name => :order, :id => "order", :value => params[:order]} - %input{:type => :hidden, :name => :subjectid, :value => session[:subjectid]} %input{:type => :hidden, :name => :page, :id => "page", :value => params[:page]} Models are sorted by: - - ["id","created_at","name","type"].each do |s| - - idname = s == "created_at" ? "date" : s + - ["id","created_at","name","type"].each do |s| + - idname = s == "created_at" ? "date" : s - if params[:sort_by] == s %div{:id => idname, :class => "active"} - %span="#{idname}" + %span="#{idname.capitalize}" - if params[:order] == "ASC" #up{:class => "link"} %img{:src => "arrow_down.png", :alt => 'in ascending order', :title => 'in ascending order'}/ @@ -19,20 +18,26 @@ #down{:class => "link"} %img{:src => "arrow_up.png", :alt => 'in descending order', :title => 'in descending order'}/ - else - %div{:id => idname, :class => "link"}="#{idname}" + %div{:id => idname, :class => "link"}="#{idname.capitalize} " | - models: - - #prev= "prev" unless @page.to_i == 0 + Models: + - unless @page.to_i == 0 + #prev + %img{:src => "arrow_left.png", :alt => 'previous', :title => 'previous'}/ + -else + %img{:src => "arrow_left_inactive.png", :alt => '', :title => ''}/ - if @models.size < 5*@page+5 - - last = @models.size - - else + - last = @models.size + - else - last = 5*@page+5 - = "(#{5*@page+1}-#{last}/#{@models.size})" - - #next= "next" unless 5*@page.to_i+5 >= @models.size + = "(#{5*@page+1}-#{last}/#{@models.size})" + - unless 5*@page.to_i+5 >= @models.size + #next + %img{:src => "arrow_right.png", :alt => 'next', :title => 'next'}/ + -else + %img{:src => "arrow_right_inactive.png", :alt => '', :title => ''}/ - js = "" - ["id","created_at","name","type"].each do |s| diff --git a/views/style.sass b/views/style.sass index 56eee02..23b157a 100644 --- a/views/style.sass +++ b/views/style.sass @@ -285,6 +285,5 @@ dl display: inline color: #000 font-weight: bold - padding: 0 1px .thin font-weight: 100 -- cgit v1.2.3 From 7ec60be28a09f748ee624e8b44bdc2e936de71f9 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 31 Aug 2011 17:06:54 +0200 Subject: show pages only if more than 5 models --- views/models_navigation.haml | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/views/models_navigation.haml b/views/models_navigation.haml index 4b3ba2d..ed8b720 100644 --- a/views/models_navigation.haml +++ b/views/models_navigation.haml @@ -19,25 +19,27 @@ %img{:src => "arrow_up.png", :alt => 'in descending order', :title => 'in descending order'}/ - else %div{:id => idname, :class => "link"}="#{idname.capitalize} " - | - Models: - - unless @page.to_i == 0 - #prev - %img{:src => "arrow_left.png", :alt => 'previous', :title => 'previous'}/ - -else - %img{:src => "arrow_left_inactive.png", :alt => '', :title => ''}/ - - - if @models.size < 5*@page+5 - - last = @models.size - - else - - last = 5*@page+5 - - = "(#{5*@page+1}-#{last}/#{@models.size})" - - unless 5*@page.to_i+5 >= @models.size - #next - %img{:src => "arrow_right.png", :alt => 'next', :title => 'next'}/ - -else - %img{:src => "arrow_right_inactive.png", :alt => '', :title => ''}/ + - if @models.size > 5 + | + Models: + = "#{@models.size}" + - unless @page.to_i == 0 + #prev + %img{:src => "arrow_left.png", :alt => 'previous', :title => 'previous'}/ + -else + %img{:src => "arrow_left_inactive.png", :alt => '', :title => ''}/ + + - if @models.size < 5*@page+5 + - last = @models.size + - else + - last = 5*@page+5 + + = "(#{5*@page+1}-#{last}/#{@models.size})" + - unless 5*@page.to_i+5 >= @models.size + #next + %img{:src => "arrow_right.png", :alt => 'next', :title => 'next'}/ + -else + %img{:src => "arrow_right_inactive.png", :alt => '', :title => ''}/ - js = "" - ["id","created_at","name","type"].each do |s| -- cgit v1.2.3 From 9299e2d50ac9f63ef30b7d5ead662b8f2f2df78f Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 31 Aug 2011 17:23:27 +0200 Subject: make w3c valid --- views/create.haml | 19 ++++++++++--------- views/predict.haml | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/views/create.haml b/views/create.haml index b706484..5dbd71d 100644 --- a/views/create.haml +++ b/views/create.haml @@ -47,15 +47,16 @@ structure-activity models from your experimental data. The models can be used to predict toxicity of new chemicals (e.g. for %a{:href => "http://ec.europa.eu/environment/chemicals/reach/reach_intro.htm", :rel => "external"} REACH purposes) and to reduce the need for animal testing. The following methods are currently available: - %ul - %li - = toggle_link("#lazar_description","lazar") - %em= toggle_link("#classification","classification") - models and - %li - = toggle_link("#lazar_description","lazar") - %em= toggle_link("#regression","regression") - models (experimental) + %ul + %li + = toggle_link("#lazar_description","lazar") + %em= toggle_link("#classification","classification") + models and + %li + = toggle_link("#lazar_description","lazar") + %em= toggle_link("#regression","regression") + models (experimental) + %p Further modelling algorithms may be added in future versions. .login_notice diff --git a/views/predict.haml b/views/predict.haml index 8aae7cf..670ca44 100644 --- a/views/predict.haml +++ b/views/predict.haml @@ -20,7 +20,7 @@ %span{:style=>"font-size:75%"} © %a{:href => 'http://www.molinspiration.com/jme/index.html', :rel => "external"} JME Editor - courtesy of Peter Ertl, Novartis + courtesy of Peter Ertl, Novartis %br -# %label{:for => 'identifier'} or enter a Name, InChI, Smiles, CAS, ... %label{:for => 'identifier'} or enter a Smiles string -- cgit v1.2.3 From 038c4563032f65f935f38ef6bffe426b2dd14c0c Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 14 Sep 2011 10:05:47 +0200 Subject: Endpoint selection from ontology server with cache --- helper.rb | 21 ++++++++++++++++++++- views/create.haml | 2 ++ views/endpoint.haml | 2 +- views/model_echa.haml | 2 ++ views/style.sass | 10 ++++++++++ 5 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 views/model_echa.haml diff --git a/helper.rb b/helper.rb index 799135b..9b47142 100644 --- a/helper.rb +++ b/helper.rb @@ -96,5 +96,24 @@ helpers do haml :models_navigation, :layout => false end + def endpoint_option_list(max_time=3600) + out = "" + tmpfile = File.join(TMP_DIR, "endpoint_option_list") + if File.exists? tmpfile + if Time.now-File.mtime(tmpfile) <= max_time + f = File.open(tmpfile, 'r+') + f.each{|line| out << line} + return out + else + File.unlink(tmpfile) + end + end + result = OpenTox::Ontology::Echa.endpoint_option_list() + if result.lines.count > 3 + f = File.new(tmpfile,"w") + f.print result + f.close + end + return result + end end - diff --git a/views/create.haml b/views/create.haml index 5dbd71d..da85382 100644 --- a/views/create.haml +++ b/views/create.haml @@ -24,6 +24,8 @@ = link_to "SDF", '/help' format: %input{:type => 'file', :name => 'file', :id => 'file', :size => '41'} + %br + -# = haml :model_echa, :layout => false %input{ :type => "submit", :value => "Create model"} =# link_to "Cancel", '/create' diff --git a/views/endpoint.haml b/views/endpoint.haml index af06b80..9c250ca 100644 --- a/views/endpoint.haml +++ b/views/endpoint.haml @@ -9,4 +9,4 @@ %em in-vitro, or %em in-vivo - expriment, clinical trial or epidemiological study + experiment, clinical trial or epidemiological study diff --git a/views/model_echa.haml b/views/model_echa.haml new file mode 100644 index 0000000..257a28a --- /dev/null +++ b/views/model_echa.haml @@ -0,0 +1,2 @@ +Select an endpoint: += endpoint_option_list \ No newline at end of file diff --git a/views/style.sass b/views/style.sass index 23b157a..c2a74cb 100644 --- a/views/style.sass +++ b/views/style.sass @@ -287,3 +287,13 @@ dl font-weight: bold .thin font-weight: 100 + +.level_1 + padding-left: 10px + font-weight: bold +.level_2 + padding-left: 20px +.level_3 + padding-left: 30px +.level_4 + padding-left: 40px -- cgit v1.2.3 From e967ffe75370d39d0928e440a9023e2da6e35ae3 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 21 Sep 2011 11:16:28 +0200 Subject: remove id from sort tab --- application.rb | 2 +- views/models_navigation.haml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application.rb b/application.rb index 12784f0..2b320e0 100644 --- a/application.rb +++ b/application.rb @@ -102,7 +102,7 @@ get '/models/?' do @models = ToxCreateModel.all.sort(:order => "#{order}") end else - params["sort_by"] = "id" + params["sort_by"] = "created_at" end @models = ToxCreateModel.all.sort(:order => "DESC") unless @models diff --git a/views/models_navigation.haml b/views/models_navigation.haml index ed8b720..b491cb5 100644 --- a/views/models_navigation.haml +++ b/views/models_navigation.haml @@ -5,8 +5,8 @@ %input{:type => :hidden, :name => :order, :id => "order", :value => params[:order]} %input{:type => :hidden, :name => :page, :id => "page", :value => params[:page]} - Models are sorted by: - - ["id","created_at","name","type"].each do |s| + Sort by: + - ["created_at","name","type"].each do |s| - idname = s == "created_at" ? "date" : s - if params[:sort_by] == s %div{:id => idname, :class => "active"} -- cgit v1.2.3