OpenMS
MSChromatogram.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: Andreas Bertsch $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
17 
18 namespace OpenMS
19 {
20  class ChromatogramPeak;
21 
27  class OPENMS_DLLAPI MSChromatogram :
28  private std::vector<ChromatogramPeak>,
29  public RangeManagerContainer<RangeRT, RangeIntensity>,
31  {
32 
33 public:
34 
36  struct OPENMS_DLLAPI MZLess
37  {
38  bool operator()(const MSChromatogram& a, const MSChromatogram& b) const;
39  };
40 
48  typedef std::vector<PeakType> ContainerType;
53  typedef std::vector<FloatDataArray> FloatDataArrays;
56  typedef std::vector<StringDataArray> StringDataArrays;
59  typedef std::vector<IntegerDataArray> IntegerDataArrays;
61 
63 
64  typedef typename ContainerType::iterator Iterator;
67  typedef typename ContainerType::const_iterator ConstIterator;
69  typedef typename ContainerType::reverse_iterator ReverseIterator;
71  typedef typename ContainerType::const_reverse_iterator ConstReverseIterator;
73 
75 
76  using ContainerType::operator[];
77  using ContainerType::begin;
78  using ContainerType::cbegin;
79  using ContainerType::rbegin;
80  using ContainerType::end;
81  using ContainerType::cend;
82  using ContainerType::rend;
83  using ContainerType::resize;
84  using ContainerType::size;
85  using ContainerType::push_back;
86  using ContainerType::pop_back;
87  using ContainerType::empty;
88  using ContainerType::front;
89  using ContainerType::back;
90  using ContainerType::reserve;
91  using ContainerType::insert;
92  using ContainerType::erase;
93  using ContainerType::swap;
94 
95  using typename ContainerType::iterator;
96  using typename ContainerType::const_iterator;
97  using typename ContainerType::size_type;
98  using typename ContainerType::value_type;
99  using typename ContainerType::reference;
100  using typename ContainerType::const_reference;
101  using typename ContainerType::pointer;
102  using typename ContainerType::difference_type;
104 
106  MSChromatogram() = default;
107 
109  MSChromatogram(const MSChromatogram&) = default;
110 
113 
115  ~MSChromatogram() = default;
116 
119 
122 
124  bool operator==(const MSChromatogram& rhs) const;
125 
127  bool operator!=(const MSChromatogram& rhs) const
128  {
129  return !(operator==(rhs));
130  }
131 
132  // Docu in base class (RangeManager)
133  void updateRanges() override
134  {
135  clearRanges();
136  for (const auto& peak : (ContainerType&) *this)
137  {
138  extendRT(peak.getRT());
139  extendIntensity(peak.getIntensity());
140  }
141  }
142 
146  const String& getName() const;
147 
149  void setName(const String& name);
150 
152 
154  double getMZ() const;
155 
171 
174 
177  {
178  float_data_arrays_ = fda;
179  }
180 
183 
186 
189  {
190  string_data_arrays_ = sda;
191  }
192 
195 
198 
201  {
202  integer_data_arrays_ = ida;
203  }
204 
206 
209 
214  void sortByIntensity(bool reverse = false);
215 
223 
225  bool isSorted() const;
226 
228 
231 
242 
250 
258 
266 
274 
282 
290 
298 
300 
308 
318 
328 
338 
348 
358 
368 
378 
388 
394  void clear(bool clear_meta_data);
395 
397 
410  void mergePeaks(MSChromatogram& other, bool add_meta=false);
411 
412 protected:
413 
416 
419 
422 
425  };
426 
428  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const MSChromatogram& chrom);
429 
430 } // namespace OpenMS
431 
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:28
double CoordinateType
Coordinate type.
Definition: ChromatogramPeak.h:41
Representation of chromatogram settings, e.g. SRM/MRM chromatograms.
Definition: ChromatogramSettings.h:35
Float data array class.
Definition: DataArrays.h:22
Integer data array class.
Definition: DataArrays.h:29
String data array class.
Definition: DataArrays.h:36
The representation of a chromatogram.
Definition: MSChromatogram.h:31
void setIntegerDataArrays(const IntegerDataArrays &ida)
Sets the integer meta data arrays.
Definition: MSChromatogram.h:200
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:46
ConstIterator RTBegin(CoordinateType rt) const
Binary search for peak range begin.
std::vector< StringDataArray > StringDataArrays
Definition: MSChromatogram.h:56
OpenMS::DataArrays::FloatDataArray FloatDataArray
Float data array vector type.
Definition: MSChromatogram.h:52
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:44
MSChromatogram & operator=(const MSChromatogram &source)
Assignment operator.
String name_
Name.
Definition: MSChromatogram.h:415
ContainerType::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSChromatogram.h:67
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:69
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:48
ContainerType::const_reverse_iterator ConstReverseIterator
Non-mutable reverse iterator.
Definition: MSChromatogram.h:71
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:50
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:127
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:421
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:424
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:55
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:418
const FloatDataArrays & getFloatDataArrays() const
void setStringDataArrays(const StringDataArrays &sda)
Sets the string meta data arrays.
Definition: MSChromatogram.h:188
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:53
void updateRanges() override
Definition: MSChromatogram.h:133
OpenMS::DataArrays::IntegerDataArray IntegerDataArray
Integer data array vector type.
Definition: MSChromatogram.h:58
void clear(bool clear_meta_data)
Clears all data and meta data.
std::vector< IntegerDataArray > IntegerDataArrays
Definition: MSChromatogram.h:59
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:176
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:872
Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra.
Definition: RangeManager.h:540
A more convenient string class.
Definition: String.h:34
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
static String & reverse(String &this_s)
Definition: StringUtilsSimple.h:330
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
Comparator for the retention time.
Definition: MSChromatogram.h:37
bool operator()(const MSChromatogram &a, const MSChromatogram &b) const