class Mspire::Mzml::Precursor
The method of precursor ion selection and activation
Attributes
activation[RW]
(required) The type and energy level used for activation.
isolation_window[RW]
(optional)
selected_ions[RW]
(optional) An array of ions that were selected.
source_file[RW]
This is an EXTERNAL source file ONLY. It should NOT be set if the spectrum is internal.
spectrum_id[RW]
(optional) the id of the Spectrum
object, whether internal or externally derived.
spectrum_list[RW]
the spectrum list object which enables the spectrum to be accessed directly
Public Class Methods
from_xml(xml, link)
click to toggle source
# File lib/mspire/mzml/precursor.rb, line 41 def self.from_xml(xml, link) ref_hash = link[:ref_hash] obj = self.new obj.spectrum_id = xml[:spectrumRef] || xml[:externalSpectrumID] if source_file_ref = xml[:sourceFileRef] obj.source_file = link[:source_file_hash][ source_file_ref ] end xml.children.each do |child_n| case child_n.name when 'activation' # the only one required obj.activation = Mspire::Mzml::Activation.new.describe_self_from_xml!(child_n, ref_hash) when 'isolationWindow' obj.isolation_window = Mspire::Mzml::IsolationWindow.new.describe_self_from_xml!(child_n, ref_hash) when 'selectedIonList' obj.selected_ions = child_n.children.map do |si_n| Mspire::Mzml::SelectedIon.new.describe_self_from_xml!(si_n, ref_hash) end end end obj end
new(spectrum_id=nil, spectrum_list=nil)
click to toggle source
provide the SpectrumList
object for spectrum
access
# File lib/mspire/mzml/precursor.rb, line 33 def initialize(spectrum_id=nil, spectrum_list=nil) @spectrum_id, @spectrum_list = spectrum_id, spectrum_list end
Public Instance Methods
spectrum()
click to toggle source
# File lib/mspire/mzml/precursor.rb, line 37 def spectrum @spectrum_list[@spectrum_id] end
to_xml(builder)
click to toggle source
# File lib/mspire/mzml/precursor.rb, line 65 def to_xml(builder) atts = {} if @source_file atts[:sourceFileRef] = @source_file.id atts[:externalSpectrumRef] = @spectrum_id elsif @spectrum_id atts[:spectrumRef] = @spectrum_id end builder.precursor(atts) do |prec_n| @isolation_window.to_xml(prec_n) if @isolation_window Mspire::Mzml::SelectedIon.list_xml(@selected_ions, prec_n) if @selected_ions @activation.to_xml(prec_n) if @activation end end