Sha256: 8e64aacdf408286c88098186d8ce35c25e02a2ac3d8824e34a1b4fff3f7823d3
Contents?: true
Size: 958 Bytes
Versions: 24
Compression:
Stored size: 958 Bytes
Contents
## # Get statistics about clusters in a UC file # module Lederhosen class CLI desc 'uc_stats', 'get statistics about clusters in a UC file. for now, this only calculates the size of each cluster' method_option :input, :type => :string, :required => true def uc_stats input = options[:input] ohai "calculating statistics for #{input}" # TODO add more stats cluster_stats = Hash.new { |h, k| h[k] = { :size => 0 } } File.open(input) do |handle| handle.each do |line| line = line.strip.split type, clustr_nr = line[0], line[1] cluster_stats[clustr_nr][:size] += 1 end end stat_types = cluster_stats.values.first.keys.sort puts "cluster,#{stat_types.join(',')}" cluster_stats.each do |cluster, stats| puts "#{cluster},#{stat_types.map { |x| stats[x] }.join(',')}" end end end end
Version data entries
24 entries across 24 versions & 1 rubygems