Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Weights.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2017.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: Anton Pervukhin <Anton.Pervukhin@CeBiTec.Uni-Bielefeld.DE> $
33 // --------------------------------------------------------------------------
34 //
35 
36 #ifndef OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_WEIGHTS_H
37 #define OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_WEIGHTS_H
38 
39 #include <vector>
40 #include <ostream>
41 
42 #include <OpenMS/config.h>
43 
44 namespace OpenMS
45 {
46  namespace ims
47  {
68  class OPENMS_DLLAPI Weights
69  {
70 public:
72  typedef long unsigned int weight_type;
73 
75  typedef double alphabet_mass_type;
76 
78  typedef std::vector<weight_type> weights_type;
79 
81  typedef std::vector<alphabet_mass_type> alphabet_masses_type;
82 
84  typedef weights_type::size_type size_type;
85 
87  Weights() {}
88 
95  Weights(const alphabet_masses_type & masses, alphabet_mass_type precision) :
96  alphabet_masses_(masses),
97  precision_(precision)
98  {
99  setPrecision(precision);
100  }
101 
107  Weights(const Weights & other) :
108  alphabet_masses_(other.alphabet_masses_),
109  precision_(other.precision_),
110  weights_(other.weights_) {}
111 
118  Weights & operator=(const Weights & other);
119 
125  size_type size() const
126  {
127  return weights_.size();
128  }
129 
136  weight_type getWeight(size_type i) const
137  {
138  return weights_[i];
139  }
140 
146  void setPrecision(alphabet_mass_type precision);
147 
153  alphabet_mass_type getPrecision() const
154  {
155  return precision_;
156  }
157 
166  weight_type operator[](size_type i) const
167  {
168  return weights_[i];
169  }
170 
176  weight_type back() const
177  {
178  return weights_.back();
179  }
180 
187  alphabet_mass_type getAlphabetMass(size_type i) const
188  {
189  return alphabet_masses_[i];
190  }
191 
195  alphabet_mass_type getParentMass(const std::vector<unsigned int> & decomposition) const;
196 
203  void swap(size_type index1, size_type index2);
204 
217  bool divideByGCD();
218 
219  alphabet_mass_type getMinRoundingError() const;
220 
221  alphabet_mass_type getMaxRoundingError() const;
222 private:
226  alphabet_masses_type alphabet_masses_;
227 
231  alphabet_mass_type precision_;
232 
236  weights_type weights_;
237  };
238 
245  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Weights & weights);
246 
247  } // namespace ims
248 } // namespace OpenMS
249 
250 #endif // OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_WEIGHTS_H
alphabet_mass_type precision_
Definition: Weights.h:231
Weights(const alphabet_masses_type &masses, alphabet_mass_type precision)
Definition: Weights.h:95
std::vector< weight_type > weights_type
Type of container to store integer values.
Definition: Weights.h:78
Weights(const Weights &other)
Definition: Weights.h:107
Represents a set of weights (double values and scaled with a certain precision their integer counterp...
Definition: Weights.h:68
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
weight_type back() const
Definition: Weights.h:176
Weights()
Empty constructor.
Definition: Weights.h:87
alphabet_masses_type alphabet_masses_
Definition: Weights.h:226
double alphabet_mass_type
Type of double values to be used.
Definition: Weights.h:75
weight_type getWeight(size_type i) const
Definition: Weights.h:136
long unsigned int weight_type
Type of integer values to be used.
Definition: Weights.h:72
weights_type weights_
Definition: Weights.h:236
alphabet_mass_type getAlphabetMass(size_type i) const
Definition: Weights.h:187
weight_type operator[](size_type i) const
Definition: Weights.h:166
size_type size() const
Definition: Weights.h:125
weights_type::size_type size_type
Type of container&#39;s size.
Definition: Weights.h:84
std::vector< alphabet_mass_type > alphabet_masses_type
Type of container to store double values.
Definition: Weights.h:81
alphabet_mass_type getPrecision() const
Definition: Weights.h:153
std::ostream & operator<<(std::ostream &os, const IMSAlphabet &alphabet)

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:04 using doxygen 1.8.13