summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2016-09-22 19:33:40 +0000
committergebele <gebele@in-silico.ch>2016-09-22 19:33:40 +0000
commitd160d2c5be9ea52b9b5e9f8a4895e6ccf464c938 (patch)
treef97c05ff7b72520b8a782cc1237e9c3f206f32d9
parent79bcc6575eb30c4fddcc77ffdc183f79d2d1cc0d (diff)
select list core; sorted pcp
-rw-r--r--application.rb10
-rw-r--r--views/predict.haml15
-rw-r--r--views/prediction.haml36
3 files changed, 34 insertions, 27 deletions
diff --git a/application.rb b/application.rb
index 3ffc080..86fdb1f 100644
--- a/application.rb
+++ b/application.rb
@@ -12,7 +12,10 @@ end
get '/?' do
redirect to('/predict')
end
-
+=begin
+get '/qsar-report/:id' do
+end
+=end
get '/predict/?' do
@prediction_models = []
prediction_models = OpenTox::Model::NanoPrediction.all
@@ -57,7 +60,9 @@ post '/predict/?' do
# unchanged input = database hit
nanoparticle = OpenTox::Nanoparticle.find_by(:id => params[:example_id])
nanoparticle.physchem_descriptors = input_pc
- @match = true,@nanoparticle = nanoparticle,@name = nanoparticle.name
+ @match = true
+ @nanoparticle = nanoparticle
+ @name = nanoparticle.name
else
# changed input = create nanoparticle to predict
nanoparticle = OpenTox::Nanoparticle.new
@@ -65,6 +70,7 @@ post '/predict/?' do
nanoparticle.coating = input_coating
nanoparticle.physchem_descriptors = input_pc
@match = false
+ @nanoparticle = nanoparticle
end
# output
@input = input_pc
diff --git a/views/predict.haml b/views/predict.haml
index ad263d1..81383b1 100644
--- a/views/predict.haml
+++ b/views/predict.haml
@@ -64,9 +64,9 @@
= "R square:\t"
= cv.r_squared.round(3) if cv.r_squared
%br
- %b QSAR report
- %br
- %a{:href=>to('/qsar-report/'+m.id)} download
+ //%b QSAR report
+ //%br
+ //%a{:href=>to('/qsar-report/'+m.id)} download
%hr
%form{:id=>idx, :role=>"form", :action=> to("/predict"), :method=>"post"}
%h3.help-block
@@ -83,15 +83,18 @@
%input{:id=>"size",:type=>"hidden",:name=>"size",:value=>size}
%input{:id=>"id",:type=>"hidden",:name=>"example_id",:value=>example.id}
// input form parameters to transfer
- %h5 Core
- %input.input-sm.form-control{:id=>"core",:type=>"text",:name=>"input_core",:value=>example.core["name"]}
+ %div.form-group
+ %label{:for=>"selCore#{idx}"} Core
+ %select.form-control{:id=>"selCore#{idx}", :name=>"input_core",:value=>example.core["name"]}
+ %option{:selected => ("selected" if example.core["name"] == "Ag")} Ag
+ %option{:selected => ("selected" if example.core["name"] == "Au")} Au
%input{:id=>"input_core",:type=>"hidden",:name=>"in_core",:value=>"#{example.core}"}
%h5 Coating
%input.input-sm.form-control{:id=>"coating",:type=>"text",:name=>"input_coating",:value=>example.coating[0]["name"]}
%input{:id=>"input_coating",:type=>"hidden",:name=>"in_coating",:value=>example.coating}
// prediction model id
%input{:id=>"prediction_model",:type=>"hidden",:name=>"prediction_model",:value=>m.id}
- - example.physchem_descriptors.each_with_index do |v,id|
+ - example.physchem_descriptors.sort_by{|d| OpenTox::Feature.find(d[0]).category}.each_with_index do |v,id|
- feature = OpenTox::Feature.find_by(:id => v[0])
- name = feature.name
- if feature[:conditions] && !feature[:conditions]["MEDIUM"].blank?
diff --git a/views/prediction.haml b/views/prediction.haml
index 0438f1f..3913b3e 100644
--- a/views/prediction.haml
+++ b/views/prediction.haml
@@ -38,7 +38,7 @@
Toxicity
%br
Net cell association [mL/ug(Mg)]
- - @input.each do |key|
+ - @input.sort_by{|d| OpenTox::Feature.find(d[0]).category}.each do |key|
- feature = OpenTox::Feature.find_by(:id=>key[0])
- name = feature.name
- if (feature[:conditions] && !feature[:conditions]["MEDIUM"].blank?)
@@ -73,7 +73,12 @@
= @nanoparticle[:coating][0]["name"]
%br
- else
- %h5.th5 x
+ %h5.th5 Core:
+ = "["+@nanoparticle[:core]["name"]+"]"
+ %br
+ %h5.th5 Coating:
+ = @nanoparticle[:coating][0]["name"]
+ %br
/ tox
%td.tox
- if @prediction[:value]
@@ -93,28 +98,21 @@
- interval = @prediction[:prediction_interval].nil? ? " - - " : @prediction[:prediction_interval].collect{|i| i.round(2)}
= "#{interval[0]} - #{interval[1]}"
- if @prediction[:measurements]
- %hr
+ %br
+ %br
%h5.th5 Measurement:
- @prediction[:measurements].each do |m|
= m
- if !@prediction[:value] && !@prediction[:measurements]
%h5.th5 not available
/ physchem
- - if @prediction[:match]
- - sorted = {}
- - @input.each{|i| sorted[i[0]]=@prediction[:match].values[0]["physchem"][i[0]]}
- - sorted.each do |k,v|
- %td.physchem
- %div{:style=>"display:inline-block;padding-right:20px;"}
- %p= v[0].round(3)
- - else
- - @input.each do |v|
- %td.physchem
- %div{:style=>"display:inline-block;padding-right:20px;"}
- - if v[1].nil?
- %p x
- - else
- %p= v[1][0].round(3)
+ - @input.sort_by{|d| OpenTox::Feature.find(d[0]).category}.each do |v|
+ %td.physchem
+ %div{:style=>"display:inline-block;padding-right:20px;"}
+ - if v[1].nil?
+ %p x
+ - else
+ %p= v[1][0].round(3)
/ neighbors
- if @prediction[:neighbors]
@@ -142,7 +140,7 @@
= neighbor["measurements"][0]
/ Physchem
-#- @input.each do |k,v|
- - nano.physchem_descriptors.each do |k,v|
+ - nano.physchem_descriptors.sort_by{|d| OpenTox::Feature.find(d[0]).category}.each do |k,v|
%td.physchem
%div
%div{:style=>"display:inline-block;padding-right:20px;"}