OpenMS
Loading...
Searching...
No Matches
PeakGroup.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Kyowon Jeong, Jihyung Kim $
6// $Authors: Kyowon Jeong, Jihyung Kim $
7// --------------------------------------------------------------------------
8
9#pragma once
10
14
15#include <functional>
16
17namespace OpenMS
18{
28 class OPENMS_DLLAPI PeakGroup
29 {
32
33 public:
37 {
38 target = 0,
41 };
42
43
45 PeakGroup() = default;
46
53 explicit PeakGroup(int min_abs_charge, int max_abs_charge, bool is_positive);
54
56 ~PeakGroup() = default;
57
59 PeakGroup(const PeakGroup&) = default;
60
62 PeakGroup(PeakGroup&& other) = default;
63
65 bool operator<(const PeakGroup& a) const;
66
67 bool operator>(const PeakGroup& a) const;
68
69 bool operator==(const PeakGroup& a) const;
70
72 PeakGroup& operator=(const PeakGroup& t) = default;
73
78
90 int updateQscore(const std::vector<LogMzPeak>& noisy_peaks, const FLASHHelperClasses::PrecalculatedAveragine& avg, double min_cos,
91 double tol, bool is_low_charge, const std::vector<double>& excluded_masses, bool is_last = false);
92
103 std::vector<LogMzPeak> recruitAllPeaksInSpectrum(const MSSpectrum& spec, double tol, const FLASHHelperClasses::PrecalculatedAveragine& avg, double mono_mass, bool renew_signal_peaks = true);
104
113 std::vector<LogMzPeak> getNoisyPeaks(const MSSpectrum& spec, double tol, const FLASHHelperClasses::PrecalculatedAveragine& avg) const;
114
116 void setScanNumber(int scan_number);
117
119 void setChargeIsotopeCosine(int abs_charge, float cos);
120
122 void setAbsChargeRange(int min_abs_charge, int max_abs_charge);
123
125 void setIsotopeCosine(float cos);
126
128 void setRepAbsCharge(int max_snr_abs_charge);
129
131 void setMonoisotopicMass(double mono_mass);
132
134 void setQscore(double qscore);
135
137 void setChargeScore(float charge_score);
138
140 void setAvgPPMError(float error);
141
143 void setSNR(float snr);
144
146 void setChargeSNR(int abs_charge, float c_snr);
147
150
152 int getScanNumber() const;
153
155 double getMonoMass() const;
156
158 float getIntensity() const;
159
161 float getChargeSNR(int abs_charge) const;
162
164 float getChargeIsotopeCosine(int abs_charge) const;
165
167 float getChargeIntensity(int abs_charge) const;
168
170 std::tuple<double, double> getRepMzRange() const;
171
173 std::tuple<double, double> getMzRange(int abs_charge) const;
174
176 std::tuple<int, int> getAbsChargeRange() const;
177
179 const std::vector<float>& getIsotopeIntensities() const;
180
182 float getIsotopeCosine() const;
183
185
189 float getPeakOccupancy() const;
191 int getRepAbsCharge() const;
192
202 double getQscore() const;
203
215 double getQscore2D() const;
216
218 float getSNR() const;
219
221 float getChargeScore() const;
222
224 float getAvgPPMError() const;
225
227 float getAvgDaError() const;
228
230 bool isPositive() const;
231
233 bool isTargeted() const;
234
237
240
244 float getQvalue() const;
245
249 void setQvalue(double q);
250
252 void setIsotopeDaDistance(double d);
253
255 double getIsotopeDaDistance() const;
256
259
261 void setIndex(uint i);
262
271 void setQscore2D(double fqscore);
272
280 void setFeatureIndex(uint findex);
281
283 uint getIndex() const;
293 uint getFeatureIndex() const;
294
296 std::vector<FLASHHelperClasses::LogMzPeak>::const_iterator begin() const noexcept;
297 std::vector<FLASHHelperClasses::LogMzPeak>::const_iterator end() const noexcept;
298
299 std::vector<FLASHHelperClasses::LogMzPeak>::iterator begin() noexcept;
300 std::vector<FLASHHelperClasses::LogMzPeak>::iterator end() noexcept;
301
302 const FLASHHelperClasses::LogMzPeak& operator[](Size i) const;
303
315 std::vector<float> getMassErrors(bool ppm = true) const;
316
318 void push_back(const FLASHHelperClasses::LogMzPeak& pg);
320 Size size() const noexcept;
321
322 void reserve(Size n);
323 bool empty() const;
324 void swap(std::vector<FLASHHelperClasses::LogMzPeak>& x);
325 void sort();
326
337 std::tuple<std::vector<double>, std::vector<double>> getDLVector(const MSSpectrum& spec, const Size charge_count, const Size isotope_count,
338 const FLASHHelperClasses::PrecalculatedAveragine& avg, double tol);
339
340 private:
342 void updateChargeFitScoreAndChargeIntensities_(bool is_low_charge);
344 void updateAvgMassError_();
346 float getPPMError_(const LogMzPeak& p) const;
348 float getDaError_(const LogMzPeak& p) const;
350 void updateSNR_(float mul_factor);
352 void clear_();
354 void getPerIsotopeIntensities_(std::vector<float>& intensities, int& min_isotope_index, int& max_isotope_index, int abs_charge, int min_negative_isotope_index, double tol);
356 void updatePerChargeInformation_(const std::vector<LogMzPeak>& noisy_peaks, double tol, bool is_last);
358 void updateChargeRange_();
360 void updatePerChargeCos_(const FLASHHelperClasses::PrecalculatedAveragine& avg, double tol);
361
369 float getNoisePeakPower_(const std::vector<LogMzPeak>& noisy_peaks, int z, double tol) const;
370
372 std::vector<FLASHHelperClasses::LogMzPeak> logMzpeaks_;
374 std::vector<FLASHHelperClasses::LogMzPeak> negative_iso_peaks_;
376 std::vector<float> per_charge_sum_signal_squared_;
377 std::vector<float> per_charge_noise_pwr_;
378 std::vector<float> per_charge_cos_;
379 std::vector<float> per_charge_int_;
380 std::vector<float> per_charge_snr_;
382 std::vector<float> per_isotope_int_;
384 int min_abs_charge_ = 0, max_abs_charge_ = -1;
386 uint index_ = 0;
388 uint findex_ = 0;
390 int scan_number_ = 0;
392 bool is_positive_ = false;
394 bool is_targeted_ = false;
396 double monoisotopic_mass_ = -1.0;
398 float intensity_ = 0.f;
400 PeakGroup::TargetDecoyType target_decoy_type_ = target;
403 int min_negative_isotope_index_ = -1;
404
406 double iso_da_distance_ = Constants::ISOTOPE_MASSDIFF_55K_U;
409 int max_snr_abs_charge_ = -1;
411 float isotope_cosine_score_ = 0.f;
413 float charge_score_ = 0.f;
415 double qscore_ = .0;
417 double qscore2D_ = -1.0f;
418 float avg_ppm_error_ = 0.f;
419 float avg_da_error_ = 0.f;
421 float snr_ = 0.f;
423 float qvalue_ = 1.f;
424 };
425} // namespace OpenMS
426
427namespace std
428{
431 template<>
432 struct hash<OpenMS::PeakGroup>
433 {
434 std::size_t operator()(const OpenMS::PeakGroup& pg) const noexcept
435 {
436 std::size_t seed = OpenMS::hash_float(pg.getMonoMass());
437 OpenMS::hash_combine(seed, OpenMS::hash_float(pg.getIntensity()));
438 return seed;
439 }
440 };
441} // namespace std
log transformed peak. After deconvolution, all necessary information from deconvolution such as charg...
Definition FLASHHelperClasses.h:189
Averagine patterns pre-calculated for speed up. Other variables are also calculated for fast cosine c...
Definition FLASHHelperClasses.h:41
The representation of a 1D spectrum.
Definition MSSpectrum.h:44
Class describing a deconvolved mass. A mass contains multiple (LogMz) peaks of different charges and ...
Definition PeakGroup.h:29
std::vector< LogMzPeak > getNoisyPeaks(const MSSpectrum &spec, double tol, const FLASHHelperClasses::PrecalculatedAveragine &avg) const
Get noisy peaks for this PeakGroup without modifying any state (const-safe). This is a const alternat...
std::vector< FLASHHelperClasses::LogMzPeak >::const_iterator begin() const noexcept
iterators for the signal LogMz peaks in this PeakGroup
FLASHHelperClasses::PrecalculatedAveragine PrecalculatedAveragine
Definition PeakGroup.h:31
void setTargeted()
set if it is targeted
void setTargetDecoyType(PeakGroup::TargetDecoyType index)
for this PeakGroup, specify the target decoy type.
int getMinNegativeIsotopeIndex() const
get minimum neagative isotope index
void setIsotopeCosine(float cos)
set isotope cosine score
void setAvgPPMError(float error)
set average mass ppm error
bool isTargeted() const
get if it is targeted
float getChargeSNR(int abs_charge) const
get per abs_charge SNR
void setQvalue(double q)
uint getIndex() const
get index of this peak group
std::tuple< int, int > getAbsChargeRange() const
get charge range - the actual charge values
std::vector< LogMzPeak > recruitAllPeaksInSpectrum(const MSSpectrum &spec, double tol, const FLASHHelperClasses::PrecalculatedAveragine &avg, double mono_mass, bool renew_signal_peaks=true)
given a monoisotopic mass, recruit raw peaks from the raw input spectrum and add to this peakGroup....
float getIntensity() const
get intensity
float getAvgDaError() const
get average mass ppm error;
float getSNR() const
get total SNR
float getChargeIntensity(int abs_charge) const
get per abs_charge intenstiy
int getRepAbsCharge() const
get representative charge
bool operator<(const PeakGroup &a) const
comparison operators
void setSNR(float snr)
set SNR manually - for FLASHIda log file parsing
void setIsotopeDaDistance(double d)
set distance between consecutive isotopes
float getChargeIsotopeCosine(int abs_charge) const
get per abs_charge isotope cosine
void setChargeSNR(int abs_charge, float c_snr)
set charge SNR manually - for FLASHIda log file parsing
void setQscore2D(double fqscore)
Set the two-dimensional quality score for this peak group.
bool operator>(const PeakGroup &a) const
const std::vector< float > & getIsotopeIntensities() const
get per isotope intensities
float getChargeScore() const
get charge score
float getPeakOccupancy() const
get the density of the peaks within charge and isotope range
std::tuple< double, double > getRepMzRange() const
get mz range that results in max setQscore
float getQvalue() const
void setAbsChargeRange(int min_abs_charge, int max_abs_charge)
set min_abs_charge and max_abs_charge charge range
void setMonoisotopicMass(double mono_mass)
set monoisotopic mass
PeakGroup(int min_abs_charge, int max_abs_charge, bool is_positive)
Constructor specifying charge range.
int updateQscore(const std::vector< LogMzPeak > &noisy_peaks, const FLASHHelperClasses::PrecalculatedAveragine &avg, double min_cos, double tol, bool is_low_charge, const std::vector< double > &excluded_masses, bool is_last=false)
Update setQscore. Cosine and SNRs are also updated.
int getScanNumber() const
get scan number
PeakGroup()=default
default constructor
~PeakGroup()=default
default destructor
uint getFeatureIndex() const
Get the feature index associated with this peak group.
void setChargeIsotopeCosine(int abs_charge, float cos)
set per abs_charge isotope cosine
double getQscore() const
Get the one-dimensional quality score for this peak group.
PeakGroup(const PeakGroup &)=default
copy constructor
std::tuple< double, double > getMzRange(int abs_charge) const
get mz range of the charge
float getIsotopeCosine() const
get isotopic cosine score
FLASHHelperClasses::LogMzPeak LogMzPeak
Definition PeakGroup.h:30
PeakGroup & operator=(const PeakGroup &t)=default
assignment operator
void setFeatureIndex(uint findex)
Set the feature index for this peak group.
void setRepAbsCharge(int max_snr_abs_charge)
set representative max_snr_abs_charge
void setScanNumber(int scan_number)
set scan number
PeakGroup(PeakGroup &&other)=default
move constructor
void setIndex(uint i)
set index of this peak group
void setQscore(double qscore)
set Qscore - for FLASHIda log file parsing
double getIsotopeDaDistance() const
get distance between consecutive isotopes
void setChargeScore(float charge_score)
set charge score - for FLASHIda log file parsing
bool operator==(const PeakGroup &a) const
PeakGroup::TargetDecoyType getTargetDecoyType() const
get the target decoy type of this
double getMonoMass() const
get monoisotopic mass
bool isPositive() const
get if it is positive mode
void updateMonoMassAndIsotopeIntensities(double tol)
add monoisotopic indices of peaks by offset and discard negative isotope peaks. Total intensity is al...
TargetDecoyType
Definition PeakGroup.h:37
@ noise_decoy
Definition PeakGroup.h:39
@ signal_decoy
Definition PeakGroup.h:40
double getQscore2D() const
Get the two-dimensional quality score incorporating feature-level information.
float getAvgPPMError() const
get average mass ppm error;
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
void hash_combine(std::size_t &seed, std::size_t value) noexcept
Combine a hash value with additional data using golden ratio mixing.
Definition HashUtils.h:87
std::size_t hash_float(T value) noexcept
Hash for a floating point type (float or double).
Definition HashUtils.h:142
STL namespace.
Wrapper struct for all the structs needed by the FLASHDeconv The following structures/classes are def...
Definition FLASHHelperClasses.h:38
std::size_t operator()(const OpenMS::PeakGroup &pg) const noexcept
Definition PeakGroup.h:434