diff options
author | mguetlein <martin.guetlein@gmail.com> | 2011-05-12 12:45:18 +0200 |
---|---|---|
committer | mguetlein <martin.guetlein@gmail.com> | 2011-05-12 12:45:18 +0200 |
commit | c858faa20607125097a3ca36f9178c4b4076b071 (patch) | |
tree | 358baf64e55162f9abd30f1833ccc56ebaab0603 | |
parent | a730ae5a2a34ece618ae7b66c50b0d5aca7c9120 (diff) |
move to ruby-plot 0.0.3, use png instead of svg, use ?media for compound images
-rw-r--r-- | lib/ohm_util.rb | 7 | ||||
-rwxr-xr-x | lib/ot_predictions.rb | 2 | ||||
-rwxr-xr-x | report/environment.rb | 2 | ||||
-rw-r--r-- | report/plot_factory.rb | 16 | ||||
-rwxr-xr-x | report/report_content.rb | 12 | ||||
-rwxr-xr-x | report/xml_report.rb | 2 |
6 files changed, 21 insertions, 20 deletions
diff --git a/lib/ohm_util.rb b/lib/ohm_util.rb index 21d7978..856f9d2 100644 --- a/lib/ohm_util.rb +++ b/lib/ohm_util.rb @@ -6,7 +6,7 @@ module Lib prop_names = model.attributes.collect{|p| p.to_s} params.keys.each do |k| key = k.to_s - if (key == "subjectid") + if (key == "subjectid" || key == "media") params.delete(k) else unless prop_names.include?(key) @@ -28,10 +28,11 @@ module Lib end def self.find(model, filter_params) - if (filter_params.size==0) + params = check_params(model,filter_params) + if (params.size==0) model.all else - model.find(check_params(model,filter_params)) + model.find(params) end end diff --git a/lib/ot_predictions.rb b/lib/ot_predictions.rb index 1fd601c..22f9b20 100755 --- a/lib/ot_predictions.rb +++ b/lib/ot_predictions.rb @@ -213,7 +213,7 @@ module Lib begin #a.push( "http://ambit.uni-plovdiv.bg:8080/ambit2/depict/cdk?search="+ # URI.encode(OpenTox::Compound.new(:uri=>p.identifier(i)).smiles) ) if add_pic - a << p.identifier(i)+"/image" + a << p.identifier(i)+"?media=image/png" rescue => ex raise ex #a.push("Could not add pic: "+ex.message) diff --git a/report/environment.rb b/report/environment.rb index 4729dc8..a149a1d 100755 --- a/report/environment.rb +++ b/report/environment.rb @@ -4,7 +4,7 @@ 'rexml/document', 'ruby-plot', 'opentox-ruby' ].each do |g| require g end -gem 'ruby-plot', '= 0.0.2' +gem 'ruby-plot', '= 0.0.3' #R.quit diff --git a/report/plot_factory.rb b/report/plot_factory.rb index 43c45fc..deb1880 100644 --- a/report/plot_factory.rb +++ b/report/plot_factory.rb @@ -161,7 +161,7 @@ module Reports end - def self.create_ranking_plot( svg_out_file, validation_set, compare_attribute, equal_attribute, rank_attribute, class_value=nil ) + def self.create_ranking_plot( out_file, validation_set, compare_attribute, equal_attribute, rank_attribute, class_value=nil ) #compute ranks #puts "rank attibute is "+rank_attribute.to_s @@ -184,14 +184,14 @@ module Reports ranks, nil, #0.1, validation_set.num_different_values(equal_attribute), - svg_out_file) + out_file) end protected - def self.plot_ranking( title, comparables_array, ranks_array, confidence = nil, numdatasets = nil, svg_out_file = nil ) + def self.plot_ranking( title, comparables_array, ranks_array, confidence = nil, numdatasets = nil, out_file = nil ) (confidence and numdatasets) ? conf = "-q "+confidence.to_s+" -k "+numdatasets.to_s : conf = "" - svg_out_file ? show = "-o" : show = "" + out_file ? show = "-o" : show = "" (title and title.length > 0) ? tit = '-t "'+title+'"' : tit = "" #title = "-t \""+ranking_value_prop+"-Ranking ("+comparables.size.to_s+" "+comparable_prop+"s, "+num_groups.to_s+" "+ranking_group_prop+"s, p < "+p.to_s+")\" " @@ -208,12 +208,12 @@ module Reports end raise "rank plot failed" unless $?==0 - if svg_out_file - f = File.new(svg_out_file, "w") + if out_file + f = File.new(out_file, "w") f.puts res end - svg_out_file ? svg_out_file : res + out_file ? out_file : res end def self.demo_ranking_plot @@ -264,7 +264,7 @@ module Reports :actual_values => [0, 1, 0, 0, 1, 1]} tp_fp_rates = get_tp_fp_rates(roc_values) data = { :names => ["default"], :fp_rate => [tp_fp_rates[:fp_rate]], :tp_rate => [tp_fp_rates[:tp_rate]] } - RubyPlot::plot_lines("/tmp/plot.svg", + RubyPlot::plot_lines("/tmp/plot.png", "ROC-Plot", "False positive rate", "True Positive Rate", data[:names], data[:fp_rate], data[:tp_rate], data[:faint] ) diff --git a/report/report_content.rb b/report/report_content.rb index 674bb13..1e47cee 100755 --- a/report/report_content.rb +++ b/report/report_content.rb @@ -155,12 +155,12 @@ class Reports::ReportContent section_text += "\nWARNING: regression plot information not available for all validation results" if prediction_set.size!=validation_set.size @xml_report.add_paragraph(section_regr, section_text) if section_text - plot_file_name = "regr_plot"+@tmp_file_count.to_s+".svg" + plot_file_name = "regr_plot"+@tmp_file_count.to_s+".png" @tmp_file_count += 1 begin plot_file_path = add_tmp_file(plot_file_name) Reports::PlotFactory.create_regression_plot( plot_file_path, prediction_set, name_attribute ) - @xml_report.add_imagefigure(section_regr, image_title, plot_file_name, "SVG", 120, image_caption) + @xml_report.add_imagefigure(section_regr, image_title, plot_file_name, "PNG", 100, image_caption) rescue RuntimeError => ex LOGGER.error("Could not create regression plot: "+ex.message) rm_tmp_file(plot_file_name) @@ -194,12 +194,12 @@ class Reports::ReportContent class_value = accept_values[i] image_title = image_titles ? image_titles[i] : "ROC Plot for class-value '"+class_value.to_s+"'" image_caption = image_captions ? image_captions[i] : nil - plot_file_name = "roc_plot"+@tmp_file_count.to_s+".svg" + plot_file_name = "roc_plot"+@tmp_file_count.to_s+".png" @tmp_file_count += 1 begin plot_file_path = add_tmp_file(plot_file_name) Reports::PlotFactory.create_roc_plot( plot_file_path, prediction_set, class_value, split_set_attribute, false )#prediction_set.size>1 ) - @xml_report.add_imagefigure(section_roc, image_title, plot_file_name, "SVG", 120, image_caption) + @xml_report.add_imagefigure(section_roc, image_title, plot_file_name, "PNG", 100, image_caption) rescue RuntimeError => ex msg = "WARNING could not create roc plot for class value '"+class_value.to_s+"': "+ex.message LOGGER.error(msg) @@ -270,11 +270,11 @@ class Reports::ReportContent section_bar = @xml_report.add_section(@current_section, section_title) @xml_report.add_paragraph(section_bar, section_text) if section_text - plot_file_name = "bar_plot"+@tmp_file_count.to_s+".svg" + plot_file_name = "bar_plot"+@tmp_file_count.to_s+".png" @tmp_file_count += 1 plot_file_path = add_tmp_file(plot_file_name) Reports::PlotFactory.create_bar_plot(plot_file_path, validation_set, title_attribute, value_attributes ) - @xml_report.add_imagefigure(section_bar, image_title, plot_file_name, "SVG", 120, image_caption) + @xml_report.add_imagefigure(section_bar, image_title, plot_file_name, "PNG", 100, image_caption) end private diff --git a/report/xml_report.rb b/report/xml_report.rb index 4b9a11a..4fbfae3 100755 --- a/report/xml_report.rb +++ b/report/xml_report.rb @@ -184,7 +184,7 @@ module Reports row = Element.new("row") r.each do |v| entry = Element.new("entry") - if auto_link_urls && v.to_s =~ /depict/ || v.to_s =~ /image$/ #PENDING + if auto_link_urls && v.to_s =~ /depict/ || v.to_s =~ /image\/png$/ #PENDING add_image(entry, v.to_s) elsif auto_link_urls && v.to_s =~ /^http(s?):\/\// add_url(entry, v.to_s, v.to_s) |