mspire 0.6.7 → 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/Rakefile
CHANGED
@@ -51,3 +51,8 @@ Rake::RDocTask.new do |rdoc|
|
|
51
51
|
rdoc.rdoc_files.include('README*')
|
52
52
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
53
|
end
|
54
|
+
|
55
|
+
# need to write updaters to get latest obo
|
56
|
+
#task 'update-obo' do
|
57
|
+
# "http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo"
|
58
|
+
#end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.9
|
data/lib/cv/param.rb
CHANGED
@@ -1,24 +1,44 @@
|
|
1
|
+
=begin
|
2
|
+
# if you want to use Nokogiri as the builder, you need something like this
|
3
|
+
# code:
|
4
|
+
class XML::Nokogiri::Builder
|
5
|
+
def tag!(name, *data)
|
6
|
+
send(name, *data)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
=end
|
10
|
+
|
1
11
|
|
2
12
|
module CV
|
13
|
+
# the xml writer is written with the assumption that the object is a
|
14
|
+
# Builder::XmlMarkup object. You can get away with using Nokogiri
|
3
15
|
class Param
|
16
|
+
|
4
17
|
attr_accessor :cv_ref, :accession, :name, :value
|
18
|
+
|
5
19
|
# A valueless CV::Param object that describes the units being used
|
6
20
|
attr_accessor :unit
|
7
21
|
|
8
|
-
def initialize(cv_ref, accession, name, value=nil)
|
9
|
-
|
22
|
+
def initialize(cv_ref, accession, name, value=nil, unit=nil)
|
23
|
+
@cv_ref, @accession, @name, @value, @unit = cv_ref, accession, name, value, unit
|
10
24
|
end
|
11
25
|
|
12
|
-
# for now, assumes this is a
|
26
|
+
# for now, assumes this is a Builder::XmlMarkup object.
|
27
|
+
# returns the xml builder object
|
13
28
|
def to_xml(xml, name=:cvParam)
|
14
|
-
hash_to_send = {:cvRef => @
|
29
|
+
hash_to_send = {:cvRef => @cv_ref, :accession => @accession, :name => @name}
|
15
30
|
hash_to_send[:value] = @value if @value
|
16
31
|
if unit
|
17
32
|
hash_to_send.merge!( { :unitCvRef => unit.cv_ref,
|
18
33
|
:unitAccession => unit.accession,
|
19
34
|
:unitName => unit.name } )
|
20
35
|
end
|
21
|
-
|
36
|
+
|
37
|
+
# xml.send for builder results in tags with 'send' in the front
|
38
|
+
xml.tag!(name, hash_to_send)
|
39
|
+
# for nokogiri builder
|
40
|
+
#xml.send(name, hash_to_send)
|
41
|
+
xml
|
22
42
|
end
|
23
43
|
|
24
44
|
def ==(other)
|
data/lib/cv.rb
CHANGED
data/lib/ms/cv/param.rb
CHANGED
@@ -1,37 +1,32 @@
|
|
1
|
-
|
1
|
+
require 'cv/param'
|
2
2
|
require 'ms/cv'
|
3
3
|
|
4
4
|
module MS
|
5
5
|
module CV
|
6
6
|
|
7
|
-
# a mass spec related CVParam.
|
8
|
-
# accession numbers or objects to make writing CV's as easy as possible.
|
7
|
+
# a mass spec related CVParam.
|
9
8
|
class Param < ::CV::Param
|
10
9
|
|
11
|
-
#
|
10
|
+
# Takes one of these invocations:
|
12
11
|
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def initialize(*args)
|
22
|
-
@unit =
|
23
|
-
if args.size > 1 && ((args.last.is_a?(::CV::Param) || args.last =~ /[A-Za-z]+:\d+/))
|
24
|
-
unit_arg = args.pop
|
25
|
-
unit_arg.is_a?(::CV::Param) ? unit_arg : self.class.new(unit_arg)
|
26
|
-
end
|
27
|
-
(@cv_ref, @accession, @name, @value) =
|
12
|
+
# acc_num[, unit_acc_num]
|
13
|
+
# acc_num, value[, unit_acc_num]
|
14
|
+
#
|
15
|
+
# Where acc_num and unit_acc_num are strings containing valid accession
|
16
|
+
# numbers (e.g., 'MS:1000514' or 'UO:0000108')
|
17
|
+
def self.[](*args)
|
18
|
+
#puts "param args #{args.inspect}"
|
19
|
+
unit =
|
28
20
|
case args.size
|
29
|
-
when 1
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
21
|
+
when 1
|
22
|
+
nil
|
23
|
+
when 2
|
24
|
+
MS::CV::Param[args.pop] if args.last.to_s[0,3] == 'UO:'
|
25
|
+
when 3
|
26
|
+
MS::CV::Param[args.pop]
|
34
27
|
end
|
28
|
+
obo_type = args[0][/([A-Za-z]+):/,1]
|
29
|
+
self.new(obo_type, args[0], MS::CV::Obo[obo_type][args.first], args[1], unit)
|
35
30
|
end
|
36
31
|
end
|
37
32
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'ms/cv/param'
|
2
|
+
|
3
|
+
module MS
|
4
|
+
module CV
|
5
|
+
module Paramable
|
6
|
+
|
7
|
+
attr_accessor :params
|
8
|
+
|
9
|
+
def initialize(opts={params: []})
|
10
|
+
describe!(*opts[:params])
|
11
|
+
end
|
12
|
+
|
13
|
+
# casts each string or array as a Param object (using MS::CV::Param[]),
|
14
|
+
# pushes it onto the params attribute and returns the growing params object
|
15
|
+
def describe!(*args)
|
16
|
+
@params ||= []
|
17
|
+
as_params = args.map do |arg|
|
18
|
+
if arg.is_a?(Array)
|
19
|
+
MS::CV::Param[ *arg ]
|
20
|
+
elsif arg.is_a?(String)
|
21
|
+
MS::CV::Param[ arg ]
|
22
|
+
else
|
23
|
+
arg
|
24
|
+
end
|
25
|
+
end
|
26
|
+
@params.push(*as_params)
|
27
|
+
end
|
28
|
+
|
29
|
+
# if params respond_to?(:to_xml) then will call that, otherwise
|
30
|
+
# iterates over @params and calls .to_xml on each object.
|
31
|
+
def to_xml(xml)
|
32
|
+
if @params
|
33
|
+
@params.each do |el|
|
34
|
+
el.to_xml(xml)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
xml
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'ms/cv/paramable'
|
2
|
+
|
3
|
+
module MS
|
4
|
+
class Mzml
|
5
|
+
|
6
|
+
# MAY supply a *child* term of MS:1000510 (precursor activation attribute) one or more times
|
7
|
+
#
|
8
|
+
# e.g.: MS:1000045 (collision energy)
|
9
|
+
# e.g.: MS:1000138 (percent collision energy)
|
10
|
+
# e.g.: MS:1000245 (charge stripping)
|
11
|
+
# e.g.: MS:1000412 (buffer gas)
|
12
|
+
# e.g.: MS:1000419 (collision gas)
|
13
|
+
# e.g.: MS:1000509 (activation energy)
|
14
|
+
# e.g.: MS:1000869 (collision gas pressure)
|
15
|
+
#
|
16
|
+
# MUST supply term MS:1000044 (dissociation method) or any of its children one or more times
|
17
|
+
#
|
18
|
+
# e.g.: MS:1000133 (collision-induced dissociation)
|
19
|
+
# e.g.: MS:1000134 (plasma desorption)
|
20
|
+
# e.g.: MS:1000135 (post-source decay)
|
21
|
+
# e.g.: MS:1000136 (surface-induced dissociation)
|
22
|
+
# e.g.: MS:1000242 (blackbody infrared radiative dissociation)
|
23
|
+
# e.g.: MS:1000250 (electron capture dissociation)
|
24
|
+
# e.g.: MS:1000262 (infrared multiphoton dissociation)
|
25
|
+
# e.g.: MS:1000282 (sustained off-resonance irradiation)
|
26
|
+
# e.g.: MS:1000422 (high-energy collision-induced dissociation)
|
27
|
+
# e.g.: MS:1000433 (low-energy collision-induced dissociation)
|
28
|
+
# et al.
|
29
|
+
class Activation
|
30
|
+
include MS::CV::Paramable
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'ms/mzml/data_array_container_like'
|
2
|
+
|
3
|
+
module MS
|
4
|
+
class Mzml
|
5
|
+
class Chromatogram
|
6
|
+
include MS::Mzml::DataArrayContainerLike
|
7
|
+
|
8
|
+
# (optional) precursor isolations to the chromatogram currently being
|
9
|
+
# described
|
10
|
+
attr_accessor :precursor
|
11
|
+
|
12
|
+
# (optional) Description of product isolation to the chromatogram
|
13
|
+
attr_accessor :product
|
14
|
+
|
15
|
+
def initialize(*args, &block)
|
16
|
+
super(*args)
|
17
|
+
block.call(self) if block
|
18
|
+
end
|
19
|
+
|
20
|
+
# see SpectrumList for generating the entire list
|
21
|
+
def to_xml(builder, opts={})
|
22
|
+
super(builder) do |node|
|
23
|
+
@precursor.to_xml(node) if @precursor
|
24
|
+
@product.to_xml(node) if @product
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module MS
|
4
|
+
class Mzml
|
5
|
+
class ChromatogramList < Array
|
6
|
+
|
7
|
+
# a DataProcessing object
|
8
|
+
attr_reader :default_data_processing
|
9
|
+
|
10
|
+
def initialize(default_data_processing, chromatograms=[])
|
11
|
+
@default_data_processing = default_data_processing
|
12
|
+
super(chromatograms)
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_xml(builder)
|
16
|
+
builder.chromatogramList(count: self.size, defaultDataProcessingRef: @default_data_processing.id) do |chrl_n|
|
17
|
+
self.each do |chromatogram|
|
18
|
+
chromatogram.to_xml(chrl_n)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
builder
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'ms/cv/paramable'
|
2
|
+
require 'ms/mzml/list'
|
3
|
+
|
4
|
+
module MS
|
5
|
+
class Mzml
|
6
|
+
module Component
|
7
|
+
include MS::CV::Paramable
|
8
|
+
|
9
|
+
attr_accessor :order
|
10
|
+
|
11
|
+
def to_xml(builder)
|
12
|
+
builder.component(order: @order) do |c_n|
|
13
|
+
super(c_n)
|
14
|
+
end
|
15
|
+
builder
|
16
|
+
end
|
17
|
+
|
18
|
+
extend(MS::Mzml::List)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'ms/cv/paramable'
|
2
|
+
|
3
|
+
module MS
|
4
|
+
class Mzml
|
5
|
+
class Contact
|
6
|
+
|
7
|
+
COMMON_PARAMS = {
|
8
|
+
name: 'MS:1000586',
|
9
|
+
organization: 'MS:1000590',
|
10
|
+
address: 'MS:1000587',
|
11
|
+
email: 'MS:1000589'
|
12
|
+
}
|
13
|
+
|
14
|
+
include MS::CV::Paramable
|
15
|
+
|
16
|
+
def to_xml(builder)
|
17
|
+
builder.contact do |fc_n|
|
18
|
+
super(fc_n)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/ms/mzml/cv.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
module MS
|
3
|
+
class Mzml
|
4
|
+
class CV
|
5
|
+
|
6
|
+
# (required) The short label to be used as a reference tag with which to refer to
|
7
|
+
# this particular Controlled Vocabulary source description (e.g., from
|
8
|
+
# the cvLabel attribute, in CVParamType elements).
|
9
|
+
attr_accessor :id
|
10
|
+
# (required) The usual name for the resource (e.g. The PSI-MS Controlled Vocabulary).
|
11
|
+
attr_accessor :full_name
|
12
|
+
# (required) The URI for the resource.
|
13
|
+
attr_accessor :uri
|
14
|
+
# (optional) The version of the CV from which the referred-to terms are drawn.
|
15
|
+
attr_accessor :version
|
16
|
+
|
17
|
+
def initialize(id, full_name, uri, version=nil)
|
18
|
+
@id, @full_name, @uri, @version = id, full_name, uri, version
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_xml(builder)
|
22
|
+
atts = {id: @id, fullName: @full_name, :URI => @uri}
|
23
|
+
atts[:version] = @version if @version
|
24
|
+
builder.cv( atts )
|
25
|
+
builder
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.list_xml(objs, builder)
|
29
|
+
builder.cvList(count: objs.size) do |cvl_n|
|
30
|
+
objs.each {|obj| obj.to_xml(cvl_n) }
|
31
|
+
end
|
32
|
+
builder
|
33
|
+
end
|
34
|
+
|
35
|
+
# These are derived by looking in the obo folder at the top of mspire
|
36
|
+
IMS = self.new("IMS", "Imaging MS Ontology", "http://www.maldi-msi.org/download/imzml/imagingMS.obo", "0.9.1")
|
37
|
+
MS = self.new('MS', "Proteomics Standards Initiative Mass Spectrometry Ontology", "http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo", "3.18.0")
|
38
|
+
# the version for UO doesn't really exist: seen files where they use the
|
39
|
+
# download date: DD:MM:YYY
|
40
|
+
UO = self.new("UO", "Unit Ontology", "http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/phenotype/unit.obo", "16:02:2012")
|
41
|
+
|
42
|
+
DEFAULT_CVS = [MS, UO, IMS]
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require 'zlib'
|
3
|
+
|
4
|
+
module MS
|
5
|
+
class Mzml
|
6
|
+
class DataArray < Array
|
7
|
+
|
8
|
+
DEFAULT_DTYPE = :float64
|
9
|
+
DEFAULT_COMPRESSION = true
|
10
|
+
DTYPE_TO_ACC = {
|
11
|
+
float64: 'MS:1000523',
|
12
|
+
float32: 'MS:1000521',
|
13
|
+
# float16: 'MS:1000520', # <- not supported w/o other gems
|
14
|
+
int64: 'MS:1000522', # signed
|
15
|
+
int32: 'MS:1000519', # signed
|
16
|
+
}
|
17
|
+
|
18
|
+
# the type of data array (:mz or :intensity)
|
19
|
+
attr_accessor :type
|
20
|
+
|
21
|
+
# requires a type, :mz or :intensity
|
22
|
+
def initialize(_type, ar=[])
|
23
|
+
@type = _type
|
24
|
+
super(ar)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.to_mzml_string(array_ish, dtype=DEFAULT_DTYPE, compression=DEFAULT_COMPRESSION)
|
28
|
+
pack_code =
|
29
|
+
case dtype
|
30
|
+
when :float64 ; 'E*'
|
31
|
+
when :float32 ; 'e*'
|
32
|
+
when :int64 ; 'q<*'
|
33
|
+
when :int32 ; 'l<*'
|
34
|
+
else ; raise "unsupported dtype: #{dtype}"
|
35
|
+
end
|
36
|
+
# TODO: support faster pack method for NArray's in future
|
37
|
+
string = array_ish.to_a.pack(pack_code)
|
38
|
+
string = Zlib::Deflate.deflate(string) if compression
|
39
|
+
Base64.strict_encode64(string)
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_xml(builder, dtype=DEFAULT_DTYPE, compression=DEFAULT_COMPRESSION)
|
43
|
+
base64 = self.class.to_mzml_string(self, dtype, compression)
|
44
|
+
builder.binaryDataArray(encodedLength: base64.bytesize) do |bda_n|
|
45
|
+
MS::CV::Param[ DTYPE_TO_ACC[dtype] ].to_xml(bda_n)
|
46
|
+
MS::CV::Param[ compression ? 'MS:1000574' : 'MS:1000576' ].to_xml(bda_n)
|
47
|
+
MS::CV::Param[ (@type == :mz) ? 'MS:1000514' : 'MS:1000515' ].to_xml(bda_n) # must be m/z or intensity
|
48
|
+
bda_n.binary(base64)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# takes an array of DataArray objects or other kinds of objects
|
53
|
+
def self.list_xml(arrays, builder)
|
54
|
+
builder.binaryDataArrayList(count: arrays.size) do |bdal_n|
|
55
|
+
arrays.zip([:mz, :intensity]) do |data_ar, typ|
|
56
|
+
ar = data_ar.is_a?(MS::Mzml::DataArray) ? data_ar : MS::Mzml::DataArray.new(typ, data_ar)
|
57
|
+
ar.type = typ unless ar.type
|
58
|
+
ar.to_xml(bdal_n)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'ms/cv/paramable'
|
2
|
+
require 'ms/mzml/data_array'
|
3
|
+
|
4
|
+
module MS
|
5
|
+
class Mzml
|
6
|
+
module DataArrayContainerLike
|
7
|
+
include MS::CV::Paramable
|
8
|
+
|
9
|
+
###########################################
|
10
|
+
# ATTRIBUTES
|
11
|
+
###########################################
|
12
|
+
|
13
|
+
# (required) the spectrum id matching this general pattern: \S+=\S+( \S+=\S+)*)
|
14
|
+
attr_accessor :id
|
15
|
+
|
16
|
+
# (required [at xml write time]) the index in the spectrum list
|
17
|
+
attr_accessor :index
|
18
|
+
|
19
|
+
# (optional) an MS::Mzml::DataProcessing object
|
20
|
+
attr_accessor :data_processing
|
21
|
+
|
22
|
+
###########################################
|
23
|
+
# SUBELEMENTS
|
24
|
+
###########################################
|
25
|
+
|
26
|
+
# (optional) an array of MS::Mzml::DataArray
|
27
|
+
attr_accessor :data_arrays
|
28
|
+
|
29
|
+
def initialize(id, opts={params: []})
|
30
|
+
@id = id
|
31
|
+
describe!(*opts[:params])
|
32
|
+
end
|
33
|
+
|
34
|
+
def default_array_length
|
35
|
+
@data_arrays ? @data_arrays.first.size : 0
|
36
|
+
end
|
37
|
+
|
38
|
+
# see SpectrumList for generating the entire list
|
39
|
+
# the opt key :sub_elements can be used to pass in subelements whose
|
40
|
+
# to_xml methods will be called.
|
41
|
+
def to_xml(builder, opts={}, &block)
|
42
|
+
atts = {id: @id, index: @index, defaultArrayLength: default_array_length}
|
43
|
+
atts[:dataProcessingRef] = @data_processing.id if @data_processing
|
44
|
+
atts.merge!(opts)
|
45
|
+
raise "#{self.class} object must have index at xml writing time!" unless atts[:index]
|
46
|
+
|
47
|
+
builder.spectrum(atts) do |sp_n|
|
48
|
+
super(sp_n) # params
|
49
|
+
block.call(sp_n) if block
|
50
|
+
MS::Mzml::DataArray.list_xml(@data_arrays, sp_n) if @data_arrays
|
51
|
+
end
|
52
|
+
builder
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'ms/mzml/list'
|
2
|
+
|
3
|
+
module MS
|
4
|
+
class Mzml
|
5
|
+
class DataProcessing
|
6
|
+
|
7
|
+
attr_accessor :id, :processing_methods
|
8
|
+
|
9
|
+
# yields self if given a block
|
10
|
+
def initialize(id, processing_methods=[], &block)
|
11
|
+
@id, @processing_methods = id, processing_methods
|
12
|
+
block.call(self) if block
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_xml(builder)
|
16
|
+
builder.dataProcessing( id: @id ) do |dp_n|
|
17
|
+
processing_methods.each do |proc_method|
|
18
|
+
proc_method.to_xml(dp_n)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
builder
|
22
|
+
end
|
23
|
+
|
24
|
+
extend(MS::Mzml::List)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'ms/cv/paramable'
|
2
|
+
|
3
|
+
module MS
|
4
|
+
class Mzml
|
5
|
+
# This summarizes the different types of spectra that can be expected in
|
6
|
+
# the file. This is expected to aid processing software in skipping files
|
7
|
+
# that do not contain appropriate spectrum types for it. It should also
|
8
|
+
# describe the nativeID format used in the file by referring to an
|
9
|
+
# appropriate CV term.
|
10
|
+
class FileContent
|
11
|
+
include MS::CV::Paramable
|
12
|
+
|
13
|
+
def to_xml(builder, &block)
|
14
|
+
builder.fileContent do |fc_n|
|
15
|
+
super(fc_n, &block)
|
16
|
+
end
|
17
|
+
builder
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'ms/mzml/file_content'
|
2
|
+
require 'ms/mzml/source_file'
|
3
|
+
require 'ms/mzml/contact'
|
4
|
+
|
5
|
+
module MS
|
6
|
+
class Mzml
|
7
|
+
class FileDescription
|
8
|
+
|
9
|
+
# a summary of the different types of spectra, must be present
|
10
|
+
attr_accessor :file_content
|
11
|
+
|
12
|
+
# may or may not be present
|
13
|
+
attr_accessor :source_files
|
14
|
+
|
15
|
+
# zero to many (just listed in the singular, not enclosed in a list)
|
16
|
+
#
|
17
|
+
# <contact>
|
18
|
+
# </contact>
|
19
|
+
# <contact>
|
20
|
+
# </contact>
|
21
|
+
attr_accessor :contacts
|
22
|
+
|
23
|
+
# hands the user the object if given a block
|
24
|
+
def initialize(file_content=nil, source_files=[], contacts=[], &block)
|
25
|
+
@file_content, @source_files, @contacts = file_content, source_files, contacts
|
26
|
+
block.call(self) if block
|
27
|
+
raise ArgumentError, "FileDescription must have file_content" unless @file_content
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_xml(builder)
|
31
|
+
builder.fileDescription do |fd_n|
|
32
|
+
@file_content.to_xml(fd_n)
|
33
|
+
if source_files.size > 0
|
34
|
+
fd_n.sourceFileList(count: source_files.size) do |sf_n|
|
35
|
+
source_files.each do |sf|
|
36
|
+
sf.to_xml(sf_n)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
contacts.each do |contact|
|
41
|
+
contact.to_xml(fd_n)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'ms/cv/paramable'
|
2
|
+
require 'ms/mzml/component'
|
3
|
+
require 'ms/mzml/list'
|
4
|
+
|
5
|
+
module MS
|
6
|
+
class Mzml
|
7
|
+
class InstrumentConfiguration
|
8
|
+
include MS::CV::Paramable
|
9
|
+
|
10
|
+
# (required) the id that this guy can be referenced from
|
11
|
+
attr_accessor :id
|
12
|
+
|
13
|
+
# a list of Source, Analyzer, Detector objects
|
14
|
+
attr_accessor :components
|
15
|
+
|
16
|
+
# a single software object associated with the instrument
|
17
|
+
attr_accessor :software
|
18
|
+
|
19
|
+
def initialize(id, components=[], opts={params: []})
|
20
|
+
describe!(*opts[:params])
|
21
|
+
@id = id
|
22
|
+
@components = components
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_xml(builder)
|
26
|
+
builder.instrumentConfiguration(id: @id) do |inst_conf_n|
|
27
|
+
super(builder)
|
28
|
+
MS::Mzml::Component.list_xml(components, inst_conf_n)
|
29
|
+
inst_conf_n.softwareRef(ref: @software.id) if @software
|
30
|
+
end
|
31
|
+
builder
|
32
|
+
end
|
33
|
+
|
34
|
+
self.extend(MS::Mzml::List)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'ms/cv/paramable'
|
2
|
+
|
3
|
+
module MS
|
4
|
+
class Mzml
|
5
|
+
|
6
|
+
# MUST supply a *child* term of MS:1000792 (isolation window attribute) one or more times
|
7
|
+
#
|
8
|
+
# e.g.: MS:1000827 (isolation window target m/z)
|
9
|
+
# e.g.: MS:1000828 (isolation window lower offset)
|
10
|
+
# e.g.: MS:1000829 (isolation window upper offset)
|
11
|
+
#
|
12
|
+
# MUST supply a *child* term of MS:1000792 (isolation window attribute) one or more times
|
13
|
+
#
|
14
|
+
# e.g.: MS:1000827 (isolation window target m/z)
|
15
|
+
# e.g.: MS:1000828 (isolation window lower offset)
|
16
|
+
# e.g.: MS:1000829 (isolation window upper offset)
|
17
|
+
class IsolationWindow
|
18
|
+
include MS::CV::Paramable
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/ms/mzml/list.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
module MS
|
3
|
+
class Mzml
|
4
|
+
# Methods for simple List objects (scanList, instrumentConfigurationList,
|
5
|
+
# etc.)
|
6
|
+
module List
|
7
|
+
def list_xml_element
|
8
|
+
return @list_xml_element if @list_xml_element
|
9
|
+
@list_xml_element = self.to_s.split('::').last << "List"
|
10
|
+
@list_xml_element[0] = @list_xml_element[0].downcase
|
11
|
+
@list_xml_element
|
12
|
+
end
|
13
|
+
|
14
|
+
def list_xml(objects, builder, tagname=nil)
|
15
|
+
# InstrumentConfiguration -> instrumentConfigurationList
|
16
|
+
builder.tag!(tagname || list_xml_element, count: objects.size) do |n|
|
17
|
+
objects.each {|obj| obj.to_xml(n) }
|
18
|
+
end
|
19
|
+
builder
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|