Class: GraphStats
- Inherits:
-
Object
- Object
- GraphStats
- Defined in:
- lib/seqtrimnext/classes/graph_stats.rb
Overview
require ‘gnu_plot_graph’
Instance Method Summary collapse
-
#initialize(stats, initial_stats = nil) ⇒ GraphStats
constructor
A new instance of GraphStats.
Constructor Details
#initialize(stats, initial_stats = nil) ⇒ GraphStats
Returns a new instance of GraphStats.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/seqtrimnext/classes/graph_stats.rb', line 8 def initialize(stats,initial_stats=nil) #load stats init_stats=initial_stats if init_stats.nil? if File.exists?(File.join(OUTPUT_PATH,'initial_stats.json')) r=File.read(File.join(OUTPUT_PATH,'initial_stats.json')) init_stats= JSON::parse(r) else init_stats=[] end end # puts init_stats.to_json #r=File.read(File.join(File.dirname(__FILE__),'stats.json')) if !File.exists?('graphs') Dir.mkdir('graphs') end @stats=stats @stats.each do |plugin_name,plugin_value| # get plugin class begin plugin_class = Object.const_get(plugin_name) rescue Exception => e # puts "RESCUE",e.message,e.backtrace plugin_class = Plugin end plugin_value.keys.each do |stats_name| puts "Plotting #{stats_name} from #{plugin_name}" # if graph is not ignored if !plugin_class.graph_ignored?(stats_name) x=[] y=[] # get filename file_name=File.join('graphs',plugin_class.get_graph_filename(plugin_name,stats_name)+'.png') # create new graph object plot=ScbiPlot::Histogram.new(file_name,plugin_class.get_graph_title(plugin_name,stats_name)) plugin_class.auto_setup(plugin_value[stats_name],stats_name,x,y) # puts plugin_class.name.to_s # plot_setup returns true if it has already handled the setup of the plot, if not, handle here if !plugin_class.plot_setup(plugin_value[stats_name],stats_name,x,y,init_stats,plot) if !x.empty? && !y.empty? && (x.length==y.length) plot.x_label= "Length" plot.y_label= "Count" plot.add_x(x) plot.add_y(y) plot.do_graph end end # if !x.empty? && !y.empty? && (x.length==y.length) # # end end end end end |