Sha256: 363a05334b2723071c2610623b22b40daeac190e4910261f2c17718f11806c2d
Contents?: true
Size: 1.99 KB
Versions: 7
Compression:
Stored size: 1.99 KB
Contents
require 'spec/msrun' module Align; end class Align::CHAMS # Avg_score 0.52559 # Scan1 Scan2 Edge_cost Path_cost Edge_direction attr_accessor :avg_score, :time_mscans, :time_nscans, :mscans, :nscans, :edge_costs, :path_costs, :directions def initialize(chams_file, timeIndex_file1, timeIndex_file2) @time_mscans = [] @time_nscans = [] @mscans = [] @nscans = [] @edge_costs = [] @path_costs = [] @directions = [] read_chams_file(chams_file) scans_by_num1 = Spec::MSRunIndex.new(timeIndex_file1).scans_by_num scans_by_num2 = Spec::MSRunIndex.new(timeIndex_file2).scans_by_num @mscans.each_with_index do |scan,i| @time_mscans[i] = scans_by_num1[scan].time end @nscans.each_with_index do |scan,i| @time_nscans[i] = scans_by_num2[scan].time end end def read_chams_file(chams_file) File.open(chams_file).each do |line| if line =~ /[\d\w]/ if line =~ /^# Avg_score ([\.\d])/ @avg_score = $1.to_f next end end if line =~ /^#/ next end arr = line.chomp.split(/\s+/) @mscans.push arr[0].to_i @nscans.push arr[1].to_i @edge_costs.push arr[2].to_f @path_costs.push arr[3].to_f @directions.push arr[4].to_f end @mscans.reverse! @nscans.reverse! @edge_costs.reverse! @path_costs.reverse! @directions.reverse! end def write_my_chams_file(filename) File.open(filename, "w") do |fh| ## As columns: #(0...@mscans.size).each do |i| # fh.print @time_mscans[i].to_s + " " # fh.print @time_nscans[i].to_s + " " # fh.print @mscans[i].to_s + " " # fh.print @nscans[i].to_s + " " # fh.print @edge_costs[i].to_s + "\n" #end # As rows: fh.print @time_mscans.join(" ") + "\n" fh.print @time_nscans.join(" ") + "\n" fh.print @mscans.join(" ") + "\n" fh.print @nscans.join(" ") + "\n" fh.print @edge_costs.join(" ") + "\n" end end end
Version data entries
7 entries across 7 versions & 1 rubygems