From 13313d9fa8f5e4b29bbbc0ddeb0e455765b0774d Mon Sep 17 00:00:00 2001 From: opentox Date: Wed, 15 Jun 2011 18:50:47 +0200 Subject: cactvs name lookup disabled --- application.rb | 2 +- views/predict.haml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/application.rb b/application.rb index 60d50cd..8d96dbe 100644 --- a/application.rb +++ b/application.rb @@ -338,7 +338,7 @@ post '/predict/?' do # post chemical name to model redirect url_for('/predict') end begin - @compound = OpenTox::Compound.from_name(params[:identifier]) + @compound = OpenTox::Compound.from_smiles(params[:identifier]) rescue flash[:notice] = "Could not find a structure for '#{@identifier}'. Please try again." redirect url_for('/predict') diff --git a/views/predict.haml b/views/predict.haml index ec667e6..7d5e30a 100644 --- a/views/predict.haml +++ b/views/predict.haml @@ -23,7 +23,8 @@ %a{:href => 'http://www.molinspiration.com/jme/index.html', :rel => "external"} JME Editor courtesy of Peter Ertl, Novartis %br - %label{:for => 'identifier'} or enter a Name, InChI, Smiles, CAS, ... + -# %label{:for => 'identifier'} or enter a Name, InChI, Smiles, CAS, ... + %label{:for => 'identifier'} or enter a Smiles string %input{:type => 'text', :name => 'identifier', :id => 'identifier', :size => '60'} %br %fieldset -- cgit v1.2.3 From aa588fc87f1a892f3de903f5d60df68d4eaa6b52 Mon Sep 17 00:00:00 2001 From: mr Date: Thu, 4 Aug 2011 17:49:29 +0200 Subject: ul in p --- views/help.haml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/views/help.haml b/views/help.haml index 2b39d6c..f602dff 100644 --- a/views/help.haml +++ b/views/help.haml @@ -87,13 +87,13 @@ %p Excel examples for download: - %ul - %li - = link_to "hamster_carcinogenicity.xls", "/hamster_carcinogenicity.xls" - (classification) - %li - = link_to "EPAFHM.xls", "/EPAFHM.xls" - (regression) +%ul + %li + = link_to "hamster_carcinogenicity.xls", "/hamster_carcinogenicity.xls" + (classification) + %li + = link_to "EPAFHM.xls", "/EPAFHM.xls" + (regression) %h3 CSV example @@ -113,13 +113,13 @@ %p CSV examples for download: - %ul - %li - = link_to "hamster_carcinogenicity.csv", "/hamster_carcinogenicity.csv" - (classification) - %li - = link_to "EPAFHM.csv", "/EPAFHM.csv" - (regression) +%ul + %li + = link_to "hamster_carcinogenicity.csv", "/hamster_carcinogenicity.csv" + (classification) + %li + = link_to "EPAFHM.csv", "/EPAFHM.csv" + (regression) %p You can create CSV files in Excel: Create a sheet with two columns and export them as CSV file with the "Save As" option from the menu, selecting the CSV (comma delimited) format. -- cgit v1.2.3 From 2adbb8fff2563616e85680c0326a8fa0421fd666 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 8 Aug 2011 11:14:11 +0000 Subject: doubled date removed --- views/layout.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/layout.haml b/views/layout.haml index c76396d..96f7d35 100644 --- a/views/layout.haml +++ b/views/layout.haml @@ -51,7 +51,7 @@ Disclaimer: ToxCreate uses state-of-the-art published and tested algorithms and methodologies with full validation information. However, just as with experimental measurements, computational predictions are subject to varying degrees of accuracy and uncertainty, so please read the full report carefully, particularly the validation information. No liability is accepted for any inaccuracy in predictions. %p - tag = `git tag`.split("\n").last - - tagdate = `git show #{tag}|grep Date`.chomp + - tagdate = `git show #{tag}|grep Date`.split("\n").last Version: = tag , -- cgit v1.2.3 From e2f8adcc24470548f0c4a7d9b5cb0d4ab929fb51 Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 16 Aug 2011 12:26:59 +0200 Subject: fix typo in html code --- views/predict.haml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/views/predict.haml b/views/predict.haml index 7d5e30a..8aae7cf 100644 --- a/views/predict.haml +++ b/views/predict.haml @@ -17,9 +17,8 @@ %applet{:code => "JME.class", :name => "JME", :archive => "JME.jar", :width => "500", :height => "360"} %param{ :name => "options", :value => "polarnitro"} Please enable Java and JavaScript in your browser to use the JME editor. - - %jme_info - © + %span{:style=>"font-size:75%"} + © %a{:href => 'http://www.molinspiration.com/jme/index.html', :rel => "external"} JME Editor courtesy of Peter Ertl, Novartis %br -- cgit v1.2.3 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