summaryrefslogtreecommitdiff
path: root/helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'helper.rb')
-rw-r--r--helper.rb52
1 files changed, 45 insertions, 7 deletions
diff --git a/helper.rb b/helper.rb
index 2fe8785..698fd3e 100644
--- a/helper.rb
+++ b/helper.rb
@@ -51,23 +51,60 @@ 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 { |d| features[d[OT.effect].to_sym] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]} }
+ descriptors.each do |d|
+ if !value_map.empty?
+ features[:activating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]} if d[OT.effect] == 2
+ features[:deactivating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]} if d[OT.effect] == 1
+ else
+ if d[OT.effect] =~ TRUE_REGEXP
+ features[:activating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]}
+ elsif d[OT.effect] =~ FALSE_REGEXP
+ features[:deactivating] << {:smarts => d[OT.smarts],:p_value => d[OT.pValue]}
+ end
+ 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)
+ def activity_markup(activity,value_map)
+ if value_map and !value_map.empty?
+ if value_map.size == 2
+ activity = value_map.index(activity) if value_map.has_value? activity
+ if activity.to_i == 2
+ haml ".active #{value_map[activity]}", :layout => false
+ elsif activity.to_i == 1
+ haml ".inactive #{value_map[activity]}", :layout => false
+ else
+ haml ".other #{activity.to_s}", :layout => false
+ end
+ else
+ haml ".other #{activity.to_s}", :layout => false
+ end
+ elsif OpenTox::Algorithm::numeric? activity
+ haml ".other #{sprintf('%.03g', activity.to_f)}", :layout => false
+ else
+ haml ".other #{activity.to_s}", :layout => false
+ end
+=begin
case activity.class.to_s
when /Float/
haml ".other #{sprintf('%.03g', activity)}", :layout => false
when /String/
- haml ".other #{activity.to_s}", :layout => false
- else
+ case activity
+ when "true"
+ haml ".active active", :layout => false
+ when "false"
+ haml ".inactive inactive", :layout => false
+ else
+ haml ".other #{activity.to_s}", :layout => false
+ end
+ else
if activity #true
haml ".active active", :layout => false
elsif !activity # false
@@ -76,6 +113,7 @@ helpers do
haml ".other #{activity.to_s}", :layout => false
end
end
+=end
end
def neighbors_navigation