35 #ifndef OPENMS_KERNEL_MSCHROMATOGRAM_H
36 #define OPENMS_KERNEL_MSCHROMATOGRAM_H
51 template <
typename PeakT = ChromatogramPeak>
53 private std::vector<PeakT>,
63 public std::vector<float>
69 public std::vector<String>
75 public std::vector<Int>
80 public std::binary_function<MSChromatogram, MSChromatogram, bool>
107 typedef typename ContainerType::iterator
Iterator;
119 using ContainerType::operator[];
120 using ContainerType::begin;
121 using ContainerType::rbegin;
122 using ContainerType::end;
123 using ContainerType::rend;
124 using ContainerType::resize;
125 using ContainerType::size;
126 using ContainerType::push_back;
127 using ContainerType::pop_back;
128 using ContainerType::empty;
129 using ContainerType::front;
130 using ContainerType::back;
131 using ContainerType::reserve;
132 using ContainerType::insert;
133 using ContainerType::erase;
134 using ContainerType::swap;
136 using typename ContainerType::iterator;
137 using typename ContainerType::const_iterator;
138 using typename ContainerType::size_type;
139 using typename ContainerType::value_type;
140 using typename ContainerType::reference;
141 using typename ContainerType::const_reference;
142 using typename ContainerType::pointer;
143 using typename ContainerType::difference_type;
175 if (&source ==
this)
return *
this;
177 ContainerType::operator=(source);
193 return std::operator==(*
this, rhs) &&
310 std::vector<std::pair<typename PeakType::IntensityType, Size> > sorted_indices;
311 sorted_indices.reserve(ContainerType::size());
312 for (
Size i = 0; i < ContainerType::size(); ++i)
314 sorted_indices.push_back(std::make_pair(ContainerType::operator[](i).getIntensity(), i));
328 for (
Size i = 0; i < sorted_indices.size(); ++i)
330 tmp.push_back(*(ContainerType::begin() + (sorted_indices[i].second)));
332 ContainerType::swap(tmp);
336 std::vector<float> mda_tmp;
346 std::vector<String> mda_tmp;
356 std::vector<Int> mda_tmp;
381 std::vector<std::pair<typename PeakType::PositionType, Size> > sorted_indices;
382 sorted_indices.reserve(ContainerType::size());
383 for (
Size i = 0; i < ContainerType::size(); ++i)
385 sorted_indices.push_back(std::make_pair(ContainerType::operator[](i).getPosition(), i));
391 for (
Size i = 0; i < sorted_indices.size(); ++i)
393 tmp.push_back(*(ContainerType::begin() + (sorted_indices[i].second)));
395 ContainerType::swap(tmp);
399 std::vector<float> mda_tmp;
409 std::vector<String> mda_tmp;
419 std::vector<Int> mda_tmp;
432 for (
Size i = 1; i < this->size(); ++i)
434 if (this->
operator[](i - 1).getRT() > this->operator[](i).getRT())
return false;
456 if (ContainerType::size() == 0)
throw Exception::Precondition(__FILE__, __LINE__, __PRETTY_FUNCTION__,
"There must be at least one peak to determine the nearest peak!");
461 if (it == ContainerType::begin())
return 0;
463 if (it == ContainerType::end())
return ContainerType::size() - 1;
468 if (std::fabs(it->getRT() - rt) < std::fabs(it2->getRT() - rt))
470 return Size(it - ContainerType::begin());
474 return Size(it2 - ContainerType::begin());
589 ContainerType::clear();
620 template <
typename PeakT>
621 std::ostream& operator<<(std::ostream& os, const MSChromatogram<PeakT>& chrom)
623 os <<
"-- MSCHROMATOGRAM BEGIN --" << std::endl;
626 os << static_cast<const ChromatogramSettings&>(chrom);
631 os << *it << std::endl;
634 os <<
"-- MSCHROMATOGRAM END --" << std::endl;
641 #endif // OPENMS_KERNEL_MSCHROMATOGRAM_H
Iterator RTBegin(CoordinateType rt)
Binary search for peak range begin.
Definition: MSChromatogram.h:484
Iterator RTEnd(Iterator begin, CoordinateType rt, Iterator end)
Binary search for peak range end (returns the past-the-end iterator)
Definition: MSChromatogram.h:523
FloatDataArrays & getFloatDataArrays()
Returns a mutable reference to the float meta data arrays.
Definition: MSChromatogram.h:256
FloatDataArrays float_data_arrays_
Float data arrays.
Definition: MSChromatogram.h:610
A more convenient string class.
Definition: String.h:57
const String & getName() const
Definition: MSChromatogram.h:217
bool operator==(const MSChromatogram &rhs) const
Equality operator.
Definition: MSChromatogram.h:190
Size findNearest(CoordinateType rt) const
Binary search for the peak nearest to a specific RT.
Definition: MSChromatogram.h:453
std::vector< IntegerDataArray > IntegerDataArrays
Integer data array vector type.
Definition: MSChromatogram.h:102
The representation of a chromatogram.
Definition: MSChromatogram.h:52
ContainerType::iterator Iterator
Mutable iterator.
Definition: MSChromatogram.h:108
std::vector< PeakType > ContainerType
Chromatogram base type.
Definition: MSChromatogram.h:96
ConstIterator RTEnd(CoordinateType rt) const
Binary search for peak range end (returns the past-the-end iterator)
Definition: MSChromatogram.h:562
Iterator RTBegin(Iterator begin, CoordinateType rt, Iterator end)
Binary search for peak range begin.
Definition: MSChromatogram.h:497
bool operator()(const MSChromatogram &a, const MSChromatogram &b) const
Definition: MSChromatogram.h:82
Float data array class.
Definition: MSChromatogram.h:73
const StringDataArrays & getStringDataArrays() const
Returns a const reference to the string meta data arrays.
Definition: MSChromatogram.h:262
ReverseComparator< Cmp > reverseComparator(Cmp const &cmp)
Make-function to create a ReverseComparator from another comparator without the need to specify the t...
Definition: ComparatorUtils.h:261
ConstIterator RTBegin(CoordinateType rt) const
Binary search for peak range begin.
Definition: MSChromatogram.h:536
PeakType::CoordinateType CoordinateType
Coordinate (RT) type.
Definition: MSChromatogram.h:94
bool operator==(const RangeManager &rhs) const
Equality operator.
Definition: RangeManager.h:88
Precondition failed exception.
Definition: Exception.h:167
ContainerType::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSChromatogram.h:110
void setName(const String &name)
Sets the name.
Definition: MSChromatogram.h:223
Iterator RTEnd(CoordinateType rt)
Binary search for peak range end (returns the past-the-end iterator)
Definition: MSChromatogram.h:510
virtual void updateRanges()
Updates minimum and maximum position/intensity.
Definition: MSChromatogram.h:208
StringDataArrays & getStringDataArrays()
Returns a mutable reference to the string meta data arrays.
Definition: MSChromatogram.h:268
MSChromatogram()
Constructor.
Definition: MSChromatogram.h:147
Comparator by position. Lexicographical comparison (first RT then m/z) is done.
Definition: Peak2D.h:327
double getMZ() const
returns the target m/z
ConstIterator RTBegin(ConstIterator begin, CoordinateType rt, ConstIterator end) const
Binary search for peak range begin.
Definition: MSChromatogram.h:549
void sortByIntensity(bool reverse=false)
Lexicographically sorts the peaks by their intensity.
Definition: MSChromatogram.h:294
MSChromatogram(const MSChromatogram &source)
Copy constructor.
Definition: MSChromatogram.h:158
virtual ~MSChromatogram()
Destructor.
Definition: MSChromatogram.h:169
std::vector< StringDataArray > StringDataArrays
String data array vector type.
Definition: MSChromatogram.h:100
Float data array class.
Definition: MSChromatogram.h:61
MSChromatogram & operator=(const MSChromatogram &source)
Assignment operator.
Definition: MSChromatogram.h:173
Comparator for the retention time.
Definition: MSChromatogram.h:79
RangeManager & operator=(const RangeManager &rhs)
Assignment operator.
Definition: RangeManager.h:77
void clearRanges()
Resets the ranges.
Definition: RangeManager.h:140
std::vector< FloatDataArray > FloatDataArrays
Float data array vector type.
Definition: MSChromatogram.h:98
const Product & getProduct() const
returns a const reference to the products
PeakT PeakType
Definition: MSChromatogram.h:92
Representation of chromatogram settings, e.g. SRM/MRM chromatograms.
Definition: ChromatogramSettings.h:59
const IntegerDataArrays & getIntegerDataArrays() const
Returns a const reference to the integer meta data arrays.
Definition: MSChromatogram.h:274
StringDataArrays string_data_arrays_
String data arrays.
Definition: MSChromatogram.h:613
ContainerType::reverse_iterator ReverseIterator
Mutable reverse iterator.
Definition: MSChromatogram.h:112
bool operator!=(const MSChromatogram &rhs) const
Equality operator.
Definition: MSChromatogram.h:202
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:121
void sortByPosition()
Lexicographically sorts the peaks by their position.
Definition: MSChromatogram.h:372
IntegerDataArrays integer_data_arrays_
Integer data arrays.
Definition: MSChromatogram.h:616
ConstIterator RTEnd(ConstIterator begin, CoordinateType rt, ConstIterator end) const
Binary search for peak range end (returns the past-the-end iterator)
Definition: MSChromatogram.h:575
ContainerType::const_reverse_iterator ConstReverseIterator
Non-mutable reverse iterator.
Definition: MSChromatogram.h:114
String name_
Name.
Definition: MSChromatogram.h:607
bool isSorted() const
Checks if all peaks are sorted with respect to ascending RT.
Definition: MSChromatogram.h:430
void updateRanges_(const PeakIteratorType &begin, const PeakIteratorType &end)
Updates the range using data points in the iterator range.
Definition: RangeManager.h:155
const FloatDataArrays & getFloatDataArrays() const
Definition: MSChromatogram.h:250
Handles the management of a position and intensity range.
Definition: RangeManager.h:48
Class for comparison of std::pair using first ONLY e.g. for use with std::sort.
Definition: ComparatorUtils.h:326
void clear(bool clear_meta_data)
Clears all data and meta data.
Definition: MSChromatogram.h:587
ChromatogramSettings & operator=(const ChromatogramSettings &source)
double getMZ() const
returns the mz of the product entry, makes sense especially for MRM scans
Definition: MSChromatogram.h:231
IntegerDataArrays & getIntegerDataArrays()
Returns a mutable reference to the integer meta data arrays.
Definition: MSChromatogram.h:280
String data array class.
Definition: MSChromatogram.h:67
bool operator==(const ChromatogramSettings &rhs) const
Equality operator.
ChromatogramSettings()
Constructor.