Sha256: e8d306709ca7bb709dd2dfc66edb5119a876a21480410414d2f8ee261b74806a

Contents?: true

Size: 908 Bytes

Versions: 12

Compression:

Stored size: 908 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]

      # 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

12 entries across 12 versions & 1 rubygems

Version Path
lederhosen-0.2.9 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.2.8 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.2.7 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.2.6 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.2.5 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.2.4 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.2.3 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.2.2 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.2.1 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.2.0 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.1.9 lib/lederhosen/tasks/uc_stats.rb
lederhosen-0.1.8 lib/lederhosen/tasks/uc_stats.rb