24 class ChromatogramPeak;
73 typedef std::vector<SpectrumType>
Base;
78 typedef std::vector<SpectrumType>::iterator
Iterator;
125 return spectra_.size();
137 return spectra_.empty();
160 return spectra_.begin();
165 return spectra_.cbegin();
170 return spectra_.cbegin();
175 return spectra_.end();
180 return spectra_.cend();
185 return spectra_.cend();
201 template <
class Container>
204 for (
typename Base::const_iterator spec = spectra_.begin(); spec != spectra_.end(); ++spec)
206 if (spec->getMSLevel() != 1)
210 typename Container::value_type s;
211 for (
typename SpectrumType::const_iterator it = spec->begin(); it != spec->end(); ++it)
214 cont.back().setRT(spec->getRT());
215 cont.back().setMZ(it->getMZ());
216 cont.back().setIntensity(it->getIntensity());
232 template <
class Container>
235 set2DData<false, Container>(container);
252 template <
class Container>
259 for (
typename Container::const_iterator iter = container.begin(); iter != container.end(); ++iter)
262 if (current_rt != iter->getRT() || spectrum ==
nullptr)
265 if (current_rt > iter->getRT())
269 current_rt = iter->getRT();
270 spectrum = createSpec_(current_rt, store_metadata_names);
296 template <
bool add_mass_traces,
class Container>
303 for (
typename Container::const_iterator iter = container.begin(); iter != container.end(); ++iter)
306 if (current_rt != iter->getRT() || spectrum ==
nullptr)
309 if (current_rt > iter->getRT())
313 current_rt = iter->getRT();
314 spectrum = createSpec_(current_rt);
327 AreaIterator areaBegin(CoordinateType min_rt, CoordinateType max_rt,
329 CoordinateType min_mz, CoordinateType max_mz,
UInt ms_level = 1);
365 std::vector<float>& rt,
366 std::vector<std::vector<float>>& mz,
367 std::vector<std::vector<float>>& intensity)
const
370 for (
auto it = areaBeginConst(min_rt, max_rt, min_mz, max_mz, ms_level); it != areaEndConst(); ++it)
374 t = (float)it.getRT();
376 mz.push_back(std::vector<float>());
377 intensity.push_back(std::vector<float>());
379 mz.back().push_back((
float)it->getMZ());
380 intensity.back().push_back(it->getIntensity());
404 std::vector<float>& rt,
405 std::vector<std::vector<float>>& mz,
406 std::vector<std::vector<float>>& intensity,
407 std::vector<std::vector<float>>& ion_mobility)
const
410 std::vector<float> im;
412 for (
auto it = areaBeginConst(min_rt, max_rt, min_mz, max_mz, ms_level); it != areaEndConst(); ++it)
416 t = (float)it.getRT();
418 std::tie(unit, im) = it.getSpectrum().maybeGetIMData();
419 mz.push_back(std::vector<float>());
420 intensity.push_back(std::vector<float>());
421 ion_mobility.push_back(std::vector<float>());
426 const Size peak_index = it.getPeakIndex().peak;
427 ion_mobility.back().push_back(im[peak_index]);
431 ion_mobility.back().push_back(-1.0);
433 mz.back().push_back((
float)it->getMZ());
434 intensity.back().push_back(it->getIntensity());
457 std::vector<float>& rt,
458 std::vector<float>& mz,
459 std::vector<float>& intensity)
462 for (
auto it = areaBeginConst(min_rt, max_rt, min_mz, max_mz, ms_level); it != areaEndConst(); ++it)
464 rt.push_back((
float)it.getRT());
465 mz.push_back((
float)it->getMZ());
466 intensity.push_back(it->getIntensity());
490 std::vector<float>& rt,
491 std::vector<float>& mz,
492 std::vector<float>& intensity,
493 std::vector<float>& ion_mobility)
const
495 for (
auto it = areaBeginConst(min_rt, max_rt, min_mz, max_mz, ms_level); it != areaEndConst(); ++it)
498 std::vector<float> im;
502 t = (float)it.getRT();
503 std::tie(unit, im) = it.getSpectrum().maybeGetIMData();
505 rt.push_back((
float)it.getRT());
506 mz.push_back((
float)it->getMZ());
507 intensity.push_back(it->getIntensity());
510 const Size peak_index = it.getPeakIndex().peak;
511 ion_mobility.push_back(im[peak_index]);
515 ion_mobility.push_back(-1.0);
532 template <
typename Iterator>
535 using ValueType =
typename std::iterator_traits<Iterator>::value_type;
536 using IntensityType = decltype(std::declval<ValueType>().getIntensity());
537 static_assert(std::is_member_function_pointer_v<decltype(&ValueType::getIntensity)>,
538 "Iterator value type must have getIntensity() member function");
541 for (
auto it = begin; it != end; ++it) {
542 sum += it->getIntensity();
597 template<
class MzReductionFunctionType>
598 std::vector<std::vector<MSExperiment::CoordinateType>>
aggregate(
599 const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges,
600 unsigned int ms_level,
601 MzReductionFunctionType func_mz_reduction)
const
604 if (mz_rt_ranges.empty())
611 std::vector<std::reference_wrapper<const MSSpectrum>> spectra_view;
612 spectra_view.reserve(spectra_.size());
613 std::copy_if(spectra_.begin(), spectra_.end(),
614 std::back_inserter(spectra_view),
615 [ms_level](
const auto& spec) {
616 return spec.getMSLevel() == ms_level;
620 if (spectra_view.empty()) {
626 auto getCoveredSpectra = [](
627 const std::vector<std::reference_wrapper<const MSSpectrum>>& spectra_view,
628 const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges)
629 -> std::vector<std::pair<size_t, size_t>>
631 std::vector<std::pair<size_t, size_t>> res;
632 res.reserve(mz_rt_ranges.size());
634 for (
const auto & mz_rt : mz_rt_ranges)
638 auto start_it = std::lower_bound(spectra_view.begin(), spectra_view.end(), mz_rt.second.getMin(),
639 [](
const auto& spec,
double rt)
640 { return spec.get().getRT() < rt; });
642 auto stop_it = std::upper_bound(spectra_view.begin(), spectra_view.end(), mz_rt.second.getMax(),
643 [](
double rt,
const auto& spec)
644 { return rt < spec.get().getRT(); });
647 std::distance(spectra_view.begin(), start_it),
648 std::distance(spectra_view.begin(), stop_it)
656 const std::vector<std::pair<size_t, size_t>> rt_ranges_idcs = getCoveredSpectra(spectra_view, mz_rt_ranges);
659 std::vector<std::vector<MSExperiment::CoordinateType>> result(mz_rt_ranges.size());
662 std::vector<std::vector<size_t>> spec_idx_to_range_idx(spectra_view.size());
665 for (
size_t i = 0; i < rt_ranges_idcs.size(); ++i)
667 const auto& [start, stop] = rt_ranges_idcs[i];
668 result[i].resize(stop - start);
670 for (
size_t j = start; j < stop; ++j)
672 spec_idx_to_range_idx[j].push_back(i);
676 #pragma omp parallel for schedule(dynamic)
677 for (
Int64 i = 0; i < (
Int64)spec_idx_to_range_idx.size(); ++i)
679 if (spec_idx_to_range_idx[i].empty())
continue;
681 const auto& spec = spectra_view[i].get();
682 auto spec_begin = spec.cbegin();
683 auto spec_end = spec.cend();
685 for (
size_t range_idx : spec_idx_to_range_idx[i])
687 const auto& mz_range = mz_rt_ranges[range_idx].first;
690 auto start_it = spec.PosBegin(spec_begin, mz_range.getMinMZ(), spec_end);
691 auto end_it = start_it;
693 while (end_it != spec_end && end_it->getPosition() <= mz_range.getMaxMZ())
701 result[range_idx][i - rt_ranges_idcs[range_idx].first] =
702 func_mz_reduction(start_it, end_it);
709 std::vector<std::vector<MSExperiment::CoordinateType>>
aggregate(
710 const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges,
711 unsigned int ms_level)
const
728 template<
class MzReductionFunctionType>
730 const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges,
731 unsigned int ms_level,
732 MzReductionFunctionType func_mz_reduction)
const
735 if (mz_rt_ranges.empty())
742 std::vector<std::reference_wrapper<const MSSpectrum>> spectra_view;
743 spectra_view.reserve(spectra_.size());
744 std::copy_if(spectra_.begin(), spectra_.end(),
745 std::back_inserter(spectra_view),
746 [ms_level](
const auto& spec) {
747 return spec.getMSLevel() == ms_level;
751 if (spectra_view.empty()) {
757 auto getCoveredSpectra = [](
758 const std::vector<std::reference_wrapper<const MSSpectrum>>& spectra_view,
759 const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges)
760 -> std::vector<std::pair<size_t, size_t>>
762 std::vector<std::pair<size_t, size_t>> res;
763 res.reserve(mz_rt_ranges.size());
765 for (
const auto & mz_rt : mz_rt_ranges)
767 auto start_it = std::lower_bound(spectra_view.begin(), spectra_view.end(), mz_rt.second.getMin(),
768 [](
const auto& spec,
double rt)
769 { return spec.get().getRT() < rt; });
771 auto stop_it = std::upper_bound(spectra_view.begin(), spectra_view.end(), mz_rt.second.getMax(),
772 [](
double rt,
const auto& spec)
773 { return rt < spec.get().getRT(); });
776 std::distance(spectra_view.begin(), start_it),
777 std::distance(spectra_view.begin(), stop_it)
784 const std::vector<std::pair<size_t, size_t>> rt_ranges_idcs = getCoveredSpectra(spectra_view, mz_rt_ranges);
787 std::vector<MSChromatogram> result(mz_rt_ranges.size());
790 std::vector<std::vector<size_t>> spec_idx_to_range_idx(spectra_view.size());
793 for (
size_t i = 0; i < rt_ranges_idcs.size(); ++i)
795 const auto& [start, stop] = rt_ranges_idcs[i];
796 result[i].resize(stop - start);
797 result[i].getProduct().setMZ(
798 (mz_rt_ranges[i].first.getMinMZ() + mz_rt_ranges[i].first.getMaxMZ()) / 2.0);
799 for (
size_t j = start; j < stop; ++j)
801 spec_idx_to_range_idx[j].push_back(i);
805 #pragma omp parallel for schedule(dynamic)
806 for (
Int64 i = 0; i < (
Int64)spec_idx_to_range_idx.size(); ++i)
808 if (spec_idx_to_range_idx[i].empty())
continue;
810 const auto& spec = spectra_view[i].get();
811 const double rt = spec.getRT();
812 auto spec_begin = spec.cbegin();
813 auto spec_end = spec.cend();
815 for (
size_t range_idx : spec_idx_to_range_idx[i])
817 const auto& mz_range = mz_rt_ranges[range_idx].first;
820 auto start_it = spec.PosBegin(spec_begin, mz_range.getMinMZ(), spec_end);
821 auto end_it = start_it;
823 while (end_it != spec_end && end_it->getPosition() <= mz_range.getMaxMZ())
829 result[range_idx][i - rt_ranges_idcs[range_idx].first] =
834 for (
auto& r : result) r.updateRanges();
841 const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges,
842 unsigned int ms_level)
const
857 unsigned int ms_level,
858 const std::string& mz_agg)
const
861 if (ranges.cols() != 4)
864 "Range matrix must have 4 columns [mz_min, mz_max, rt_min, rt_max]");
868 std::vector<std::pair<RangeMZ, RangeRT>> mz_rt_ranges;
869 mz_rt_ranges.reserve((
Size)ranges.rows());
871 for (
Size i = 0; i < (
Size)ranges.rows(); ++i)
873 mz_rt_ranges.emplace_back(
874 RangeMZ(ranges(i, 0), ranges(i, 1)),
875 RangeRT(ranges(i, 2), ranges(i, 3))
883 return aggregate(mz_rt_ranges, ms_level,
884 [](
auto begin_it,
auto end_it)
886 return std::accumulate(begin_it, end_it, 0.0,
890 else if (mz_agg ==
"max")
892 return aggregate(mz_rt_ranges, ms_level,
893 [](
auto begin_it,
auto end_it)->
double
895 if (begin_it == end_it)
return 0.0;
896 return std::max_element(begin_it, end_it,
901 else if (mz_agg ==
"min")
903 return aggregate(mz_rt_ranges, ms_level,
904 [](
auto begin_it,
auto end_it)->
double
906 if (begin_it == end_it)
return 0.0;
907 return std::min_element(begin_it, end_it,
912 else if (mz_agg ==
"mean")
914 return aggregate(mz_rt_ranges, ms_level,
915 [](
auto begin_it,
auto end_it)
917 if (begin_it == end_it)
return 0.0;
918 double sum = std::accumulate(begin_it, end_it, 0.0,
920 return sum /
static_cast<double>(std::distance(begin_it, end_it));
926 "Invalid aggregation function", mz_agg);
940 unsigned int ms_level,
941 const std::string& mz_agg)
const
944 if (ranges.cols() != 4)
947 "Range matrix must have 4 columns [mz_min, mz_max, rt_min, rt_max]");
951 std::vector<std::pair<RangeMZ, RangeRT>> mz_rt_ranges;
952 mz_rt_ranges.reserve((
Size)ranges.rows());
954 for (
Size i = 0; i < (
Size)ranges.rows(); ++i)
956 mz_rt_ranges.emplace_back(
957 RangeMZ(ranges(i, 0), ranges(i, 1)),
958 RangeRT(ranges(i, 2), ranges(i, 3))
965 return extractXICs(mz_rt_ranges, ms_level,
966 [](
auto begin_it,
auto end_it)
968 return std::accumulate(begin_it, end_it, 0.0,
972 else if (mz_agg ==
"max")
974 return extractXICs(mz_rt_ranges, ms_level,
975 [](
auto begin_it,
auto end_it)->
double
977 if (begin_it == end_it)
return 0.0;
978 return std::max_element(begin_it, end_it,
983 else if (mz_agg ==
"min")
985 return extractXICs(mz_rt_ranges, ms_level,
986 [](
auto begin_it,
auto end_it)->
double
988 if (begin_it == end_it)
return 0.0;
989 return std::min_element(begin_it, end_it,
994 else if (mz_agg ==
"mean")
996 return extractXICs(mz_rt_ranges, ms_level,
997 [](
auto begin_it,
auto end_it)
999 if (begin_it == end_it)
return 0.0;
1000 double sum = std::accumulate(begin_it, end_it, 0.0,
1002 return sum /
static_cast<double>(std::distance(begin_it, end_it));
1008 "Invalid aggregation function", mz_agg);
1293 template<
typename ContainerValueType,
bool addMassTraces>
1300 template<
typename ContainerValueType>
1307 spectrum->insert(spectrum->end(),
PeakType());
1308 spectrum->back().setIntensity(item->getIntensity());
1309 spectrum->back().setPosition(item->getMZ());
1314 addData_(spectrum, item);
1315 for (StringList::const_iterator itm = store_metadata_names.begin(); itm != store_metadata_names.end(); ++itm)
1317 float val = std::numeric_limits<float>::quiet_NaN();
1318 if (item->metaValueExists(*itm)) val = item->getMetaValue(*itm);
1324 template<
typename ContainerValueType>
1330 if (item->metaValueExists(
"num_of_masstraces"))
1332 Size mts = item->getMetaValue(
"num_of_masstraces");
1333 int charge = (item->getCharge()==0 ? 1 : item->getCharge());
1334 for (
Size i = 0; i < mts; ++i)
1337 if (!item->metaValueExists(meta_name))
1339 throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
String(
"Meta value '") + meta_name +
"' expected but not found in container.");
1341 ContainerValueType p;
1342 p.setIntensity(item->getMetaValue(meta_name));
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:28
Exception indicating that an invalid parameter was handed over to an algorithm.
Definition: Exception.h:316
Invalid value exception.
Definition: Exception.h:305
Precondition failed exception.
Definition: Exception.h:128
Description of the experimental settings.
Definition: ExperimentalSettings.h:36
Forward iterator for an area of peaks in an experiment.
Definition: AreaIterator.h:36
The representation of a chromatogram.
Definition: MSChromatogram.h:30
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:48
const ExperimentalSettings & getExperimentalSettings() const
returns the meta information of this experiment (const access)
MSExperiment(MSExperiment &&)=default
Move constructor.
ConstIterator IMBegin(CoordinateType im) const
Fast search for spectrum range begin.
ConstIterator getClosestSpectrumInRT(const double RT, UInt ms_level) const
Returns the closest(=nearest) spectrum in retention time to the given RT of a certain MS level.
std::vector< SpectrumType > spectra_
spectra
Definition: MSExperiment.h:1288
const std::vector< MSChromatogram > & getChromatograms() const
returns the chromatogram list
std::vector< SpectrumType > Base
STL base class type.
Definition: MSExperiment.h:73
void setChromatograms(std::vector< MSChromatogram > &&chromatograms)
Base::iterator iterator
Definition: MSExperiment.h:92
bool containsScanOfLevel(size_t ms_level) const
returns true if at least one of the spectra has the specified level
ConstAreaIterator areaBeginConst(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz, UInt ms_level=1) const
Returns a non-mutable area iterator for area.
~MSExperiment() override
D'tor.
PeakType::CoordinateType CoordinateType
Coordinate type of peak positions.
Definition: MSExperiment.h:61
void get2DData(Container &cont) const
Reads out a 2D Spectrum.
Definition: MSExperiment.h:202
void swap(MSExperiment &from)
Swaps the content of this map with the content of from.
MSChromatogram ChromatogramType
Chromatogram type.
Definition: MSExperiment.h:71
void addSpectrum(const MSSpectrum &spectrum)
adds a spectrum to the list
PeakType::IntensityType IntensityType
Intensity type of peaks.
Definition: MSExperiment.h:63
void set2DData(const Container &container, const StringList &store_metadata_names)
Assignment of a data container with RT and MZ to an MSExperiment.
Definition: MSExperiment.h:253
std::vector< SpectrumType >::iterator Iterator
Mutable iterator.
Definition: MSExperiment.h:79
bool clearMetaDataArrays()
Clears the meta data arrays of all contained spectra (float, integer and string arrays)
SpectrumType * createSpec_(PeakType::CoordinateType rt)
ConstAreaIterator areaBeginConst(const RangeManagerType &range, UInt ms_level=1) const
Returns a non-mutable area iterator for all peaks in range. If a dimension is empty(),...
ConstIterator RTBegin(CoordinateType rt) const
Fast search for spectrum range begin.
Size getNrSpectra() const
get the total number of spectra available
std::vector< MSChromatogram > extractXICs(const std::vector< std::pair< RangeMZ, RangeRT >> &mz_rt_ranges, unsigned int ms_level, MzReductionFunctionType func_mz_reduction) const
Extracts extracted ion chromatograms (XICs) from the MSExperiment.
Definition: MSExperiment.h:729
bool empty() const noexcept
Are there any spectra (does not consider chromatograms)
Definition: MSExperiment.h:135
UInt64 getSize() const
returns the total number of peaks (spectra and chromatograms included)
std::vector< MSChromatogram > extractXICs(const std::vector< std::pair< RangeMZ, RangeRT >> &mz_rt_ranges, unsigned int ms_level) const
Definition: MSExperiment.h:840
ConstIterator begin() const noexcept
Definition: MSExperiment.h:163
MSExperiment & operator=(MSExperiment &&) &=default
Move assignment operator.
ConstIterator cbegin() const noexcept
Definition: MSExperiment.h:168
ConstIterator RTEnd(CoordinateType rt) const
Fast search for spectrum range end (returns the past-the-end iterator)
RangeManagerContainer< RangeRT, RangeMZ, RangeIntensity, RangeMobility > RangeManagerContainerType
RangeManager type.
Definition: MSExperiment.h:67
void addChromatogram(MSChromatogram &&chrom)
ExperimentalSettings & getExperimentalSettings()
returns the meta information of this experiment (mutable access)
void reserveSpaceChromatograms(Size s)
Iterator getClosestSpectrumInRT(const double RT, UInt ms_level)
Iterator begin() noexcept
Definition: MSExperiment.h:158
SpectrumType * createSpec_(PeakType::CoordinateType rt, const StringList &metadata_names)
ChromatogramPeakT ChromatogramPeakType
Chromatogram peak type.
Definition: MSExperiment.h:59
MSSpectrum & getSpectrum(Size id)
returns a single spectrum
AreaIterator areaBegin(const RangeManagerType &range, UInt ms_level=1)
Returns an area iterator for all peaks in range. If a dimension is empty(), it is ignored (i....
Iterator RTEnd(CoordinateType rt)
Fast search for spectrum range end (returns the past-the-end iterator)
MSExperiment & operator=(const MSExperiment &source)
Assignment operator.
MSSpectrum SpectrumType
Spectrum Type.
Definition: MSExperiment.h:69
Size getNrChromatograms() const
get the total number of chromatograms available
Iterator getClosestSpectrumInRT(const double RT)
Base::value_type value_type
Definition: MSExperiment.h:91
Size size() const noexcept
The number of spectra.
Definition: MSExperiment.h:123
MSExperiment()
Constructor.
bool operator!=(const MSExperiment &rhs) const
Equality operator.
Peak1D PeakT
Definition: MSExperiment.h:51
ConstAreaIterator areaEndConst() const
Returns a non-mutable invalid area iterator marking the end of an area.
void get2DPeakDataIMPerSpectrum(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz, Size ms_level, std::vector< float > &rt, std::vector< std::vector< float >> &mz, std::vector< std::vector< float >> &intensity, std::vector< std::vector< float >> &ion_mobility) const
Definition: MSExperiment.h:398
void set2DData(const Container &container)
Assignment of a data container with RT and MZ to an MSExperiment.
Definition: MSExperiment.h:233
void setSpectra(std::vector< MSSpectrum > &&spectra)
void getPrimaryMSRunPath(StringList &toFill) const
get the file path to the first MS run
void resize(Size n)
Resize to n spectra.
Definition: MSExperiment.h:129
ConstIterator cend() const noexcept
Definition: MSExperiment.h:183
void get2DPeakData(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz, Size ms_level, std::vector< float > &rt, std::vector< float > &mz, std::vector< float > &intensity) const
Definition: MSExperiment.h:451
std::vector< MSChromatogram > & getChromatograms()
returns the chromatogram list (mutable)
void setSpectra(const std::vector< MSSpectrum > &spectra)
sets the spectrum list
void updateRanges(Int ms_level)
Updates the m/z, intensity, and retention time ranges of all spectra with a certain ms level.
void get2DPeakDataIM(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz, Size ms_level, std::vector< float > &rt, std::vector< float > &mz, std::vector< float > &intensity, std::vector< float > &ion_mobility) const
Definition: MSExperiment.h:484
void sortChromatograms(bool sort_rt=true)
Sorts the data points of the chromatograms by m/z.
int getFirstProductSpectrum(int zero_based_index) const
Returns the index of the first product spectrum given an index.
Iterator RTBegin(CoordinateType rt)
Fast search for spectrum range begin.
std::vector< std::vector< MSExperiment::CoordinateType > > aggregateFromMatrix(const Matrix< double > &ranges, unsigned int ms_level, const std::string &mz_agg) const
Wrapper for aggregate function that takes a matrix of m/z and RT ranges.
Definition: MSExperiment.h:855
Internal::AreaIterator< const PeakT, const PeakT &, const PeakT *, ConstIterator, SpectrumType::ConstIterator > ConstAreaIterator
Immutable area iterator type (for traversal of a rectangular subset of the peaks)
Definition: MSExperiment.h:85
void setChromatograms(const std::vector< MSChromatogram > &chromatograms)
sets the chromatogram list
Internal::AreaIterator< PeakT, PeakT &, PeakT *, Iterator, SpectrumType::Iterator > AreaIterator
Mutable area iterator type (for traversal of a rectangular subset of the peaks)
Definition: MSExperiment.h:83
const SpectrumType & operator[](Size n) const
Random access to n'th spectrum.
Definition: MSExperiment.h:153
const MSChromatogram calculateTIC(float rt_bin_size=0, UInt ms_level=1) const
Computes the total ion chromatogram (TIC) for a given MS level (use ms_level = 0 for all levels).
const std::vector< MSSpectrum > & getSpectra() const
returns the spectrum list
std::vector< MSChromatogram > extractXICsFromMatrix(const Matrix< double > &ranges, unsigned int ms_level, const std::string &mz_agg) const
Wrapper for extractXICs function that takes a matrix of m/z and RT ranges.
Definition: MSExperiment.h:938
Iterator end()
Definition: MSExperiment.h:173
std::vector< std::vector< MSExperiment::CoordinateType > > aggregate(const std::vector< std::pair< RangeMZ, RangeRT >> &mz_rt_ranges, unsigned int ms_level) const
Definition: MSExperiment.h:709
bool isSorted(bool check_mz=true) const
Checks if all spectra are sorted with respect to ascending RT.
MSExperiment(const MSExperiment &source)
Copy constructor.
ConstIterator end() const noexcept
Definition: MSExperiment.h:178
RangeManager< RangeRT, RangeMZ, RangeIntensity, RangeMobility > RangeManagerType
RangeManager type.
Definition: MSExperiment.h:65
std::vector< MSSpectrum > & getSpectra()
returns the spectrum list (mutable)
ConstIterator getClosestSpectrumInRT(const double RT) const
Returns the closest(=nearest) spectrum in retention time to the given RT.
void set2DData(const Container &container)
Assignment of a data container with RT and MZ to an MSExperiment.
Definition: MSExperiment.h:297
ChromatogramPeak ChromatogramPeakT
Definition: MSExperiment.h:52
void sortSpectra(bool sort_mz=true)
Sorts the data points by retention time.
std::vector< UInt > getMSLevels() const
returns a sorted array of MS levels (calculated on demand)
void reset()
Clear all internal data (spectra, ranges, metadata)
void addSpectrum(MSSpectrum &&spectrum)
void reserveSpaceSpectra(Size s)
bool hasZeroIntensities(size_t ms_level) const
returns true if any MS spectra of trthe specified level contain at least one peak with intensity of 0...
bool operator==(const MSExperiment &rhs) const
Equality operator.
ConstIterator IMEnd(CoordinateType im) const
Fast search for spectrum range end (returns the past-the-end iterator)
void get2DPeakDataPerSpectrum(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz, Size ms_level, std::vector< float > &rt, std::vector< std::vector< float >> &mz, std::vector< std::vector< float >> &intensity) const
Definition: MSExperiment.h:359
ConstIterator getPrecursorSpectrum(ConstIterator iterator) const
Returns the precursor spectrum of the scan pointed to by iterator.
void reserve(Size n)
Reserve space for n spectra.
Definition: MSExperiment.h:141
Base::const_iterator const_iterator
Definition: MSExperiment.h:93
void updateRanges() override
std::vector< std::vector< MSExperiment::CoordinateType > > aggregate(const std::vector< std::pair< RangeMZ, RangeRT >> &mz_rt_ranges, unsigned int ms_level, MzReductionFunctionType func_mz_reduction) const
Aggregates data over specified m/z and RT ranges at a given MS level using a custom reduction functio...
Definition: MSExperiment.h:598
void setSqlRunID(UInt64 id)
sets the run-ID which is used when storing an sqMass file
MSExperiment & operator=(const ExperimentalSettings &source)
Assignment operator.
UInt64 getSqlRunID() const
void addChromatogram(const MSChromatogram &chromatogram)
adds a chromatogram to the list
std::vector< SpectrumType >::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSExperiment.h:81
bool hasPeptideIdentifications() const
do any of the spectra have a PeptideID?
void clear(bool clear_meta_data)
Clears all data and meta data.
ConstIterator getFirstProductSpectrum(ConstIterator iterator) const
SpectrumType & operator[](Size n)
Random access to n'th spectrum.
Definition: MSExperiment.h:147
int getPrecursorSpectrum(int zero_based_index) const
Returns the index of the precursor spectrum for spectrum at index zero_based_index.
std::vector< MSChromatogram > chromatograms_
chromatograms
Definition: MSExperiment.h:1286
AreaIterator areaEnd()
Returns an invalid area iterator marking the end of an area.
bool isIMFrame() const
Are all MSSpectra in this experiment part of an IM Frame? I.e. they all have the same RT,...
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
const FloatDataArrays & getFloatDataArrays() const
Returns a const reference to the float meta data arrays.
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:28
double CoordinateType
Coordinate type.
Definition: Peak1D.h:40
IntensityType getIntensity() const
Definition: Peak1D.h:82
float IntensityType
Intensity type.
Definition: Peak1D.h:36
Definition: RangeManager.h:889
A more convenient string class.
Definition: String.h:34
int64_t Int64
Signed integer type (64bit)
Definition: Types.h:40
int Int
Signed integer type.
Definition: Types.h:72
uint64_t UInt64
Unsigned integer type (64bit)
Definition: Types.h:47
unsigned int UInt
Unsigned integer type.
Definition: Types.h:64
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:44
static double sum(IteratorType begin, IteratorType end)
Calculates the sum of a range of values.
Definition: StatisticFunctions.h:81
const double C13C12_MASSDIFF_U
Definition: Constants.h:95
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Peak2D PeakType
Definition: MassTrace.h:21
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
DriftTimeUnit
Drift time unit for ion mobility.
Definition: IMTypes.h:23
static void addData_(SpectrumType *spectrum, const ContainerValueType *item)
general method for adding data points
Definition: MSExperiment.h:1304
static void addData_(SpectrumType *spectrum, const ContainerValueType *item, const StringList &store_metadata_names)
general method for adding data points, including metadata arrays (populated from metainfointerface)
Definition: MSExperiment.h:1312
static void addData_(SpectrumType *spectrum, const ContainerValueType *item)
specialization for adding feature mass traces (does not support metadata_names currently)
Definition: MSExperiment.h:1328
Helper class to add either general data points in set2DData or use mass traces from meta values.
Definition: MSExperiment.h:1295
static void addData_(SpectrumType *spectrum, const ContainerValueType *item)
static void addData_(SpectrumType *spectrum, const ContainerValueType *item, const StringList &store_metadata_names)
Calculates the sum of intensities for a range of elements.
Definition: MSExperiment.h:530
auto operator()(Iterator begin, Iterator end) const
Definition: MSExperiment.h:533
Definition: RangeManager.h:358
Definition: RangeManager.h:295