From 4f83500afb33612cadd7084470ab9b42dfa59cf2 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 4 Aug 2011 10:24:38 +0000 Subject: activity highlighting and significant features fixed --- application.rb | 3 ++- helper.rb | 10 +++++----- views/lazar.haml | 4 ++-- views/neighbors.haml | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/application.rb b/application.rb index 328384a..21030aa 100644 --- a/application.rb +++ b/application.rb @@ -413,8 +413,9 @@ 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.new @model_uri + lazar = OpenTox::Model::Lazar.find @model_uri prediction_dataset_uri = lazar.run(:compound_uri => params[:compound_uri], :subjectid => session[:subjectid]) + @value_map = lazar.value_map @prediction = OpenTox::LazarPrediction.find(prediction_dataset_uri, session[:subjectid]) @compound = OpenTox::Compound.new(params[:compound_uri]) haml :lazar diff --git a/helper.rb b/helper.rb index 408f8bc..943a182 100644 --- a/helper.rb +++ b/helper.rb @@ -51,20 +51,20 @@ helpers do haml :js_link, :locals => {:name => name, :destination => destination, :method => "toggle"}, :layout => false end - def sort(descriptors) + def sort(descriptors,value_map) features = {:activating => [], :deactivating => []} descriptors.each do |d| - if d[OT.effect] =~ TRUE_REGEXP + if value_map[d[OT.effect]] =~ TRUE_REGEXP features[:activating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]} - elsif d[OT.effect] =~ FALSE_REGEXP + elsif value_map[d[OT.effect]] =~ FALSE_REGEXP features[:deactivating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]} end end features end - def compound_image(compound,descriptors) - haml :compound_image, :locals => {:compound => compound, :features => sort(descriptors)}, :layout => false + def compound_image(compound,descriptors,value_map) + haml :compound_image, :locals => {:compound => compound, :features => sort(descriptors,value_map)}, :layout => false end def activity_markup(activity) diff --git a/views/lazar.haml b/views/lazar.haml index 3f1d030..2912567 100644 --- a/views/lazar.haml +++ b/views/lazar.haml @@ -18,7 +18,7 @@ %th Supporting information %tr - %td.image= compound_image(@compound,@prediction.descriptors(@compound)) + %td.image= compound_image(@compound,@prediction.descriptors(@compound),@value_map) %td= activity_markup(@prediction.value(@compound)) %td= sprintf('%.03g', @prediction.confidence(@compound)) %td @@ -40,7 +40,7 @@ %tr#fragments{ :style => "display: none;" } %td{:colspan => '4'} = hide_link('#fragments') - = haml :feature_table, :locals => {:features => sort(@prediction.descriptors(@compound))}, :layout => false + = haml :feature_table, :locals => {:features => sort(@prediction.descriptors(@compound),@value_map)}, :layout => false %tbody#neighbors = haml :neighbors, :locals => {:neighbors => @prediction.neighbors(@compound), :page => @page}, :layout => false diff --git a/views/neighbors.haml b/views/neighbors.haml index 2df9230..3f1dccd 100644 --- a/views/neighbors.haml +++ b/views/neighbors.haml @@ -13,8 +13,8 @@ - neighbor_id += 1 - compound = OpenTox::Compound.new(neighbor[OT.compound]) %tr - %td.image= compound_image(compound,@prediction.descriptors(compound)) - %td= activity_markup(neighbor[OT.measuredActivity]) + %td.image= compound_image(compound,@prediction.descriptors(compound),@value_map) + %td= activity_markup(@value_map[neighbor[OT.measuredActivity].to_i]) %td= sprintf('%.03g', neighbor[OT.similarity]) %td %ul @@ -39,5 +39,5 @@ %tr{:id => "fragments#{neighbor_id}", :style => "display: none;" } %td{:colspan => '4'} = hide_link("#fragments#{neighbor_id}") - = haml :feature_table, :locals => {:features => sort(@prediction.descriptors(compound))}, :layout => false + = haml :feature_table, :locals => {:features => sort(@prediction.descriptors(compound),@value_map)}, :layout => false -- cgit v1.2.3