#!/usr/bin/ruby # Main program for sorting index and same order correlation # # Written by k-fleak # # Usage: # # > ./getSameCorrelation [cout.orig] [cout.toBeSort] [CORRELATION.toBeSort] require "#{ENV["HOME"]}/myRuby/identicalCluster.rb" class GetSameCorrelation def initialize(coutFile1, coutFile2, corrFile2) id = IdenticalCluster.new(coutFile1, coutFile2) @corrFile2 = open(corrFile2, "r") @sameCluster = id.getSameCluster readCorrelation calcSameCorrelation end def getCorrSort @corrSort end def printSameCorr print @comment print "\n" @corrSort.sort.each do |cs| print cs[1] print "\n" end end private def readCorrelation @corrOrig = Hash.new indexOrig = 0 @corrFile2.each do |lines| unless lines.strip.empty? then if /str/ =~ lines then @comment = lines.strip else corr = lines.strip @corrOrig[indexOrig] = corr indexOrig += 1 end end end end def calcSameCorrelation @corrSort = Hash.new @sameCluster.each do |sameC| indexSort = sameC[0] corr = @corrOrig[sameC[1]] @corrSort[indexSort] = corr end end end hog = GetSameCorrelation.new(ARGV[0], ARGV[1], ARGV[2]) hog.printSameCorr