class Mspire::Mzml::Scan

Attributes

from_external_source_file[RW]

a boolean indicating the spectrum is from an external source file

instrument_configuration[RW]

an InstrumentConfiguration object (optional).

scan_windows[RW]

ScanWindow objects

spectrum[RW]

(optional) the Mspire::Mzml::Spectrum object from which the precursor is derived. (the sourceFileRef is derived from this spectrum object if from_external_source_file == true)

Public Class Methods

from_xml(xml, link) click to toggle source

link should have:

:ref_hash
:default_instrument_configuration
:instrument_configuration_hash
# File lib/mspire/mzml/scan.rb, line 49
def self.from_xml(xml, link)
  ref_hash = link[:ref_hash]
  obj = self.new
  obj.instrument_configuration =
    if icf = xml[:instrumentConfigurationRef]
      link[:instrument_configuration_hash][icf]
    else
      link[:default_instrument_configuration]
    end
  scan_window_list_n = obj.describe_from_xml!(xml, ref_hash)
  if scan_window_list_n
    obj.scan_windows = scan_window_list_n.children.map do |scan_window_n|
      Mspire::Mzml::ScanWindow.new.describe_self_from_xml!(scan_window_n, ref_hash)
    end
  end
  obj
end
new() { |self| ... } click to toggle source
# File lib/mspire/mzml/scan.rb, line 24
def initialize
  params_init
  yield(self) if block_given?
end

Public Instance Methods

scan_window() click to toggle source

returns the first existing scan window, or nil if none

# File lib/mspire/mzml/scan.rb, line 30
def scan_window
  return nil unless scan_windows
  scan_windows.first
end
scan_window_limits() click to toggle source

returns a doublet: the upper and lower scan window limits as floats. Returns an array of two values, but may be nil if they don’t exist.

# File lib/mspire/mzml/scan.rb, line 37
def scan_window_limits
  %w(MS:1000501 MS:1000500).map do |acc|
    val = scan_window.fetch_by_acc(acc)
    val && val.to_f
  end
end
to_xml(builder, default_ids) click to toggle source
Calls superclass method Mspire::Paramable#to_xml
# File lib/mspire/mzml/scan.rb, line 67
def to_xml(builder, default_ids)
  atts = {}
  if @from_external_source_file
    atts[:sourceFileRef] = @spectrum.source_file.id
    atts[:externalSpectrumRef] = @spectrum.id
  else
    atts[:spectrumRef] = @spectrum.id if @spectrum
  end
  if @instrument_configuration
    unless @instrument_configuration.id == default_ids[:instrument_configuration]
      atts[:instrumentConfigurationRef] = @instrument_configuration.id 
    end
  end
  builder.scan(atts) do |prec_n|
    super(prec_n) # description
    ScanWindow.list_xml(@scan_windows, prec_n) if @scan_windows
  end
end