Class: Mspire::Mzml::Scan

Inherits:
Object
  • Object
show all
Includes:
Paramable
Defined in:
lib/mspire/mzml/scan.rb

Instance Attribute Summary collapse

Attributes included from Paramable

#cv_params, #ref_param_groups, #user_params

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Paramable

#accessionable_params, #describe!, #describe_from_xml!, #describe_many!, #describe_self_from_xml!, #each_accessionable_param, #each_param, #fetch, #fetch_by_accession, #param?, #param_by_accession, #params, #params?, #reject!, #replace!, #replace_many!

Constructor Details

#initialize {|_self| ... } ⇒ Scan

Returns a new instance of Scan.

Yields:

  • (_self)

Yield Parameters:



24
25
26
27
# File 'lib/mspire/mzml/scan.rb', line 24

def initialize
  params_init
  yield(self) if block_given?
end

Instance Attribute Details

#from_external_source_fileObject

a boolean indicating the spectrum is from an external source file



16
17
18
# File 'lib/mspire/mzml/scan.rb', line 16

def from_external_source_file
  @from_external_source_file
end

#instrument_configurationObject

an InstrumentConfiguration object (optional).



19
20
21
# File 'lib/mspire/mzml/scan.rb', line 19

def instrument_configuration
  @instrument_configuration
end

#scan_windowsObject

ScanWindow objects



22
23
24
# File 'lib/mspire/mzml/scan.rb', line 22

def scan_windows
  @scan_windows
end

#spectrumObject

(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)



13
14
15
# File 'lib/mspire/mzml/scan.rb', line 13

def spectrum
  @spectrum
end

Class Method Details

.from_xml(xml, link) ⇒ Object

link should have:

:ref_hash
:default_instrument_configuration
:instrument_configuration_hash


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/mspire/mzml/scan.rb', line 34

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

Instance Method Details

#to_xml(builder, default_ids) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/mspire/mzml/scan.rb', line 52

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