Module: Mspire::Mzml::Convenience

Included in:
Mspire::Mzml
Defined in:
lib/mspire/mzml.rb

Instance Method Summary collapse

Instance Method Details

#chromatogram(arg) ⇒ Mspire::Mzml::Chromatogram

Returns a spectrum object.

Parameters:

  • arg (Object)

    an index number (Integer) or id string (String)

Returns:



234
235
236
# File 'lib/mspire/mzml.rb', line 234

def chromatogram(arg)
  run.chromatogram_list[arg]
end

#each_chromatogram(&block) ⇒ Object



215
216
217
# File 'lib/mspire/mzml.rb', line 215

def each_chromatogram(&block)
  @run.chromatogram_list.each(&block)
end

#each_spectrum(&block) ⇒ Object Also known as: each



219
220
221
# File 'lib/mspire/mzml.rb', line 219

def each_spectrum(&block)
  @run.spectrum_list.each(&block)
end

#lengthObject Also known as: size

returns the number of spectra



243
244
245
# File 'lib/mspire/mzml.rb', line 243

def length
  run.spectrum_list.size
end

#num_chromatogramsObject



238
239
240
# File 'lib/mspire/mzml.rb', line 238

def num_chromatograms
  run.chromatogram_list.size
end

#spectrum(arg) ⇒ Mspire::Mzml::Spectrum Also known as: []

Returns a spectrum object.

Parameters:

  • arg (Object)

    an index number (Integer) or id string (String)

Returns:



227
228
229
# File 'lib/mspire/mzml.rb', line 227

def spectrum(arg)
  run.spectrum_list[arg]
end

#spectrum_from_scan_num(scan_num) ⇒ Mspire::Spectrum

Returns a spectrum object, or nil if not found.

Parameters:

  • scan_num (Integer)

    the scan number

Returns:

Raises:



253
254
255
256
257
258
# File 'lib/mspire/mzml.rb', line 253

def spectrum_from_scan_num(scan_num)
  @scan_to_index ||= @index_list[0].create_scan_index
  raise ScanNumbersNotUnique if @scan_to_index == false
  raise ScanNumbersNotFound if @scan_to_index == nil
  spectrum(@scan_to_index[scan_num])
end