Sha256: 008bfebf755197bcb73b565fa65eccf7536b46779db6681464c30205277a8fd8
Contents?: true
Size: 1.47 KB
Versions: 7
Compression:
Stored size: 1.47 KB
Contents
module Spec; end class Spec::Scan attr_accessor :time, :ms_level, :num, :prec_mz, :prec_inten, :parent def initialize(num=nil, ms_level=nil, time=nil, prec_mz=nil, prec_inten=nil, parent=nil) @num = num @ms_level = ms_level @time = time if prec_mz then @prec_mz = prec_mz end if prec_inten then @prec_inten = prec_inten end if parent then @parent = parent end end def to_s "<Scan num=#{@num} ms_level=#{@ms_level} time=#{@time}>" end # returns the string (space delimited): "ms_level num time [prec_mz prec_inten]" def to_index_file_string arr = [@ms_level, @num, @time] if prec_mz then arr << @prec_mz end if prec_inten then arr << @prec_inten end arr.join(" ") end # adds the attribute parent to each scan with a parent # (level 1 = no parent; level 2 = prev level 1, etc. def self.add_parent_scan(scans) prev_scan = nil parent_stack = [nil] ## we want to set the level to be the first mslevel we come to prev_level = 1 scans.each do |scan| if scan then prev_level = scan.ms_level; break; end end scans.each do |scan| next unless scan ## the first one is nil, (others?) level = scan.ms_level if prev_level < level parent_stack.unshift prev_scan end if prev_level > level (prev_level - level).times do parent_stack.shift end end scan.parent = parent_stack.first prev_level = level prev_scan = scan end end end
Version data entries
7 entries across 7 versions & 1 rubygems