lib/mspire/mzml/precursor.rb in mspire-0.7.5 vs lib/mspire/mzml/precursor.rb in mspire-0.7.6
- old
+ new
@@ -1,7 +1,9 @@
require 'mspire/mzml/list'
require 'mspire/mzml/selected_ion'
+require 'mspire/mzml/isolation_window'
+require 'mspire/mzml/activation'
module Mspire
class Mzml
# The method of precursor ion selection and activation
class Precursor
@@ -21,9 +23,22 @@
# a boolean indicating the spectrum is from an external source file
attr_accessor :from_external_source_file
def initialize(spectrum_derived_from=nil)
@spectrum=spectrum_derived_from
+ end
+
+ def self.from_xml(xml)
+ obj = self.new
+ %w(isolationWindow activation).each do |el|
+ sub_node = xml.xpath("./#{el}").first
+ el[0] = el[0].capitalize
+ Mspire::Mzml.const_get(el).from_xml(sub_node) if sub_node
+ end
+ obj.selected_ions = xml.xpath('./selectedIonList/selectedIon').map do |si_n|
+ Mspire::Mzml::SelectedIon.from_xml(si_n)
+ end
+ obj
end
def to_xml(builder)
atts = {}
if @from_external_source_file