mspire 0.9.2 → 0.10.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cacdee4487f5e6a98d31c9649cb02390bce1dd9d
4
- data.tar.gz: 64ae39986bc3bb20dcbcff972ef8162bdd36609b
3
+ metadata.gz: 10f9f35036ad4f2a25b69644aa4157281bc18ccb
4
+ data.tar.gz: 3d5001ce1de7d3d5da82c5de7b3440c93d34abbb
5
5
  SHA512:
6
- metadata.gz: 6523afd75ba3fd0f179d587413b6c85f7bf77152e8c97a155152352498742ff3c53d628b49b9d613f51a1f9d33fde5d7e2f9911c9055d0b751979ad2127faac4
7
- data.tar.gz: fae953898b991b9f0cb6917fc8eaf4ff2e8557c6f73f82b750abe22b68f5f435de300c36c0b7835751b7a48ac22e40d59d340e4f4d6898478615fe6cbf66e892
6
+ metadata.gz: aa2b1352be5a165feeca924d1690fde4e43d980df05aee0dc9a30768644a6a7e6cac645171d93ff83cebddd340660c13fec17d6e27e9e8e31a134d35bfe1fed4
7
+ data.tar.gz: 8e6cc4877db87cbb408c53966570277ebb14eccbf308c8a7e9eadbe793c430e7f25cabd8be492d4f7cef93d0860955265cb48af3a4127fa86a7de5e7b83e99d2
@@ -1,5 +1,4 @@
1
1
  require 'cv/param'
2
- require 'mspire/user_param'
3
2
  require 'mspire/cv/param'
4
3
  require 'nokogiri'
5
4
  require 'andand'
@@ -9,12 +8,9 @@ module Mspire
9
8
  module Paramable
10
9
 
11
10
  attr_accessor :cv_params
12
- attr_accessor :user_params
13
- attr_accessor :ref_param_groups
14
11
 
15
- def params
16
- cv_params + ref_param_groups.flat_map(&:params) + user_params
17
- end
12
+ alias_method :cv_params, :params
13
+ alias_method :cv_params=, :params=
18
14
 
19
15
  def each_param(&block)
20
16
  return enum_for __method__ unless block
@@ -30,17 +26,6 @@ module Mspire
30
26
  user_params.size > 0
31
27
  end
32
28
 
33
- def each_accessionable_param(&block)
34
- return enum_for __method__ unless block
35
- cv_params.each(&block)
36
- ref_param_groups.flat_map(&:params).each(&block)
37
- nil
38
- end
39
-
40
- def accessionable_params
41
- cv_params + ref_param_groups.flat_map(&:params)
42
- end
43
-
44
29
  # yields each current param. If the return value is not false or nil,
45
30
  # it is deleted (i.e., any true value and it is deleted). Then adds the
46
31
  # given parameter or makes a new one by accession number.
@@ -51,8 +36,6 @@ module Mspire
51
36
  # returns self
52
37
  def reject!(&block)
53
38
  cv_params.reject!(&block)
54
- ref_param_groups.each {|group| group.reject!(&block) }
55
- user_params.reject!(&block)
56
39
  self
57
40
  end
58
41
 
@@ -60,14 +43,6 @@ module Mspire
60
43
  reject!(&block).describe_many!(describe_many_arg)
61
44
  end
62
45
 
63
- #def params_by_name
64
- # params.index_by &:name
65
- #end
66
-
67
- #def params_by_accession
68
- # accessionable_params.index_by &:accession
69
- #end
70
-
71
46
  # returns the value if the param exists by that name. Returns true if
72
47
  # the param exists but has no value. returns false if no param
73
48
  def fetch(name)
@@ -98,8 +73,6 @@ module Mspire
98
73
 
99
74
  def initialize
100
75
  @cv_params = []
101
- @user_params = []
102
- @ref_param_groups = []
103
76
  end
104
77
  alias_method :params_init, :initialize
105
78
 
@@ -128,28 +101,17 @@ module Mspire
128
101
  self
129
102
  end
130
103
 
131
- # takes a node with children that are cvParam, userParam or
132
- # referenceableParamGroupRef and a hash containing
133
- # referenceableParamGroup objects indexed by id. The only time ref_hash
134
- # should be left nil is for the referenceableParamGroup itself.
135
- #
136
- # All param elements are required to appear before other elements, so
137
- # the code walks through each child node to see if it is a paramable
138
- # element. The first child node that is not paramable is returned (or
139
- # nil if none)
140
- #
104
+ # takes a node with children that are cvParam objects
141
105
  # returns the next child node after the paramable elements or nil if none
142
106
  def describe_from_xml!(xml_node, ref_hash=nil)
107
+ # TODO: this was merely cleaned up from Paramable and should be
108
+ # re-factored
143
109
  return nil unless (child_n = xml_node.child)
144
110
  loop do
145
111
  array =
146
112
  case child_n.name
147
- when 'referenceableParamGroupRef'
148
- @ref_param_groups << ref_hash[child_n[:ref]]
149
113
  when 'cvParam'
150
114
  @cv_params << Mspire::CV::Param[ child_n[:accession], child_n[:value] ]
151
- when 'userParam'
152
- @user_params << Mspire::UserParam.new(child_n[:name], child_n[:value], child_n[:type])
153
115
  else # assumes that the above precede any following children as per the spec
154
116
  break
155
117
  end
@@ -161,8 +123,7 @@ module Mspire
161
123
  child_n
162
124
  end
163
125
 
164
- # Expects arguments describing a single CV::Param, Mspire::UserParam, or
165
- # Mspire::Mzml::ReferenceableParamGroup
126
+ # Expects arguments describing a single CV::Param
166
127
  #
167
128
  # obj.describe! 'MS:1000130' # a positive scan
168
129
  # obj.describe! CV::Param['MS:1000130'] # same behavior
@@ -176,24 +137,16 @@ module Mspire
176
137
  case (arg=args.first)
177
138
  when String
178
139
  @cv_params << Mspire::CV::Param[ *args ]
179
- when Mspire::Mzml::ReferenceableParamGroup
180
- @ref_param_groups << arg
181
140
  else
182
- if arg.is_a?(Mspire::UserParam)
183
- @user_params << arg
184
- else
185
- @cv_params << arg
186
- end
141
+ @cv_params << arg
187
142
  end
188
143
  self
189
144
  end
190
145
 
191
146
  # iterates over @params and calls .to_xml on each object.
192
147
  def to_xml(xml)
193
- [:ref_param_groups, :cv_params, :user_params].each do |kind|
194
- self.send(kind).each do |obj|
195
- obj.to_xml(xml)
196
- end
148
+ self.cv_params.each do |obj|
149
+ obj.to_xml(xml)
197
150
  end
198
151
  xml
199
152
  end
@@ -0,0 +1,29 @@
1
+ require 'mspire/cv/paramable'
2
+
3
+ module Mspire
4
+ module Mzid
5
+ class Modification
6
+ include Mspire::CV::Paramable
7
+ # optional avg mass
8
+ attr_accessor :avg_mass_delta
9
+
10
+ # From IdentML spec: "Location of the modification within the peptide -
11
+ # position in peptide sequence, counted from the N-terminus residue,
12
+ # starting at position 1. Specific modifications to the N-terminus
13
+ # should be given the location 0. Modification to the C-terminus should
14
+ # be given as peptide length + 1. If the modification location is
15
+ # unknown e.g. for PMF data, this attribute should be omitted."
16
+ attr_accessor :location
17
+
18
+ attr_accessor :monoisotopic_mass_delta
19
+
20
+ # Array of residues. Specification of the residue (amino acid) on which
21
+ # the modification occurs. If multiple values are given, it is assumed
22
+ # that the exact residue modified is unknown i.e. the modification is to
23
+ # ONE of the residues listed. Multiple residues would usually only be
24
+ # specified for PMF data.
25
+ attr_accessor :residues
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ require 'mspire/cv/paramable'
2
+
3
+ module Mspire
4
+ module Identml
5
+
6
+ # a parameter for a spectral search. An idealized modification. See
7
+ # Modification for describing a modification on an actual peptide.
8
+ class SearchModification
9
+ include Mspire::CV::Paramable
10
+
11
+ # boolean
12
+ attr_accessor :fixed_mod
13
+
14
+ # mass delta in daltons
15
+ attr_accessor :mass_delta
16
+
17
+ # A *Set* of characters. From mzIdentml: "The residue(s) searched with the
18
+ # specified modification. For N or C terminal modifications that can occur
19
+ # on any residue, the . character should be used to specify any, otherwise
20
+ # the list of amino acids should be provided."
21
+ attr_accessor :residues
22
+
23
+ # A single SpecificityRules object
24
+ attr_accessor :specificity_rules
25
+
26
+ end
27
+
28
+ end
29
+ end
@@ -1,4 +1,4 @@
1
- require 'mspire/cv/paramable'
1
+ require 'mspire/paramable'
2
2
 
3
3
  module Mspire
4
4
  class Mzml
@@ -27,7 +27,7 @@ module Mspire
27
27
  # e.g.: MS:1000433 (low-energy collision-induced dissociation)
28
28
  # et al.
29
29
  class Activation
30
- include Mspire::CV::Paramable
30
+ include Mspire::Paramable
31
31
 
32
32
  def to_xml(builder)
33
33
  builder.activation {|xml| super(xml) }
@@ -1,11 +1,11 @@
1
- require 'mspire/cv/paramable'
1
+ require 'mspire/paramable'
2
2
  require 'mspire/mzml/list'
3
3
 
4
4
  module Mspire
5
5
  class Mzml
6
6
  # order is not an intrinsic property of this object, so it
7
7
  module Component
8
- include Mspire::CV::Paramable
8
+ include Mspire::Paramable
9
9
  # using custom list_xml, so no extend Mspire::Mzml::List
10
10
 
11
11
  def initialize
@@ -1,4 +1,4 @@
1
- require 'mspire/cv/paramable'
1
+ require 'mspire/paramable'
2
2
 
3
3
  module Mspire
4
4
  class Mzml
@@ -11,7 +11,7 @@ module Mspire
11
11
  email: 'MS:1000589'
12
12
  }
13
13
 
14
- include Mspire::CV::Paramable
14
+ include Mspire::Paramable
15
15
 
16
16
  def to_xml(builder)
17
17
  builder.contact do |fc_n|
@@ -1,6 +1,6 @@
1
1
  require 'base64'
2
2
  require 'zlib'
3
- require 'mspire/cv/paramable'
3
+ require 'mspire/paramable'
4
4
 
5
5
  module Mspire
6
6
  class Mzml
@@ -16,7 +16,7 @@ end
16
16
  # will be written with the same precision as it was read in with.
17
17
  class Mspire::Mzml::DataArray < Array
18
18
  alias_method :array_init, :initialize
19
- include Mspire::CV::Paramable
19
+ include Mspire::Paramable
20
20
 
21
21
  DEFAULT_DTYPE_ACC = 'MS:1000523' # float64
22
22
  DEFAULT_COMPRESSION_ACC = 'MS:1000574'
@@ -1,10 +1,10 @@
1
- require 'mspire/cv/paramable'
1
+ require 'mspire/paramable'
2
2
  require 'mspire/mzml/data_array'
3
3
 
4
4
  module Mspire
5
5
  class Mzml
6
6
  module DataArrayContainerLike
7
- include Mspire::CV::Paramable
7
+ include Mspire::Paramable
8
8
 
9
9
  ###########################################
10
10
  # ATTRIBUTES
@@ -1,4 +1,4 @@
1
- require 'mspire/cv/paramable'
1
+ require 'mspire/paramable'
2
2
 
3
3
  module Mspire
4
4
  class Mzml
@@ -8,7 +8,7 @@ module Mspire
8
8
  # describe the nativeID format used in the file by referring to an
9
9
  # appropriate CV term.
10
10
  class FileContent
11
- include Mspire::CV::Paramable
11
+ include Mspire::Paramable
12
12
 
13
13
  def to_xml(builder, &block)
14
14
  builder.fileContent do |fc_n|
@@ -1,11 +1,11 @@
1
- require 'mspire/cv/paramable'
1
+ require 'mspire/paramable'
2
2
  require 'mspire/mzml/component'
3
3
  require 'mspire/mzml/list'
4
4
 
5
5
  module Mspire
6
6
  class Mzml
7
7
  class InstrumentConfiguration
8
- include Mspire::CV::Paramable
8
+ include Mspire::Paramable
9
9
  extend Mspire::Mzml::List
10
10
 
11
11
  # (required) the id that this guy can be referenced from
@@ -1,4 +1,4 @@
1
- require 'mspire/cv/paramable'
1
+ require 'mspire/paramable'
2
2
 
3
3
  module Mspire
4
4
  class Mzml
@@ -15,7 +15,7 @@ module Mspire
15
15
  # e.g.: MS:1000828 (isolation window lower offset)
16
16
  # e.g.: MS:1000829 (isolation window upper offset)
17
17
  class IsolationWindow
18
- include Mspire::CV::Paramable
18
+ include Mspire::Paramable
19
19
 
20
20
  def to_xml(builder)
21
21
  builder.isolationWindow {|xml| super(xml) }
@@ -1,4 +1,4 @@
1
- require 'mspire/cv/paramable'
1
+ require 'mspire/paramable'
2
2
 
3
3
  module Mspire
4
4
  class Mzml
@@ -22,7 +22,7 @@ module Mspire
22
22
  # e.g.: MS:1000745 (retention time alignment)
23
23
  # e.g.: MS:1000746 (high intensity data point removal)
24
24
  class ProcessingMethod
25
- include Mspire::CV::Paramable
25
+ include Mspire::Paramable
26
26
 
27
27
  attr_accessor :software
28
28
 
@@ -1,4 +1,4 @@
1
- require 'mspire/cv/paramable'
1
+ require 'mspire/paramable'
2
2
 
3
3
  module Mspire
4
4
  class Mzml
@@ -8,7 +8,7 @@ module Mspire
8
8
  # object itself (and not a reference). Merely callying #to_xml will
9
9
  # result in a referenceableParamGroupRef being created.
10
10
  class ReferenceableParamGroup
11
- include Mspire::CV::Paramable
11
+ include Mspire::Paramable
12
12
 
13
13
  attr_accessor :id
14
14
 
@@ -1,4 +1,4 @@
1
- require 'mspire/cv/paramable'
1
+ require 'mspire/paramable'
2
2
  require 'mspire/mzml/io_index'
3
3
  require 'mspire/mzml/spectrum_list'
4
4
  require 'mspire/mzml/chromatogram_list'
@@ -6,7 +6,7 @@ require 'mspire/mzml/chromatogram_list'
6
6
  module Mspire
7
7
  class Mzml
8
8
  class Run
9
- include Mspire::CV::Paramable
9
+ include Mspire::Paramable
10
10
 
11
11
  # required
12
12
  attr_accessor :default_instrument_configuration
@@ -1,10 +1,10 @@
1
- require 'mspire/cv/paramable'
1
+ require 'mspire/paramable'
2
2
  require 'mspire/mzml/list'
3
3
 
4
4
  module Mspire
5
5
  class Mzml
6
6
  class Sample
7
- include Mspire::CV::Paramable
7
+ include Mspire::Paramable
8
8
  extend Mspire::Mzml::List
9
9
 
10
10
  # A unique identifier across the samples with which to reference this sample description.
@@ -1,11 +1,11 @@
1
- require 'mspire/cv/paramable'
2
- require 'mspire/cv/paramable'
1
+ require 'mspire/paramable'
2
+ require 'mspire/paramable'
3
3
  require 'mspire/mzml/scan_window'
4
4
 
5
5
  module Mspire
6
6
  class Mzml
7
7
  class Scan
8
- include Mspire::CV::Paramable
8
+ include Mspire::Paramable
9
9
 
10
10
  # (optional) the Mspire::Mzml::Spectrum object from which the precursor is
11
11
  # derived. (the sourceFileRef is derived from this spectrum object if
@@ -1,4 +1,4 @@
1
- require 'mspire/cv/paramable'
1
+ require 'mspire/paramable'
2
2
  require 'mspire/mzml/scan'
3
3
 
4
4
  module Mspire
@@ -11,7 +11,7 @@ module Mspire
11
11
  # e.g.: MS:1000575 (mean of spectra)
12
12
  # e.g.: MS:1000795 (no combination)
13
13
  class ScanList < Array
14
- include Mspire::CV::Paramable
14
+ include Mspire::Paramable
15
15
 
16
16
  def initialize
17
17
  params_init
@@ -1,10 +1,10 @@
1
1
  require 'mspire/mzml/list'
2
- require 'mspire/cv/paramable'
2
+ require 'mspire/paramable'
3
3
 
4
4
  module Mspire
5
5
  class Mzml
6
6
  class ScanSettings
7
- include Mspire::CV::Paramable
7
+ include Mspire::Paramable
8
8
  extend Mspire::Mzml::List
9
9
 
10
10
  attr_accessor :id
@@ -1,4 +1,4 @@
1
- require 'mspire/cv/paramable'
1
+ require 'mspire/paramable'
2
2
 
3
3
  module Mspire
4
4
  class Mzml
@@ -7,7 +7,7 @@ module Mspire
7
7
  # accession="MS:1000501" name="scan window lower limit" value="400"
8
8
  # accession="MS:1000500" name="scan window upper limit" value="1800"
9
9
  class ScanWindow
10
- include Mspire::CV::Paramable
10
+ include Mspire::Paramable
11
11
  extend Mspire::Mzml::List
12
12
 
13
13
  def to_xml(builder)
@@ -1,5 +1,5 @@
1
1
  require 'mspire/mzml/list'
2
- require 'mspire/cv/paramable'
2
+ require 'mspire/paramable'
3
3
 
4
4
  module Mspire
5
5
  class Mzml
@@ -10,7 +10,7 @@ module Mspire
10
10
  # e.g.: MS:1000633 (possible charge state)
11
11
  # e.g.: MS:1000744 (selected ion m/z)
12
12
  class SelectedIon
13
- include Mspire::CV::Paramable
13
+ include Mspire::Paramable
14
14
  extend Mspire::Mzml::List
15
15
 
16
16
  def to_xml(builder)
@@ -1,11 +1,11 @@
1
1
  require 'mspire'
2
2
  require 'mspire/mzml/list'
3
- require 'mspire/cv/paramable'
3
+ require 'mspire/paramable'
4
4
 
5
5
  module Mspire
6
6
  class Mzml
7
7
  class Software
8
- include Mspire::CV::Paramable
8
+ include Mspire::Paramable
9
9
  extend Mspire::Mzml::List
10
10
 
11
11
  attr_accessor :id, :version
@@ -1,11 +1,11 @@
1
- require 'mspire/cv/paramable'
1
+ require 'mspire/paramable'
2
2
  require 'mspire/mzml/list'
3
3
  require 'pathname'
4
4
 
5
5
  module Mspire
6
6
  class Mzml
7
7
  class SourceFile
8
- include Mspire::CV::Paramable
8
+ include Mspire::Paramable
9
9
  extend Mspire::Mzml::List
10
10
 
11
11
  # (required) An identifier for this file.
@@ -0,0 +1,201 @@
1
+ require 'cv/param'
2
+ require 'mspire/user_param'
3
+ require 'mspire/cv/param'
4
+ require 'nokogiri'
5
+ require 'andand'
6
+
7
+ module Mspire
8
+ module Paramable
9
+
10
+ attr_accessor :cv_params
11
+ attr_accessor :user_params
12
+ attr_accessor :ref_param_groups
13
+
14
+ def params
15
+ cv_params + ref_param_groups.flat_map(&:params) + user_params
16
+ end
17
+
18
+ def each_param(&block)
19
+ return enum_for __method__ unless block
20
+ cv_params.each(&block)
21
+ ref_param_groups.flat_map(&:params).each(&block)
22
+ user_params.each(&block)
23
+ nil
24
+ end
25
+
26
+ def params?
27
+ cv_params.size > 0 ||
28
+ ref_param_groups.any? {|group| group.params.size > 0 } ||
29
+ user_params.size > 0
30
+ end
31
+
32
+ def each_accessionable_param(&block)
33
+ return enum_for __method__ unless block
34
+ cv_params.each(&block)
35
+ ref_param_groups.flat_map(&:params).each(&block)
36
+ nil
37
+ end
38
+
39
+ def accessionable_params
40
+ cv_params + ref_param_groups.flat_map(&:params)
41
+ end
42
+
43
+ # yields each current param. If the return value is not false or nil,
44
+ # it is deleted (i.e., any true value and it is deleted). Then adds the
45
+ # given parameter or makes a new one by accession number.
46
+ def replace!(*describe_args, &block)
47
+ reject!(&block).describe!(*describe_args)
48
+ end
49
+
50
+ # returns self
51
+ def reject!(&block)
52
+ cv_params.reject!(&block)
53
+ ref_param_groups.each {|group| group.reject!(&block) }
54
+ user_params.reject!(&block)
55
+ self
56
+ end
57
+
58
+ def replace_many!(describe_many_arg, &block)
59
+ reject!(&block).describe_many!(describe_many_arg)
60
+ end
61
+
62
+ #def params_by_name
63
+ # params.index_by &:name
64
+ #end
65
+
66
+ #def params_by_accession
67
+ # accessionable_params.index_by &:accession
68
+ #end
69
+
70
+ # returns the value if the param exists by that name. Returns true if
71
+ # the param exists but has no value. returns false if no param
72
+ def fetch(name)
73
+ param = each_param.find {|param| param.name == name}
74
+ if param
75
+ param.value || true
76
+ else
77
+ false
78
+ end
79
+ end
80
+
81
+ # returns the value if the param exists with that accession. Returns
82
+ # true if the param exists but has no value. returns false if no param
83
+ # with that accession.
84
+ def fetch_by_accession(acc)
85
+ param = accessionable_params.find {|v| v.accession == acc }
86
+ if param
87
+ param.value || true
88
+ else
89
+ false
90
+ end
91
+ end
92
+ alias_method :fetch_by_acc, :fetch_by_accession
93
+
94
+ def param?(name)
95
+ params.any? {|param| param.name == name }
96
+ end
97
+
98
+ def initialize
99
+ @cv_params = []
100
+ @user_params = []
101
+ @ref_param_groups = []
102
+ end
103
+ alias_method :params_init, :initialize
104
+
105
+ def param_by_accession(acc)
106
+ each_accessionable_param.find {|v| v.accession == acc }
107
+ end
108
+ alias_method :param_by_acc, :param_by_accession
109
+
110
+ # takes an array of values, each of which is fed into describe!
111
+ # returns self.
112
+ def describe_many!(array)
113
+ array.each do |arg|
114
+ if arg.is_a?(Array)
115
+ describe!(*arg)
116
+ else
117
+ describe!(arg)
118
+ end
119
+ end
120
+ self
121
+ end
122
+
123
+ # reads the paramable nodes and returns self. Use this if your element
124
+ # does not have anything besides paramable elements.
125
+ def describe_self_from_xml!(xml_node, ref_hash=nil)
126
+ describe_from_xml!(xml_node, ref_hash)
127
+ self
128
+ end
129
+
130
+ # takes a node with children that are cvParam, userParam or
131
+ # referenceableParamGroupRef and a hash containing
132
+ # referenceableParamGroup objects indexed by id. The only time ref_hash
133
+ # should be left nil is for the referenceableParamGroup itself.
134
+ #
135
+ # All param elements are required to appear before other elements, so
136
+ # the code walks through each child node to see if it is a paramable
137
+ # element. The first child node that is not paramable is returned (or
138
+ # nil if none)
139
+ #
140
+ # returns the next child node after the paramable elements or nil if none
141
+ def describe_from_xml!(xml_node, ref_hash=nil)
142
+ return nil unless (child_n = xml_node.child)
143
+ loop do
144
+ array =
145
+ case child_n.name
146
+ when 'referenceableParamGroupRef'
147
+ @ref_param_groups << ref_hash[child_n[:ref]]
148
+ when 'cvParam'
149
+ @cv_params << Mspire::CV::Param[ child_n[:accession], child_n[:value] ]
150
+ when 'userParam'
151
+ @user_params << Mspire::UserParam.new(child_n[:name], child_n[:value], child_n[:type])
152
+ else # assumes that the above precede any following children as per the spec
153
+ break
154
+ end
155
+ if (unit_acc = child_n[:unitAccession])
156
+ array.last.unit = ::CV::Param.new(child_n[:unitCvRef], unit_acc, child_n[:unitName])
157
+ end
158
+ break unless child_n = child_n.next
159
+ end
160
+ child_n
161
+ end
162
+
163
+ # Expects arguments describing a single CV::Param, Mspire::UserParam, or
164
+ # Mspire::Mzml::ReferenceableParamGroup
165
+ #
166
+ # obj.describe! 'MS:1000130' # a positive scan
167
+ # obj.describe! CV::Param['MS:1000130'] # same behavior
168
+ #
169
+ # # base peak intensity, units=number of counts
170
+ # obj.describe! "MS:1000505", 1524.5865478515625, 'MS:1000131'
171
+ #
172
+ # returns self
173
+ def describe!(*args)
174
+ return self if args.first.nil?
175
+ case (arg=args.first)
176
+ when String
177
+ @cv_params << Mspire::CV::Param[ *args ]
178
+ when Mspire::Mzml::ReferenceableParamGroup
179
+ @ref_param_groups << arg
180
+ else
181
+ if arg.is_a?(Mspire::UserParam)
182
+ @user_params << arg
183
+ else
184
+ @cv_params << arg
185
+ end
186
+ end
187
+ self
188
+ end
189
+
190
+ # iterates over @params and calls .to_xml on each object.
191
+ def to_xml(xml)
192
+ [:ref_param_groups, :cv_params, :user_params].each do |kind|
193
+ self.send(kind).each do |obj|
194
+ obj.to_xml(xml)
195
+ end
196
+ end
197
+ xml
198
+ end
199
+
200
+ end
201
+ end
@@ -1,3 +1,3 @@
1
1
  module Mspire
2
- VERSION = "0.9.2"
2
+ VERSION = "0.10.0"
3
3
  end
@@ -1,15 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
- require 'mspire/cv/paramable'
3
+ require 'mspire/paramable'
4
4
  require 'mspire/cv/param'
5
5
  require 'mspire/user_param'
6
6
  require 'mspire/mzml/referenceable_param_group'
7
7
 
8
8
  class ParamableObject
9
- include Mspire::CV::Paramable
9
+ include Mspire::Paramable
10
10
  end
11
11
 
12
- describe 'Mspire::CV::Paramable' do
12
+ describe 'Mspire::Paramable' do
13
13
 
14
14
  subject do
15
15
  paramable = ParamableObject.new.describe_many!(['MS:1000007', ['MS:1000511', 2]])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mspire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John T. Prince
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-28 00:00:00.000000000 Z
12
+ date: 2013-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -281,6 +281,8 @@ files:
281
281
  - lib/mspire/mass/subatomic.rb
282
282
  - lib/mspire/mass/util.rb
283
283
  - lib/mspire/molecular_formula.rb
284
+ - lib/mspire/mzid/modification.rb
285
+ - lib/mspire/mzid/search_modification.rb
284
286
  - lib/mspire/mzml.rb
285
287
  - lib/mspire/mzml/activation.rb
286
288
  - lib/mspire/mzml/chromatogram.rb
@@ -319,6 +321,7 @@ files:
319
321
  - lib/mspire/mzml/spectrum.rb
320
322
  - lib/mspire/mzml/spectrum_list.rb
321
323
  - lib/mspire/obo.rb
324
+ - lib/mspire/paramable.rb
322
325
  - lib/mspire/peak.rb
323
326
  - lib/mspire/peaklist.rb
324
327
  - lib/mspire/plms1.rb