Sha256: 6eafc90dd0f1beade9c53b4b7b9313e969943391669a23bd51153dcbefb6e034

Contents?: true

Size: 1.68 KB

Versions: 9

Compression:

Stored size: 1.68 KB

Contents

require 'mspire/cv/paramable'
require 'mspire/mzml/scan_window'

module Mspire
  class Mzml
    class Scan
      include Mspire::CV::Paramable

      # (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)
      attr_accessor :spectrum

      # a boolean indicating the spectrum is from an external source file
      attr_accessor :from_external_source_file

      # an InstrumentConfiguration object
      attr_accessor :instrument_configuration

      # ScanWindow objects
      attr_accessor :scan_windows

      def initialize(opts={params: []}, &block)
        super(opts)
        block.call(self) if block
      end

      # takes a nokogiri node
      #def self.from_xml(xml)
      #end

      def self.from_xml(xml)
        scan = self.new
        [:cvParam, :userParam].each {|v| scan.describe! xml.xpath("./#{v}") }
        scan.scan_windows = xml.xpath('./scanWindowList/scanWindow').map do |scan_window_n|
          Mspire::Mzml::ScanWindow.from_xml(scan_window_n)
        end
        scan
      end

      def to_xml(builder)
        atts = {}
        if @from_external_source_file
          atts[:sourceFileRef] = @spectrum.source_file.id
          atts[:externalSpectrumRef] = @spectrum.id
        else
          atts[:spectrumRef] = @spectrum.id if @spectrum
        end
        atts[:instrumentConfigurationRef] = @instrument_configuration.id if @instrument_configuration
        builder.scan(atts) do |prec_n|
          super(prec_n) # description
          ScanWindow.list_xml(@scan_windows, prec_n) if @scan_windows
        end
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mspire-0.7.18 lib/mspire/mzml/scan.rb
mspire-0.7.17 lib/mspire/mzml/scan.rb
mspire-0.7.13 lib/mspire/mzml/scan.rb
mspire-0.7.12 lib/mspire/mzml/scan.rb
mspire-0.7.11 lib/mspire/mzml/scan.rb
mspire-0.7.10 lib/mspire/mzml/scan.rb
mspire-0.7.9 lib/mspire/mzml/scan.rb
mspire-0.7.8 lib/mspire/mzml/scan.rb
mspire-0.7.7 lib/mspire/mzml/scan.rb