OpenMS  2.7.0
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-2021.
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 #pragma once
37 
38 #include <vector>
39 #include <iosfwd>
40 
41 #include <OpenMS/config.h>
42 
43 namespace OpenMS
44 {
45  namespace ims
46  {
67  class OPENMS_DLLAPI Weights
68  {
69 public:
71  typedef long unsigned int weight_type;
72 
74  typedef double alphabet_mass_type;
75 
77  typedef std::vector<weight_type> weights_type;
78 
80  typedef std::vector<alphabet_mass_type> alphabet_masses_type;
81 
83  typedef weights_type::size_type size_type;
84 
86  Weights() {}
87 
94  Weights(const alphabet_masses_type & masses, alphabet_mass_type precision) :
95  alphabet_masses_(masses),
96  precision_(precision)
97  {
98  setPrecision(precision);
99  }
100 
106  Weights(const Weights & other) :
107  alphabet_masses_(other.alphabet_masses_),
108  precision_(other.precision_),
109  weights_(other.weights_) {}
110 
117  Weights & operator=(const Weights & other);
118 
124  size_type size() const
125  {
126  return weights_.size();
127  }
128 
136  {
137  return weights_[i];
138  }
139 
146 
153  {
154  return precision_;
155  }
156 
166  {
167  return weights_[i];
168  }
169 
176  {
177  return weights_.back();
178  }
179 
187  {
188  return alphabet_masses_[i];
189  }
190 
194  alphabet_mass_type getParentMass(const std::vector<unsigned int> & decomposition) const;
195 
202  void swap(size_type index1, size_type index2);
203 
216  bool divideByGCD();
217 
219 
221 private:
226 
231 
236  };
237 
244  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Weights & weights);
245 
246  } // namespace ims
247 } // namespace OpenMS
248 
Represents a set of weights (double values and scaled with a certain precision their integer counterp...
Definition: Weights.h:68
void swap(size_type index1, size_type index2)
alphabet_mass_type getMinRoundingError() const
weights_type weights_
Definition: Weights.h:235
alphabet_masses_type alphabet_masses_
Definition: Weights.h:225
alphabet_mass_type precision_
Definition: Weights.h:230
void setPrecision(alphabet_mass_type precision)
alphabet_mass_type getMaxRoundingError() const
Weights(const Weights &other)
Definition: Weights.h:106
size_type size() const
Definition: Weights.h:124
Weights(const alphabet_masses_type &masses, alphabet_mass_type precision)
Definition: Weights.h:94
weight_type back() const
Definition: Weights.h:175
alphabet_mass_type getParentMass(const std::vector< unsigned int > &decomposition) const
weight_type operator[](size_type i) const
Definition: Weights.h:165
double alphabet_mass_type
Type of double values to be used.
Definition: Weights.h:74
weight_type getWeight(size_type i) const
Definition: Weights.h:135
Weights & operator=(const Weights &other)
std::vector< alphabet_mass_type > alphabet_masses_type
Type of container to store double values.
Definition: Weights.h:80
long unsigned int weight_type
Type of integer values to be used.
Definition: Weights.h:71
std::vector< weight_type > weights_type
Type of container to store integer values.
Definition: Weights.h:77
Weights()
Empty constructor.
Definition: Weights.h:86
weights_type::size_type size_type
Type of container's size.
Definition: Weights.h:83
alphabet_mass_type getPrecision() const
Definition: Weights.h:152
alphabet_mass_type getAlphabetMass(size_type i) const
Definition: Weights.h:186
std::ostream & operator<<(std::ostream &os, const IMSAlphabet &alphabet)
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47