OpenMS  2.8.0
MSChromatogram.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: Andreas Bertsch $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
43 
44 namespace OpenMS
45 {
46  class ChromatogramPeak;
47 
53  class OPENMS_DLLAPI MSChromatogram :
54  private std::vector<ChromatogramPeak>,
55  public RangeManagerContainer<RangeRT, RangeIntensity>,
57  {
58 
59 public:
60 
62  struct OPENMS_DLLAPI MZLess
63  {
64  bool operator()(const MSChromatogram& a, const MSChromatogram& b) const;
65  };
66 
74  typedef std::vector<PeakType> ContainerType;
79  typedef std::vector<FloatDataArray> FloatDataArrays;
82  typedef std::vector<StringDataArray> StringDataArrays;
85  typedef std::vector<IntegerDataArray> IntegerDataArrays;
87 
89 
90  typedef typename ContainerType::iterator Iterator;
93  typedef typename ContainerType::const_iterator ConstIterator;
95  typedef typename ContainerType::reverse_iterator ReverseIterator;
97  typedef typename ContainerType::const_reverse_iterator ConstReverseIterator;
99 
101 
102  using ContainerType::operator[];
103  using ContainerType::begin;
104  using ContainerType::rbegin;
105  using ContainerType::end;
106  using ContainerType::rend;
107  using ContainerType::resize;
108  using ContainerType::size;
109  using ContainerType::push_back;
110  using ContainerType::pop_back;
111  using ContainerType::empty;
112  using ContainerType::front;
113  using ContainerType::back;
114  using ContainerType::reserve;
115  using ContainerType::insert;
116  using ContainerType::erase;
117  using ContainerType::swap;
118 
119  using typename ContainerType::iterator;
120  using typename ContainerType::const_iterator;
121  using typename ContainerType::size_type;
122  using typename ContainerType::value_type;
123  using typename ContainerType::reference;
124  using typename ContainerType::const_reference;
125  using typename ContainerType::pointer;
126  using typename ContainerType::difference_type;
128 
130  MSChromatogram() = default;
131 
133  MSChromatogram(const MSChromatogram&) = default;
134 
137 
139  ~MSChromatogram() = default;
140 
143 
146 
148  bool operator==(const MSChromatogram& rhs) const;
149 
151  bool operator!=(const MSChromatogram& rhs) const
152  {
153  return !(operator==(rhs));
154  }
155 
156  // Docu in base class (RangeManager)
157  void updateRanges() override
158  {
159  clearRanges();
160  for (const auto& peak : (ContainerType&) *this)
161  {
162  extendRT(peak.getRT());
163  extendIntensity(peak.getIntensity());
164  }
165  }
166 
170  const String& getName() const;
171 
173  void setName(const String& name);
174 
176 
178  double getMZ() const;
179 
195 
198 
201  {
202  float_data_arrays_ = fda;
203  }
204 
207 
210 
213  {
214  string_data_arrays_ = sda;
215  }
216 
219 
222 
225  {
226  integer_data_arrays_ = ida;
227  }
228 
230 
233 
238  void sortByIntensity(bool reverse = false);
239 
247 
249  bool isSorted() const;
250 
252 
255 
266 
274 
282 
290 
298 
306 
314 
322 
324 
332 
342 
352 
362 
372 
382 
392 
402 
412 
418  void clear(bool clear_meta_data);
419 
421 
434  void mergePeaks(MSChromatogram& other, bool add_meta=false);
435 
436 protected:
437 
440 
443 
446 
449  };
450 
452  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const MSChromatogram& chrom);
453 
454 } // namespace OpenMS
455 
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:54
double CoordinateType
Coordinate type.
Definition: ChromatogramPeak.h:67
Representation of chromatogram settings, e.g. SRM/MRM chromatograms.
Definition: ChromatogramSettings.h:61
Float data array class.
Definition: DataArrays.h:48
Integer data array class.
Definition: DataArrays.h:55
String data array class.
Definition: DataArrays.h:62
The representation of a chromatogram.
Definition: MSChromatogram.h:57
void setIntegerDataArrays(const IntegerDataArrays &ida)
Sets the integer meta data arrays.
Definition: MSChromatogram.h:224
Iterator PosBegin(CoordinateType rt)
Binary search for peak range begin.
FloatDataArrays & getFloatDataArrays()
Returns a mutable reference to the float meta data arrays.
MSChromatogram(MSChromatogram &&)=default
Move constructor.
PeakType::CoordinateType CoordinateType
Coordinate (RT) type.
Definition: MSChromatogram.h:72
ConstIterator RTBegin(CoordinateType rt) const
Binary search for peak range begin.
std::vector< StringDataArray > StringDataArrays
Definition: MSChromatogram.h:82
OpenMS::DataArrays::FloatDataArray FloatDataArray
Float data array vector type.
Definition: MSChromatogram.h:78
ConstIterator RTEnd(ConstIterator begin, CoordinateType rt, ConstIterator end) const
Binary search for peak range end (returns the past-the-end iterator)
MSChromatogram(const MSChromatogram &)=default
Copy constructor.
ChromatogramPeak PeakType
Definition: MSChromatogram.h:70
MSChromatogram & operator=(const MSChromatogram &source)
Assignment operator.
String name_
Name.
Definition: MSChromatogram.h:439
ContainerType::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSChromatogram.h:93
ConstIterator RTEnd(CoordinateType rt) const
Binary search for peak range end (returns the past-the-end iterator)
StringDataArrays & getStringDataArrays()
Returns a mutable reference to the string meta data arrays.
ContainerType::reverse_iterator ReverseIterator
Mutable reverse iterator.
Definition: MSChromatogram.h:95
Iterator RTEnd(Iterator begin, CoordinateType rt, Iterator end)
Binary search for peak range end (returns the past-the-end iterator)
Iterator RTEnd(CoordinateType rt)
Binary search for peak range end (returns the past-the-end iterator)
std::vector< PeakType > ContainerType
Chromatogram base type.
Definition: MSChromatogram.h:74
ContainerType::const_reverse_iterator ConstReverseIterator
Non-mutable reverse iterator.
Definition: MSChromatogram.h:97
void mergePeaks(MSChromatogram &other, bool add_meta=false)
Adds all the chromatogram peaks from another MSChromatogram and updates the metadata to indicate a me...
bool isSorted() const
Checks if all peaks are sorted with respect to ascending RT.
~MSChromatogram()=default
Destructor.
RangeManager< RangeRT, RangeIntensity > RangeManagerType
RangeManager.
Definition: MSChromatogram.h:76
MSChromatogram()=default
Constructor.
Iterator PosBegin(Iterator begin, CoordinateType rt, Iterator end)
Binary search for peak range begin.
bool operator!=(const MSChromatogram &rhs) const
Equality operator.
Definition: MSChromatogram.h:151
void setName(const String &name)
Sets the name.
void sortByPosition()
Lexicographically sorts the peaks by their position.
StringDataArrays string_data_arrays_
String data arrays.
Definition: MSChromatogram.h:445
ConstIterator PosBegin(ConstIterator begin, CoordinateType rt, ConstIterator end) const
Binary search for peak range begin.
void sortByIntensity(bool reverse=false)
Lexicographically sorts the peaks by their intensity.
const IntegerDataArrays & getIntegerDataArrays() const
Returns a const reference to the integer meta data arrays.
ConstIterator PosEnd(ConstIterator begin, CoordinateType rt, ConstIterator end) const
Binary search for peak range end (returns the past-the-end iterator)
IntegerDataArrays integer_data_arrays_
Integer data arrays.
Definition: MSChromatogram.h:448
Size findNearest(CoordinateType rt) const
Binary search for the peak nearest to a specific RT.
OpenMS::DataArrays::StringDataArray StringDataArray
String data array vector type.
Definition: MSChromatogram.h:81
ConstIterator PosBegin(CoordinateType rt) const
Binary search for peak range begin.
MSChromatogram & operator=(MSChromatogram &&) &=default
Move assignment operator.
Iterator RTBegin(CoordinateType rt)
Binary search for peak range begin.
Iterator PosEnd(Iterator begin, CoordinateType rt, Iterator end)
Binary search for peak range end (returns the past-the-end iterator)
bool operator==(const MSChromatogram &rhs) const
Equality operator.
ConstIterator PosEnd(CoordinateType rt) const
Binary search for peak range end (returns the past-the-end iterator)
const String & getName() const
FloatDataArrays float_data_arrays_
Float data arrays.
Definition: MSChromatogram.h:442
const FloatDataArrays & getFloatDataArrays() const
void setStringDataArrays(const StringDataArrays &sda)
Sets the string meta data arrays.
Definition: MSChromatogram.h:212
ConstIterator RTBegin(ConstIterator begin, CoordinateType rt, ConstIterator end) const
Binary search for peak range begin.
Iterator PosEnd(CoordinateType rt)
Binary search for peak range end (returns the past-the-end iterator)
const StringDataArrays & getStringDataArrays() const
Returns a const reference to the string meta data arrays.
std::vector< FloatDataArray > FloatDataArrays
Definition: MSChromatogram.h:79
void updateRanges() override
Definition: MSChromatogram.h:157
OpenMS::DataArrays::IntegerDataArray IntegerDataArray
Integer data array vector type.
Definition: MSChromatogram.h:84
void clear(bool clear_meta_data)
Clears all data and meta data.
std::vector< IntegerDataArray > IntegerDataArrays
Definition: MSChromatogram.h:85
IntegerDataArrays & getIntegerDataArrays()
Returns a mutable reference to the integer meta data arrays.
void setFloatDataArrays(const FloatDataArrays &fda)
Sets the float meta data arrays.
Definition: MSChromatogram.h:200
Iterator RTBegin(Iterator begin, CoordinateType rt, Iterator end)
Binary search for peak range begin.
double getMZ() const
returns the mz of the product entry, makes sense especially for MRM scans
ConstIterator MZEnd(CoordinateType rt) const
Definition: RangeManager.h:652
Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra.
Definition: RangeManager.h:455
A more convenient string class.
Definition: String.h:60
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
static String & reverse(String &this_s)
Definition: StringUtilsSimple.h:350
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
Comparator for the retention time.
Definition: MSChromatogram.h:63
bool operator()(const MSChromatogram &a, const MSChromatogram &b) const