OpenMS  2.4.0
IsotopeDistribution.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-2018.
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: Chris Bielow $
32 // $Authors: Clemens Groepl, Andreas Bertsch, Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_CHEMISTRY_ISOTOPEDISTRIBUTION_ISOTOPEDISTRIBUTION_H
36 #define OPENMS_CHEMISTRY_ISOTOPEDISTRIBUTION_ISOTOPEDISTRIBUTION_H
37 
38 
40 #include <OpenMS/KERNEL/Peak1D.h>
41 
42 #include <utility>
43 #include <functional>
44 
45 #include <vector>
46 #include <set>
47 #include <map>
48 
49 
50 namespace OpenMS
51 {
70  class Element;
71 
72  class OPENMS_DLLAPI IsotopeDistribution
73  {
74 public:
75 
77 
78  typedef Peak1D MassAbundance;
80  typedef std::vector<MassAbundance> ContainerType;
81  typedef ContainerType::iterator iterator;
82  typedef ContainerType::iterator Iterator;
83  typedef ContainerType::const_iterator const_iterator;
84  typedef ContainerType::const_iterator ConstIterator;
85 
86  typedef ContainerType::reverse_iterator reverse_iterator;
87  typedef ContainerType::reverse_iterator ReverseIterator;
88  typedef ContainerType::const_reverse_iterator const_reverse_iterator;
89  typedef ContainerType::const_reverse_iterator ConstReverseIterator;
91 
92 
93  enum Sorted {INTENSITY, MASS, UNDEFINED};
94 
95 
97 
98 
101 
103  IsotopeDistribution(const IsotopeDistribution & isotope_distribution);
104 
106  virtual ~IsotopeDistribution();
108 
110 
111 
113  void set(const ContainerType & distribution);
114 
116  const ContainerType & getContainer() const;
117 
119  Peak1D::CoordinateType getMax() const;
120 
122  Peak1D::CoordinateType getMin() const;
123 
125  Peak1D getMostAbundant() const;
126 
128  Size size() const;
129 
131  void clear();
132 
133  // resizes distribution container
134  void resize(UInt size);
135 
137  void trimIntensities(double cutoff);
138 
140  void sortByIntensity();
141 
143  void sortByMass();
144 
150  void renormalize();
151 
159  void merge(double resolution, double min_prob);
160 
161 
170  void trimRight(double cutoff);
171 
180  void trimLeft(double cutoff);
181 
182 
183 
184  bool isNormalized() const;
185 
186 
187  double averageMass() const;
188 
189  bool isConvolutionUnit() const;
191 
193 
194  IsotopeDistribution & operator=(const IsotopeDistribution & isotope_distribution);
196 
198  bool operator==(const IsotopeDistribution & isotope_distribution) const;
199 
201  bool operator!=(const IsotopeDistribution & isotope_distribution) const;
202 
204  bool operator<(const IsotopeDistribution & isotope_distribution) const;
206 
208 
209  inline Iterator begin() { return distribution_.begin(); }
210 
211  inline Iterator end() { return distribution_.end(); }
212 
213  inline ConstIterator begin() const { return distribution_.begin(); }
214 
215  inline ConstIterator end() const { return distribution_.end(); }
216 
217  inline ReverseIterator rbegin() { return distribution_.rbegin(); }
218 
219  inline ReverseIterator rend() { return distribution_.rend(); }
220 
221  inline ConstReverseIterator rbegin() const { return distribution_.rbegin(); }
222 
223  inline ConstReverseIterator rend() const { return distribution_.rend(); }
224 
225  inline void insert(const Peak1D::CoordinateType& mass, const Peak1D::IntensityType& intensity)
226  {
227  distribution_.push_back(Peak1D(mass, intensity));
228  }
230 
232 
233  Peak1D& operator[](const Size& index){ return distribution_[index];}
235 
237 
238 
239 protected:
240 
242  void sort_(std::function<bool(const MassAbundance& p1, const MassAbundance& p2)> sorter);
244  void transform_(std::function<void(MassAbundance&)> lambda);
245 
248  };
249 
250 
251 } // namespace OpenMS
252 
253 #endif // OPENMS_CHEMISTRY_ISOTOPEDISTRIBUTION_ISOTOPEDISTRIBUTION_H
Sorted
Definition: IsotopeDistribution.h:93
ContainerType::iterator Iterator
Definition: IsotopeDistribution.h:82
ContainerType::reverse_iterator reverse_iterator
Definition: IsotopeDistribution.h:86
ReverseIterator rbegin()
Definition: IsotopeDistribution.h:217
Iterator end()
Definition: IsotopeDistribution.h:211
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
Definition: IsotopeDistribution.h:72
ContainerType::iterator iterator
Definition: IsotopeDistribution.h:81
bool operator==(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:806
std::vector< MassAbundance > ContainerType
Definition: IsotopeDistribution.h:80
ReverseIterator rend()
Definition: IsotopeDistribution.h:219
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
bool operator<(const MultiplexDeltaMasses &dm1, const MultiplexDeltaMasses &dm2)
ContainerType::reverse_iterator ReverseIterator
Definition: IsotopeDistribution.h:87
void insert(const Peak1D::CoordinateType &mass, const Peak1D::IntensityType &intensity)
Definition: IsotopeDistribution.h:225
ContainerType::const_reverse_iterator const_reverse_iterator
Definition: IsotopeDistribution.h:88
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
Iterator begin()
Definition: IsotopeDistribution.h:209
ConstReverseIterator rbegin() const
Definition: IsotopeDistribution.h:221
ConstReverseIterator rend() const
Definition: IsotopeDistribution.h:223
ContainerType::const_iterator const_iterator
Definition: IsotopeDistribution.h:83
bool operator!=(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:824
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
ConstIterator begin() const
Definition: IsotopeDistribution.h:213
ContainerType distribution_
stores the isotope distribution
Definition: IsotopeDistribution.h:247
ConstIterator end() const
Definition: IsotopeDistribution.h:215
ContainerType::const_iterator ConstIterator
Definition: IsotopeDistribution.h:84
ContainerType::const_reverse_iterator ConstReverseIterator
Definition: IsotopeDistribution.h:89