class Mspire::Mzml::Index

the array holds start bytes

Attributes

ids[RW]

a parallel array of ids (idRef’s)

name[RW]

the name of the index (as a symbol)

Public Instance Methods

create_scan_to_index() click to toggle source

generates a scan to index hash that points from scan number to the spectrum index number. returns the index, nil if the scan ids are not present and spectra are, or false if they are not unique.

# File lib/mspire/mzml/index.rb, line 28
def create_scan_to_index
  scan_re = /scan=(\d+)/
    scan_to_index = {}
  ids.each_with_index do |id, index|
    md = id.match(scan_re)
    scan_num = md[1].to_i if md
    if scan_num
      if scan_to_index.key?(scan_num)
        return false
      else
        scan_to_index[scan_num] = index
      end
    end
  end
  if scan_to_index.size > 0
    scan_to_index
  elsif ids.size > 0
    nil  # there are scans, but we did not find scan numbers
  else
    scan_to_index
  end
end
start_byte(arg) click to toggle source

@return [Integer] the start byte of the spectrum @param [Object] an Integer (the index number) or String (an id string)

# File lib/mspire/mzml/index.rb, line 15
def start_byte(arg)
  case arg
  when Integer
    self[arg]
  when String
    @id_index ||= create_id_index
    @id_index[arg]
  end
end