mspire 0.6.7 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +5 -0
- data/VERSION +1 -1
- data/lib/cv/param.rb +25 -5
- data/lib/cv/referenceable_param_group_ref.rb +13 -0
- data/lib/cv.rb +3 -1
- data/lib/ms/cv/param.rb +19 -24
- data/lib/ms/cv/paramable.rb +42 -0
- data/lib/ms/mzml/activation.rb +33 -0
- data/lib/ms/mzml/chromatogram.rb +29 -0
- data/lib/ms/mzml/chromatogram_list.rb +26 -0
- data/lib/ms/mzml/component.rb +21 -0
- data/lib/ms/mzml/contact.rb +23 -0
- data/lib/ms/mzml/cv.rb +46 -0
- data/lib/ms/mzml/data_array.rb +65 -0
- data/lib/ms/mzml/data_array_container_like.rb +57 -0
- data/lib/ms/mzml/data_processing.rb +27 -0
- data/lib/ms/mzml/file_content.rb +21 -0
- data/lib/ms/mzml/file_description.rb +47 -0
- data/lib/ms/mzml/instrument_configuration.rb +37 -0
- data/lib/ms/mzml/isolation_window.rb +21 -0
- data/lib/ms/mzml/list.rb +23 -0
- data/lib/ms/mzml/precursor.rb +42 -0
- data/lib/ms/mzml/processing_method.rb +24 -0
- data/lib/ms/mzml/product.rb +22 -0
- data/lib/ms/mzml/referenceable_param_group.rb +40 -0
- data/lib/ms/mzml/run.rb +54 -0
- data/lib/ms/mzml/sample.rb +27 -0
- data/lib/ms/mzml/scan.rb +44 -0
- data/lib/ms/mzml/scan_list.rb +33 -0
- data/lib/ms/mzml/scan_settings.rb +28 -0
- data/lib/ms/mzml/selected_ion.rb +18 -0
- data/lib/ms/mzml/software.rb +28 -0
- data/lib/ms/mzml/source_file.rb +48 -0
- data/lib/ms/mzml/spectrum.rb +91 -0
- data/lib/ms/mzml/spectrum_list.rb +42 -0
- data/lib/ms/mzml.rb +173 -6
- data/lib/ms/quant/qspec/protein_group_comparison.rb +3 -3
- data/lib/ms/quant/qspec.rb +4 -4
- data/lib/ms/spectrum.rb +137 -260
- data/lib/ms/spectrum_like.rb +133 -0
- data/lib/ms/user_param.rb +43 -0
- data/lib/mspire.rb +6 -0
- data/obo/ms.obo +670 -121
- data/obo/unit.obo +23 -1
- data/spec/ms/cv/param_spec.rb +33 -0
- data/spec/ms/mzml/cv_spec.rb +17 -0
- data/spec/ms/mzml/file_content_spec.rb +25 -0
- data/spec/ms/mzml/file_description_spec.rb +34 -0
- data/spec/ms/mzml/referenceable_param_group_spec.rb +33 -0
- data/spec/ms/mzml_spec.rb +65 -4
- data/spec/ms/user_param_spec.rb +51 -0
- data/spec/mspire_spec.rb +9 -0
- data/spec/testfiles/ms/mzml/mspire_simulated.noidx.check.mzML +81 -0
- metadata +57 -21
- data/lib/cv/description.rb +0 -19
- data/lib/ms/cv/description.rb +0 -44
- data/lib/msplat.rb +0 -2
- data/spec/ms/cv/description_spec.rb +0 -60
- data/spec/msplat_spec.rb +0 -24
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'ms/mzml/list'
|
2
|
+
|
3
|
+
module MS
|
4
|
+
class Mzml
|
5
|
+
# The method of precursor ion selection and activation
|
6
|
+
class Precursor
|
7
|
+
# (optional) the MS::Mzml::Spectrum object from which the precursor is
|
8
|
+
# derived
|
9
|
+
attr_accessor :spectrum
|
10
|
+
|
11
|
+
# (optional)
|
12
|
+
attr_accessor :isolation_window
|
13
|
+
|
14
|
+
# (optional) An array of ions that were selected.
|
15
|
+
attr_accessor :selected_ions
|
16
|
+
|
17
|
+
# (required) The type and energy level used for activation.
|
18
|
+
attr_accessor :activation
|
19
|
+
|
20
|
+
# a boolean indicating the spectrum is from an external source file
|
21
|
+
attr_accessor :from_external_source_file
|
22
|
+
|
23
|
+
def to_xml(builder)
|
24
|
+
atts = {}
|
25
|
+
if @from_external_source_file
|
26
|
+
atts[:sourceFileRef] = @spectrum.source_file.id
|
27
|
+
atts[:externalSpectrumRef] = @spectrum.id
|
28
|
+
else
|
29
|
+
atts[:spectrumRef] = @spectrum.id if @spectrum
|
30
|
+
end
|
31
|
+
builder.precursor(atts) do |prec_n|
|
32
|
+
@isolation_window.to_xml(prec_n) if @isolation_window
|
33
|
+
MS::Mzml::SelectedIonList.list_xml(@selected_ions, prec_n) if @selected_ions
|
34
|
+
@activation.to_xml(prec_n)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
extend(MS::Mzml::List)
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'ms/cv/paramable'
|
2
|
+
|
3
|
+
module MS
|
4
|
+
class Mzml
|
5
|
+
class ProcessingMethod
|
6
|
+
include MS::CV::Paramable
|
7
|
+
|
8
|
+
attr_accessor :order, :software
|
9
|
+
|
10
|
+
def initialize(order, software, opts={params: []}, &block)
|
11
|
+
@order, @software = order, software
|
12
|
+
describe!(*opts[:params])
|
13
|
+
block.call(self) if block
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_xml(builder)
|
17
|
+
builder.processingMethod(order: @order, softwareRef: software.id) do |pm_n|
|
18
|
+
super(pm_n) # params
|
19
|
+
end
|
20
|
+
builder
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'ms/mzml/list'
|
2
|
+
|
3
|
+
module MS
|
4
|
+
class Mzml
|
5
|
+
class Product
|
6
|
+
attr_accessor :isolation_window
|
7
|
+
|
8
|
+
def initialize(isolation_window=nil)
|
9
|
+
@isolation_window = isolation_window
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_xml(builder)
|
13
|
+
builder.product do |p_n|
|
14
|
+
@isolation_window.to_xml(p_n) if @isolation_window
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
extend(MS::Mzml::List)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'ms/cv/paramable'
|
2
|
+
|
3
|
+
module MS
|
4
|
+
class Mzml
|
5
|
+
|
6
|
+
# need to call to_xml_definition (or use
|
7
|
+
# MS::Mzml::ReferenceableParamGroupList.list_xml) to get the xml for the
|
8
|
+
# object itself (and not a reference). Merely callying #to_xml will
|
9
|
+
# result in a referenceableParamGroupRef being created.
|
10
|
+
class ReferenceableParamGroup
|
11
|
+
include MS::CV::Paramable
|
12
|
+
|
13
|
+
attr_accessor :id
|
14
|
+
|
15
|
+
def initialize(id, opts={params: []} )
|
16
|
+
@id = id
|
17
|
+
describe!(*opts[:params])
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_xml(builder)
|
21
|
+
builder.referenceableParamGroupRef(ref: @id)
|
22
|
+
builder
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_xml_definition(builder)
|
26
|
+
builder.referenceableParamGroup(id: @id) do |fc_n|
|
27
|
+
@params.each {|obj| obj.to_xml(fc_n) }
|
28
|
+
end
|
29
|
+
builder
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.list_xml(objs, builder)
|
33
|
+
builder.referenceableParamGroupList(count: objs.size) do |rpgl_n|
|
34
|
+
objs.each {|obj| obj.to_xml_definition(rpgl_n) }
|
35
|
+
end
|
36
|
+
builder
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/ms/mzml/run.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'ms/cv/paramable'
|
2
|
+
|
3
|
+
module MS
|
4
|
+
class Mzml
|
5
|
+
class Run
|
6
|
+
include MS::CV::Paramable
|
7
|
+
|
8
|
+
# required
|
9
|
+
attr_accessor :default_instrument_configuration
|
10
|
+
|
11
|
+
# optional
|
12
|
+
attr_accessor :default_source_file
|
13
|
+
|
14
|
+
# required
|
15
|
+
attr_accessor :id
|
16
|
+
|
17
|
+
# optional
|
18
|
+
attr_accessor :sample
|
19
|
+
|
20
|
+
# optional
|
21
|
+
attr_accessor :start_time_stamp
|
22
|
+
|
23
|
+
# a SpectrumList object (a special array of spectra)
|
24
|
+
attr_accessor :spectrum_list
|
25
|
+
|
26
|
+
# takes a ChromatogramList object (a special array of chromatograms)
|
27
|
+
attr_accessor :chromatogram_list
|
28
|
+
|
29
|
+
# yields self if given a block
|
30
|
+
def initialize(id, default_instrument_configuration, opts={params: []}, &block)
|
31
|
+
@id = id
|
32
|
+
@default_instrument_configuration = default_instrument_configuration
|
33
|
+
describe!(*opts[:params])
|
34
|
+
block.call(self) if block
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_xml(builder)
|
38
|
+
atts = { id: @id,
|
39
|
+
defaultInstrumentConfigurationRef: @default_instrument_configuration.id
|
40
|
+
}
|
41
|
+
atts[:defaultSourceFileRef] = @default_source_file.id if @default_source_file
|
42
|
+
atts[:sampleRef] = @sample.id if @sample
|
43
|
+
atts[:startTimeStamp] = @start_time_stamp if @start_time_stamp
|
44
|
+
|
45
|
+
builder.run(atts) do |run_n|
|
46
|
+
super(run_n)
|
47
|
+
spectrum_list.to_xml(run_n) if spectrum_list
|
48
|
+
chromatogram_list.to_xml(run_n) if chromatogram_list
|
49
|
+
end
|
50
|
+
builder
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'ms/cv/paramable'
|
2
|
+
require 'ms/mzml/list'
|
3
|
+
|
4
|
+
module MS
|
5
|
+
class Mzml
|
6
|
+
class Sample
|
7
|
+
include MS::CV::Paramable
|
8
|
+
|
9
|
+
attr_accessor :id, :name
|
10
|
+
|
11
|
+
def initialize(id, name, opts={params: []}, &block)
|
12
|
+
@id, @name = id, name
|
13
|
+
describe!(*opts[:params])
|
14
|
+
block.call(self) if block
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_xml(builder)
|
18
|
+
builder.sample( id: @id, name: @name ) do |sample_n|
|
19
|
+
super(sample_n)
|
20
|
+
end
|
21
|
+
builder
|
22
|
+
end
|
23
|
+
|
24
|
+
extend(MS::Mzml::List)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/ms/mzml/scan.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'ms/cv/paramable'
|
2
|
+
|
3
|
+
module MS
|
4
|
+
class Mzml
|
5
|
+
class Scan
|
6
|
+
include MS::CV::Paramable
|
7
|
+
|
8
|
+
# (optional) the MS::Mzml::Spectrum object from which the precursor is
|
9
|
+
# derived. (the sourceFileRef is derived from this spectrum object if
|
10
|
+
# from_external_source_file == true)
|
11
|
+
attr_accessor :spectrum
|
12
|
+
|
13
|
+
# a boolean indicating the spectrum is from an external source file
|
14
|
+
attr_accessor :from_external_source_file
|
15
|
+
|
16
|
+
# an InstrumentConfiguration object
|
17
|
+
attr_accessor :instrument_configuration
|
18
|
+
|
19
|
+
# ScanWindow objects
|
20
|
+
attr_accessor :scan_windows
|
21
|
+
|
22
|
+
def initialize(opts={params: []}, &block)
|
23
|
+
describe!(*opts[:params])
|
24
|
+
block.call(self) if block
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_xml(builder)
|
28
|
+
atts = {}
|
29
|
+
if @from_external_source_file
|
30
|
+
atts[:sourceFileRef] = @spectrum.source_file.id
|
31
|
+
atts[:externalSpectrumRef] = @spectrum.id
|
32
|
+
else
|
33
|
+
atts[:spectrumRef] = @spectrum.id if @spectrum
|
34
|
+
end
|
35
|
+
atts[:instrumentConfigurationRef] = @instrument_configuration.id if @instrument_configuration
|
36
|
+
builder.scan(atts) do |prec_n|
|
37
|
+
super(prec_n) # description
|
38
|
+
ScanWindow.list_xml(@scan_windows, prec_n) if @scan_windows
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'ms/cv/paramable'
|
2
|
+
|
3
|
+
module MS
|
4
|
+
class Mzml
|
5
|
+
|
6
|
+
# MUST supply a *child* term of MS:1000570 (spectra combination) only once
|
7
|
+
#
|
8
|
+
# e.g.: MS:1000571 (sum of spectra)
|
9
|
+
# e.g.: MS:1000573 (median of spectra)
|
10
|
+
# e.g.: MS:1000575 (mean of spectra)
|
11
|
+
# e.g.: MS:1000795 (no combination)
|
12
|
+
class ScanList < Array
|
13
|
+
include MS::CV::Paramable
|
14
|
+
|
15
|
+
def initialize(opts={params: []}, &block)
|
16
|
+
describe!(*opts[:params])
|
17
|
+
block.call(self) if block
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_xml(builder)
|
21
|
+
builder.scanList(count: self.size) do |sl_n|
|
22
|
+
@description.to_xml(sl_n) if @description
|
23
|
+
self.each do |scan|
|
24
|
+
scan.to_xml(sl_n)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
builder
|
28
|
+
end
|
29
|
+
|
30
|
+
alias_method :list_xml, :to_xml
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'ms/mzml/list'
|
2
|
+
require 'ms/cv/paramable'
|
3
|
+
|
4
|
+
module MS
|
5
|
+
class Mzml
|
6
|
+
class ScanSettings
|
7
|
+
include MS::CV::Paramable
|
8
|
+
|
9
|
+
attr_accessor :id
|
10
|
+
|
11
|
+
def initialize(id, opts={params: []}, &block)
|
12
|
+
@id = id
|
13
|
+
describe!(*opts[:params])
|
14
|
+
block.call(self) if block
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_xml(builder)
|
18
|
+
builder.scanSettings( id: @id ) do |ss_n|
|
19
|
+
super(ss_n)
|
20
|
+
end
|
21
|
+
builder
|
22
|
+
end
|
23
|
+
|
24
|
+
extend(MS::Mzml::List)
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'ms/mzml/list'
|
2
|
+
require 'ms/cv/paramable'
|
3
|
+
|
4
|
+
|
5
|
+
module MS
|
6
|
+
class Mzml
|
7
|
+
# MUST supply a *child* term of MS:1000455 (ion selection attribute) one or more times
|
8
|
+
#
|
9
|
+
# e.g.: MS:1000041 (charge state)
|
10
|
+
# e.g.: MS:1000042 (intensity)
|
11
|
+
# e.g.: MS:1000633 (possible charge state)
|
12
|
+
# e.g.: MS:1000744 (selected ion m/z)
|
13
|
+
class SelectedIon
|
14
|
+
include MS::CV::Paramable
|
15
|
+
extend(MS::Mzml::List)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'mspire'
|
2
|
+
require 'ms/mzml/list'
|
3
|
+
require 'ms/cv/paramable'
|
4
|
+
|
5
|
+
module MS
|
6
|
+
class Mzml
|
7
|
+
class Software
|
8
|
+
include MS::CV::Paramable
|
9
|
+
|
10
|
+
attr_accessor :id, :version
|
11
|
+
|
12
|
+
def initialize(id='mspire', version=Mspire::VERSION, opts={params: []}, &block)
|
13
|
+
@id, @version = id, version
|
14
|
+
describe!(*opts[:params])
|
15
|
+
block.call(self) if block
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_xml(builder)
|
19
|
+
builder.software( id: @id, version: @version) do |sf_n|
|
20
|
+
super(sf_n)
|
21
|
+
end
|
22
|
+
builder
|
23
|
+
end
|
24
|
+
|
25
|
+
extend(MS::Mzml::List)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'ms/cv/paramable'
|
2
|
+
require 'ms/mzml/list'
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
module MS
|
6
|
+
class Mzml
|
7
|
+
class SourceFile
|
8
|
+
include MS::CV::Paramable
|
9
|
+
|
10
|
+
DEFAULT_SOURCEFILE_ID = 'sourcefile1'
|
11
|
+
|
12
|
+
# (required) An identifier for this file.
|
13
|
+
attr_accessor :id
|
14
|
+
# (required) Name of the source file, without reference to location
|
15
|
+
# (either URI or local path).
|
16
|
+
attr_accessor :name
|
17
|
+
# (required) URI-formatted location where the file was retrieved.
|
18
|
+
attr_accessor :location
|
19
|
+
|
20
|
+
# expands the path and sets the name and location
|
21
|
+
def self.[](path, opts={})
|
22
|
+
self.new DEFAULT_SOURCEFILE_ID, *uri_basename_and_path(path)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.uri_basename_and_path(file)
|
26
|
+
pathname = Pathname.new(path)
|
27
|
+
dir = pathname.expand_path.dirname
|
28
|
+
dir = '/'+dir unless (dir[0] == '/')
|
29
|
+
[pathname.basename, 'file://'+ dir]
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize(id="sourcefile1", name="mspire-simulated", location='file://', opts={params: []}, &block)
|
33
|
+
@id, @name, @location = id, name, location
|
34
|
+
describe!(*opts[:params])
|
35
|
+
block.call(self) if block
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_xml(builder)
|
39
|
+
builder.sourceFile( id: @id, name: @name, location: @location ) do |sf_n|
|
40
|
+
super(sf_n)
|
41
|
+
end
|
42
|
+
builder
|
43
|
+
end
|
44
|
+
|
45
|
+
extend(MS::Mzml::List)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'ms/mzml/data_array_container_like'
|
2
|
+
require 'ms/spectrum_like'
|
3
|
+
require 'ms/mzml/data_array'
|
4
|
+
require 'ms/mzml/scan_list'
|
5
|
+
require 'ms/mzml/precursor'
|
6
|
+
require 'ms/mzml/product'
|
7
|
+
|
8
|
+
module MS
|
9
|
+
class Mzml
|
10
|
+
|
11
|
+
# MAY supply a *child* term of MS:1000465 (scan polarity) only once
|
12
|
+
# e.g.: MS:1000129 (negative scan)
|
13
|
+
# e.g.: MS:1000130 (positive scan)
|
14
|
+
# MUST supply a *child* term of MS:1000559 (spectrum type) only once
|
15
|
+
# e.g.: MS:1000322 (charge inversion mass spectrum)
|
16
|
+
# e.g.: MS:1000325 (constant neutral gain spectrum)
|
17
|
+
# e.g.: MS:1000326 (constant neutral loss spectrum)
|
18
|
+
# e.g.: MS:1000328 (e/2 mass spectrum)
|
19
|
+
# e.g.: MS:1000341 (precursor ion spectrum)
|
20
|
+
# e.g.: MS:1000581 (CRM spectrum)
|
21
|
+
# e.g.: MS:1000582 (SIM spectrum)
|
22
|
+
# e.g.: MS:1000583 (SRM spectrum)
|
23
|
+
# e.g.: MS:1000789 (enhanced multiply charged spectrum)
|
24
|
+
# e.g.: MS:1000790 (time-delayed fragmentation spectrum)
|
25
|
+
# et al.
|
26
|
+
# MUST supply term MS:1000525 (spectrum representation) or any of its children only once
|
27
|
+
# e.g.: MS:1000127 (centroid spectrum)
|
28
|
+
# e.g.: MS:1000128 (profile spectrum)
|
29
|
+
# MAY supply a *child* term of MS:1000499 (spectrum attribute) one or more times
|
30
|
+
# e.g.: MS:1000285 (total ion current)
|
31
|
+
# e.g.: MS:1000497 (zoom scan)
|
32
|
+
# e.g.: MS:1000504 (base peak m/z)
|
33
|
+
# e.g.: MS:1000505 (base peak intensity)
|
34
|
+
# e.g.: MS:1000511 (ms level)
|
35
|
+
# e.g.: MS:1000527 (highest observed m/z)
|
36
|
+
# e.g.: MS:1000528 (lowest observed m/z)
|
37
|
+
# e.g.: MS:1000618 (highest observed wavelength)
|
38
|
+
# e.g.: MS:1000619 (lowest observed wavelength)
|
39
|
+
# e.g.: MS:1000796 (spectrum title)
|
40
|
+
# et al.
|
41
|
+
class Spectrum
|
42
|
+
include MS::SpectrumLike
|
43
|
+
include MS::Mzml::DataArrayContainerLike
|
44
|
+
|
45
|
+
# (optional) an MS::Mzml::SourceFile object
|
46
|
+
attr_accessor :source_file
|
47
|
+
|
48
|
+
# (optional) The identifier for the spot from which this spectrum was derived, if a
|
49
|
+
# MALDI or similar run.
|
50
|
+
attr_accessor :spot_id
|
51
|
+
|
52
|
+
###########################################
|
53
|
+
# SUBELEMENTS
|
54
|
+
###########################################
|
55
|
+
|
56
|
+
# (optional) a ScanList object
|
57
|
+
attr_accessor :scan_list
|
58
|
+
|
59
|
+
# (optional) List and descriptions of precursor isolations to the spectrum
|
60
|
+
# currently being described, ordered.
|
61
|
+
attr_accessor :precursors
|
62
|
+
|
63
|
+
# (optional) List and descriptions of product isolations to the spectrum
|
64
|
+
# currently being described, ordered.
|
65
|
+
attr_accessor :products
|
66
|
+
|
67
|
+
# the most common param to pass in would be ms level: 'MS:1000511'
|
68
|
+
#
|
69
|
+
# This would generate a spectrum of ms_level=2 :
|
70
|
+
#
|
71
|
+
# MS::Mzml::Spectrum.new(0, "scan=1", 'MS:1000511')
|
72
|
+
def initialize(*args, &block)
|
73
|
+
super(*args)
|
74
|
+
block.call(self) if block
|
75
|
+
end
|
76
|
+
|
77
|
+
# see SpectrumList for generating the entire list
|
78
|
+
def to_xml(builder)
|
79
|
+
atts = {}
|
80
|
+
atts[:sourceFile] = @source_file.id if @source_file
|
81
|
+
atts[:spotID] = @spot_id if @spot_id
|
82
|
+
super(builder, atts) do |node|
|
83
|
+
@scan_list.list_xml( node ) if @scan_list
|
84
|
+
MS::Mzml::Precursor.list_xml(@precursors, node) if @precursors
|
85
|
+
MS::Mzml::Product.list_xml(@products, node) if @products
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'ms/mzml/spectrum'
|
2
|
+
|
3
|
+
module MS
|
4
|
+
class Mzml
|
5
|
+
class SpectrumList < Array
|
6
|
+
|
7
|
+
# a DataProcessing object
|
8
|
+
attr_reader :default_data_processing
|
9
|
+
|
10
|
+
def initialize(default_data_processing, spectra=[])
|
11
|
+
@default_data_processing = default_data_processing
|
12
|
+
super(spectra)
|
13
|
+
end
|
14
|
+
|
15
|
+
# This method takes an MS::Spectrum object and transforms it into an
|
16
|
+
# MS::Mzml::Spectrum object and puts it in the internal list
|
17
|
+
def add_ms_spectrum(spectrum, id)
|
18
|
+
mzml_spec = MS::Mzml::Spectrum.new(id)
|
19
|
+
mzml_spec.data = spectrum.data
|
20
|
+
self << mzml_spec
|
21
|
+
end
|
22
|
+
|
23
|
+
# takes an array of spectra and performs add_spectrum on each
|
24
|
+
# returns self
|
25
|
+
def add_spectra(spectra, ids=[])
|
26
|
+
spectra.zip(ids).each_with_index {|(spec,id),i| add_spectrum(spec, "spectrum=#{i+1}") }
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_xml(builder)
|
31
|
+
builder.spectrumList(count: self.size, defaultDataProcessingRef: @default_data_processing.id) do |spl_n|
|
32
|
+
self.each_with_index do |spectrum,i|
|
33
|
+
spectrum.index = i unless spectrum.index
|
34
|
+
spectrum.to_xml(spl_n)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
builder
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|