From fad3229cca5d31670f1c1d99542f3d563e226d99 Mon Sep 17 00:00:00 2001 From: mr Date: Fri, 23 Sep 2011 10:34:34 +0200 Subject: endpoint selection for create model form --- application.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'application.rb') diff --git a/application.rb b/application.rb index 12784f0..3ed2af6 100644 --- a/application.rb +++ b/application.rb @@ -232,8 +232,8 @@ end post '/models' do # create a new model - unless (params[:dataset] and params[:prediction_feature]) or (params[:file] and params[:file][:tempfile]) #params[:endpoint] and - flash[:notice] = "Please upload a Excel or CSV file or select an AMBIT dataset." + unless (params[:dataset] and params[:prediction_feature]) or (params[:endpoint] and params[:file] and params[:file][:tempfile]) #params[:endpoint] and + flash[:notice] = "Please upload a Excel or CSV file and select an endpoint or select an AMBIT dataset." redirect url_for('/create') end -- cgit v1.2.3 From 99a50ecb6c6cbff678048c2f60eafcfe476c1b64 Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 10 Oct 2011 12:47:52 +0200 Subject: add endpoint to features --- application.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'application.rb') diff --git a/application.rb b/application.rb index 3ed2af6..a75c6c0 100644 --- a/application.rb +++ b/application.rb @@ -1,7 +1,7 @@ ['rubygems', "haml", "sass", "rack-flash"].each do |lib| require lib end -gem "opentox-ruby", "~> 2" +gem "opentox-ruby", "~> 3" require 'opentox-ruby' gem 'sinatra-static-assets' require 'sinatra/static_assets' @@ -280,6 +280,7 @@ post '/models' do # create a new model else raise "#{params[:file][:filename]} has an unsupported file type." end + @dataset.features[@dataset.features.keys.first][OWL.sameAs] = params[:endpoint].split(',').first if params[:endpoint] @dataset.save(@subjectid) rescue => e error "Dataset creation failed '#{e.message}'",e @@ -290,7 +291,6 @@ post '/models' do # create a new model @prediction_feature = OpenTox::Feature.find(@dataset.features.keys.first,@subjectid) end end - task.progress(10) if @dataset.compounds.size < 10 error "Too few compounds to create a prediction model. Did you provide compounds in SMILES format and classification activities as described in the #{link_to "instructions", "/help"}? As a rule of thumb you will need at least 100 training compounds for nongeneric datasets. A lower number could be sufficient for congeneric datasets." -- cgit v1.2.3 From 680b552ce6d135a1730f83eb23da44ae244c2aa8 Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 11 Oct 2011 12:37:14 +0200 Subject: endpoint for external dataset --- application.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'application.rb') diff --git a/application.rb b/application.rb index a75c6c0..50aee72 100644 --- a/application.rb +++ b/application.rb @@ -281,6 +281,7 @@ post '/models' do # create a new model raise "#{params[:file][:filename]} has an unsupported file type." end @dataset.features[@dataset.features.keys.first][OWL.sameAs] = params[:endpoint].split(',').first if params[:endpoint] + @model.update :endpoint_uri => params[:endpoint].split(',').first, :endpoint => params[:endpoint].split(',')[1..99].to_s.gsub(/^"(.*?)"$/,'\1') if params[:endpoint] @dataset.save(@subjectid) rescue => e error "Dataset creation failed '#{e.message}'",e @@ -290,6 +291,11 @@ post '/models' do # create a new model else @prediction_feature = OpenTox::Feature.find(@dataset.features.keys.first,@subjectid) end + #else + # test when external dataset is enabled: + #if @dataset.features[@dataset.features.keys.first][OWL.sameAs] + # @model.update :endpoint_uri => @dataset.features[@dataset.features.keys.first][OWL.sameAs], :endpoint => OpenTox::Ontology::Echa.get_endpoint_name(@dataset.features[@dataset.features.keys.first][OWL.sameAs]) + #end end task.progress(10) if @dataset.compounds.size < 10 -- cgit v1.2.3 From 5147b37a3285a231d8c938c3baf2f216a3b7f197 Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 17 Oct 2011 10:04:44 +0200 Subject: model sorting for endpoints| pager for models --- application.rb | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'application.rb') diff --git a/application.rb b/application.rb index c41f072..019592c 100644 --- a/application.rb +++ b/application.rb @@ -96,8 +96,22 @@ get '/models/?' do sort_by = params["sort_by"] if sort_by case sort_by - when "name", "created_at", "type" - @models = ToxCreateModel.all.sort_by(sort_by.to_sym, :order => "#{order} ALPHA") + when "created_at" + @models = ToxCreateModel.all.sort(:order => "#{order}") + when "name" + @models = ToxCreateModel.all.sort + if order == "ASC" + @models = @models.sort_by{|x| x.name.downcase} + else + @models = @models.sort{|x, y| y.name.downcase <=> x.name.downcase} + end + when "type", "endpoint" + @models = ToxCreateModel.all.sort + if order == "ASC" + @models = @models.sort_by{|x| [x.send(sort_by.to_sym),x.name.downcase]} + else + @models = @models.sort{|x,y|[y.send(sort_by.to_sym),x.name.downcase] <=> [x.send(sort_by.to_sym), y.name.downcase]} + end when "id" @models = ToxCreateModel.all.sort(:order => "#{order}") end @@ -186,8 +200,9 @@ get '/model/:id/:view/?' do end get '/predict/?' do - @models = ToxCreateModel.all.sort(:order => "DESC") + @models = ToxCreateModel.all.sort @models = @models.collect{|m| m if m.status == 'Completed'}.compact + @models = @models.sort_by{|x| [x.endpoint,x.name.downcase] } haml :predict end -- cgit v1.2.3 From f60f559c98343b36ed50cfba1a365f2738f59a68 Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 17 Oct 2011 12:32:27 +0200 Subject: clean code for navigation --- application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'application.rb') diff --git a/application.rb b/application.rb index 019592c..6cdfcfb 100644 --- a/application.rb +++ b/application.rb @@ -202,7 +202,7 @@ end get '/predict/?' do @models = ToxCreateModel.all.sort @models = @models.collect{|m| m if m.status == 'Completed'}.compact - @models = @models.sort_by{|x| [x.endpoint,x.name.downcase] } + @models = @models.sort_by{|x| [x.endpoint ? x.endpoint : "",x.name.downcase]} haml :predict end -- cgit v1.2.3