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

Version Path
lederhosen-1.0.1 lib/lederhosen/tasks/uc_stats.rb
lederhosen-1.0.0 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.5.7 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.5.6 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.5.5 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.5.4 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.5.2 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.5.1 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.5.0 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.4.0 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.3.9 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.3.8 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.3.7 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.3.6 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.3.5 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.3.4 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.3.3 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.3.2 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.3.1 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.3.0 lib/lederhosen/tasks/uc_stats.rb