OpenMS  3.0.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-2022.
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::cbegin;
105  using ContainerType::rbegin;
106  using ContainerType::end;
107  using ContainerType::cend;
108  using ContainerType::rend;
109  using ContainerType::resize;
110  using ContainerType::size;
111  using ContainerType::push_back;
112  using ContainerType::pop_back;
113  using ContainerType::empty;
114  using ContainerType::front;
115  using ContainerType::back;
116  using ContainerType::reserve;
117  using ContainerType::insert;
118  using ContainerType::erase;
119  using ContainerType::swap;
120 
121  using typename ContainerType::iterator;
122  using typename ContainerType::const_iterator;
123  using typename ContainerType::size_type;
124  using typename ContainerType::value_type;
125  using typename ContainerType::reference;
126  using typename ContainerType::const_reference;
127  using typename ContainerType::pointer;
128  using typename ContainerType::difference_type;
130 
132  MSChromatogram() = default;
133 
135  MSChromatogram(const MSChromatogram&) = default;
136 
138  MSChromatogram(MSChromatogram&&) = default;
139 
141  ~MSChromatogram() = default;
142 
144  MSChromatogram& operator=(const MSChromatogram& source);
145 
147  MSChromatogram& operator=(MSChromatogram&&) & = default;
148 
150  bool operator==(const MSChromatogram& rhs) const;
151 
153  bool operator!=(const MSChromatogram& rhs) const
154  {
155  return !(operator==(rhs));
156  }
157 
158  // Docu in base class (RangeManager)
159  void updateRanges() override
160  {
161  clearRanges();
162  for (const auto& peak : (ContainerType&) *this)
163  {
164  extendRT(peak.getRT());
165  extendIntensity(peak.getIntensity());
166  }
167  }
168 
172  const String& getName() const;
173 
175  void setName(const String& name);
176 
178 
180  double getMZ() const;
181 
194  const FloatDataArrays& getFloatDataArrays() const;
197 
199  FloatDataArrays& getFloatDataArrays();
200 
203  {
204  float_data_arrays_ = fda;
205  }
206 
208  const StringDataArrays& getStringDataArrays() const;
209 
211  StringDataArrays& getStringDataArrays();
212 
215  {
216  string_data_arrays_ = sda;
217  }
218 
220  const IntegerDataArrays& getIntegerDataArrays() const;
221 
223  IntegerDataArrays& getIntegerDataArrays();
224 
227  {
228  integer_data_arrays_ = ida;
229  }
230 
232 
235 
240  void sortByIntensity(bool reverse = false);
241 
248  void sortByPosition();
249 
251  bool isSorted() const;
252 
254 
257 
267  Size findNearest(CoordinateType rt) const;
268 
275  Iterator RTBegin(CoordinateType rt);
276 
283  Iterator RTBegin(Iterator begin, CoordinateType rt, Iterator end);
284 
291  Iterator RTEnd(CoordinateType rt);
292 
299  Iterator RTEnd(Iterator begin, CoordinateType rt, Iterator end);
300 
307  ConstIterator RTBegin(CoordinateType rt) const;
308 
315  ConstIterator RTBegin(ConstIterator begin, CoordinateType rt, ConstIterator end) const;
316 
323  ConstIterator RTEnd(CoordinateType rt) const;
324 
325  ConstIterator MZEnd(CoordinateType rt) const;
326 
333  ConstIterator RTEnd(ConstIterator begin, CoordinateType rt, ConstIterator end) const;
334 
343  Iterator PosBegin(CoordinateType rt);
344 
353  Iterator PosBegin(Iterator begin, CoordinateType rt, Iterator end);
354 
363  ConstIterator PosBegin(CoordinateType rt) const;
364 
373  ConstIterator PosBegin(ConstIterator begin, CoordinateType rt, ConstIterator end) const;
374 
383  Iterator PosEnd(CoordinateType rt);
384 
393  Iterator PosEnd(Iterator begin, CoordinateType rt, Iterator end);
394 
403  ConstIterator PosEnd(CoordinateType rt) const;
404 
413  ConstIterator PosEnd(ConstIterator begin, CoordinateType rt, ConstIterator end) const;
414 
420  void clear(bool clear_meta_data);
421 
423 
436  void mergePeaks(MSChromatogram& other, bool add_meta=false);
437 
438 protected:
439 
442 
445 
448 
451  };
452 
454  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const MSChromatogram& chrom);
455 
456 } // namespace OpenMS
457 
OpenMS::DataArrays::IntegerDataArray
Integer data array class.
Definition: DataArrays.h:52
ChromatogramSettings.h
DataArrays.h
double
OpenMS::MSChromatogram::float_data_arrays_
FloatDataArrays float_data_arrays_
Float data arrays.
Definition: MSChromatogram.h:444
OpenMS::StringUtils::reverse
static String & reverse(String &this_s)
Definition: StringUtilsSimple.h:350
OpenMS::MSChromatogram::MZLess
Comparator for the retention time.
Definition: MSChromatogram.h:62
ChromatogramPeak.h
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::MSChromatogram::IntegerDataArrays
std::vector< IntegerDataArray > IntegerDataArrays
Definition: MSChromatogram.h:85
OpenMS::MSChromatogram::FloatDataArrays
std::vector< FloatDataArray > FloatDataArrays
Definition: MSChromatogram.h:79
OpenMS::MSChromatogram::setIntegerDataArrays
void setIntegerDataArrays(const IntegerDataArrays &ida)
Sets the integer meta data arrays.
Definition: MSChromatogram.h:226
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::MSChromatogram::ContainerType
std::vector< PeakType > ContainerType
Chromatogram base type.
Definition: MSChromatogram.h:74
OpenMS::MSChromatogram::integer_data_arrays_
IntegerDataArrays integer_data_arrays_
Integer data arrays.
Definition: MSChromatogram.h:450
OpenMS::MSChromatogram::StringDataArray
OpenMS::DataArrays::StringDataArray StringDataArray
String data array vector type.
Definition: MSChromatogram.h:81
OpenMS::MSChromatogram::FloatDataArray
OpenMS::DataArrays::FloatDataArray FloatDataArray
Float data array vector type.
Definition: MSChromatogram.h:78
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::ChromatogramSettings
Representation of chromatogram settings, e.g. SRM/MRM chromatograms.
Definition: ChromatogramSettings.h:59
OpenMS::RangeManager
Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra.
Definition: RangeManager.h:588
OpenMS::MSChromatogram::CoordinateType
PeakType::CoordinateType CoordinateType
Coordinate (RT) type.
Definition: MSChromatogram.h:72
OpenMS::MSChromatogram::StringDataArrays
std::vector< StringDataArray > StringDataArrays
Definition: MSChromatogram.h:82
OpenMS::MSChromatogram::setStringDataArrays
void setStringDataArrays(const StringDataArrays &sda)
Sets the string meta data arrays.
Definition: MSChromatogram.h:214
OpenMS::MSChromatogram::operator!=
bool operator!=(const MSChromatogram &rhs) const
Equality operator.
Definition: MSChromatogram.h:153
OpenMS::ChromatogramPeak
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:53
OpenMS::MSChromatogram::updateRanges
void updateRanges() override
Definition: MSChromatogram.h:159
OpenMS::DataArrays::StringDataArray
String data array class.
Definition: DataArrays.h:59
RangeManager.h
OpenMS::operator<<
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
OpenMS::RangeManagerContainer
Definition: RangeManager.h:919
Iterator
OpenMS::MSChromatogram::ConstReverseIterator
ContainerType::const_reverse_iterator ConstReverseIterator
Non-mutable reverse iterator.
Definition: MSChromatogram.h:97
OpenMS::MSChromatogram::Iterator
ContainerType::iterator Iterator
Mutable iterator.
Definition: MSChromatogram.h:91
OpenMS::MSChromatogram::ReverseIterator
ContainerType::reverse_iterator ReverseIterator
Mutable reverse iterator.
Definition: MSChromatogram.h:95
OpenMS::Internal::operator==
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
OpenMS::MSChromatogram
The representation of a chromatogram.
Definition: MSChromatogram.h:53
StandardDeclarations.h
OpenMS::MSChromatogram::name_
String name_
Name.
Definition: MSChromatogram.h:441
OpenMS::MSChromatogram::IntegerDataArray
OpenMS::DataArrays::IntegerDataArray IntegerDataArray
Integer data array vector type.
Definition: MSChromatogram.h:84
OpenMS::MSChromatogram::ConstIterator
ContainerType::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSChromatogram.h:93
OpenMS::MSChromatogram::PeakType
ChromatogramPeak PeakType
Definition: MSChromatogram.h:70
OpenMS::MSChromatogram::string_data_arrays_
StringDataArrays string_data_arrays_
String data arrays.
Definition: MSChromatogram.h:447
OpenMS::MSChromatogram::setFloatDataArrays
void setFloatDataArrays(const FloatDataArrays &fda)
Sets the float meta data arrays.
Definition: MSChromatogram.h:202
OpenMS::DataArrays::FloatDataArray
Float data array class.
Definition: DataArrays.h:45
OpenMS::MSChromatogram::RangeManagerType
RangeManager< RangeRT, RangeIntensity > RangeManagerType
RangeManager.
Definition: MSChromatogram.h:76
MetaInfoDescription.h