OpenMS
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 
13 
14 namespace OpenMS
15 {
25  class OPENMS_DLLAPI PeakGroup
26  {
29 
30  public:
33  {
34  target = 0,
37  isotope_dummy
38  };
39 
40 
42  PeakGroup() = default;
43 
50  explicit PeakGroup(int min_abs_charge, int max_abs_charge, bool is_positive);
51 
53  ~PeakGroup() = default;
54 
56  PeakGroup(const PeakGroup&) = default;
57 
59  PeakGroup(PeakGroup&& other) = default;
60 
62  bool operator<(const PeakGroup& a) const;
63 
64  bool operator>(const PeakGroup& a) const;
65 
66  bool operator==(const PeakGroup& a) const;
67 
69  PeakGroup& operator=(const PeakGroup& t) = default;
70 
75 
84  int updateQscore(std::vector<LogMzPeak>& noisy_peaks, const FLASHDeconvHelperStructs::PrecalculatedAveragine& avg, double min_cos, int allowed_iso_error = 1);
85 
96  std::vector<LogMzPeak> recruitAllPeaksInSpectrum(const MSSpectrum& spec, double tol, const FLASHDeconvHelperStructs::PrecalculatedAveragine& avg, double mono_mass,
97  const std::unordered_set<double>& excluded_peak_mzs);
98 
100  bool isSignalMZ(double mz, double tol) const;
101 
103  void setScanNumber(int scan_number);
104 
106  void setChargeIsotopeCosine(int abs_charge, float cos);
107 
109  void setAbsChargeRange(int min_abs_charge, int max_abs_charge);
110 
112  void setIsotopeCosine(float cos);
113 
115  void setRepAbsCharge(int max_snr_abs_charge);
116 
118  void setMonoisotopicMass(double mono_mass);
119 
121  void Qscore(float qscore);
122 
124  void setChargeScore(float charge_score);
125 
127  void setAvgPPMError(float error);
128 
130  void setSNR(float snr);
131 
133  void setChargeSNR(int abs_charge, float c_snr);
134 
136  void setTargeted();
137 
139  int getScanNumber() const;
140 
142  double getMonoMass() const;
143 
145  float getIntensity() const;
146 
148  float getChargeSNR(int abs_charge) const;
149 
151  float getChargeIsotopeCosine(int abs_charge) const;
152 
154  float getChargeIntensity(int abs_charge) const;
155 
157  std::tuple<double, double> getRepMzRange() const;
158 
160  std::tuple<double, double> getMzRange(int abs_charge) const;
161 
163  std::tuple<int, int> getAbsChargeRange() const;
164 
166  const std::vector<float>& getIsotopeIntensities() const;
167 
169  float getIsotopeCosine() const;
170 
172  int getRepAbsCharge() const;
173 
175  float getQscore() const;
176 
178  float getSNR() const;
179 
181  float getChargeScore() const;
182 
184  float getAvgPPMError() const;
185 
187  float getAvgDaError() const;
188 
190  bool isPositive() const;
191 
193  bool isTargeted() const;
194 
197 
200 
207  float getQvalue(PeakGroup::TargetDummyType target_dummy_type = PeakGroup::TargetDummyType::target) const;
208 
214  void setQvalue(float q, PeakGroup::TargetDummyType target_dummy_type);
215 
217  void setIsotopeDaDistance(double d);
218 
220  double getIsotopeDaDistance() const;
221 
225  void setIndex(uint i);
226 
228  uint getIndex() const;
229 
231  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::const_iterator begin() const noexcept;
232  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::const_iterator end() const noexcept;
233 
234  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::iterator begin() noexcept;
235  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::iterator end() noexcept;
236 
237  const FLASHDeconvHelperStructs::LogMzPeak& operator[](Size i) const;
238 
240  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::const_iterator getNoisePeakBegin() const noexcept;
241  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::const_iterator getNoisePeakEnd() const noexcept;
242 
243  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::iterator getNoisePeakBegin() noexcept;
244  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::iterator getNoisePeakEnd() noexcept;
245 
247  void push_back(const FLASHDeconvHelperStructs::LogMzPeak& pg);
248  Size size() const noexcept;
249 
250  void reserve(Size n);
251  bool empty() const;
252  void swap(std::vector<FLASHDeconvHelperStructs::LogMzPeak>& x);
253  void sort();
254 
255  private:
257  void updateChargeFitScoreAndChargeIntensities_();
259  void updateAvgPPMError_();
261  void updateAvgDaError_();
263  float getAbsPPMError_(const LogMzPeak& p) const;
265  float getAbsDaError_(LogMzPeak& p) const;
267  void updateSNR_();
269  void clear_();
271  void updatePerChargeInformation_(const std::vector<LogMzPeak>& noisy_peaks);
273  void updateChargeRange_(std::vector<LogMzPeak>& noisy_peaks);
275  void updatePerChargeCos_(const FLASHDeconvHelperStructs::PrecalculatedAveragine& avg);
276 
283  float getNoisePeakPower_(const std::vector<LogMzPeak>& noisy_peaks, const std::vector<LogMzPeak>& signal_peaks) const;
284 
286  std::vector<FLASHDeconvHelperStructs::LogMzPeak> logMzpeaks_;
288  std::vector<FLASHDeconvHelperStructs::LogMzPeak> negative_iso_peaks_;
290  std::vector<float> per_charge_sum_signal_squared_;
291  std::vector<float> per_charge_noise_pwr_;
292  std::vector<float> per_charge_cos_;
293  std::vector<float> per_charge_int_;
294  std::vector<float> per_charge_snr_;
296  std::vector<float> per_isotope_int_;
298  int min_abs_charge_ = 0, max_abs_charge_ = -1;
300  uint index_ = 0;
302  int scan_number_ = 0;
304  bool is_positive_ = false;
306  bool is_targeted_ = false;
308  double monoisotopic_mass_ = -1.0;
309  float intensity_ = 0; // total intensity
311  PeakGroup::TargetDummyType target_dummy_type_ = target;
313  int min_negative_isotope_index_ = -1;
315  double iso_da_distance_ = Constants::ISOTOPE_MASSDIFF_55K_U;
317  int max_snr_abs_charge_ = -1;
318  float isotope_cosine_score_ = 0;
319  float charge_score_ = 0;
320  float qscore_ = .0f;
321  float avg_ppm_error_ = 0;
322  float avg_da_error_ = 0;
323  float snr_ = 0;
325  std::map<PeakGroup::TargetDummyType, float> qvalue_;
326  };
327 } // namespace OpenMS
log transformed peak. After deconvolution, all necessary information from deconvolution such as charg...
Definition: FLASHDeconvHelperStructs.h:139
Averagine patterns pre-calculated for speed up. Other variables are also calculated for fast cosine c...
Definition: FLASHDeconvHelperStructs.h:34
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:26
void setTargeted()
set if it is targeted
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
std::tuple< double, double > getMzRange(int abs_charge) const
get mz range of the charge
void setTargetDummyType(PeakGroup::TargetDummyType index)
for this PeakGroup, specify the target dummy type.
FLASHDeconvHelperStructs::LogMzPeak LogMzPeak
Definition: PeakGroup.h:27
bool isTargeted() const
get if it is targeted
float getChargeSNR(int abs_charge) const
get per abs_charge SNR
uint getIndex() const
get index of this peak group
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
float getQvalue(PeakGroup::TargetDummyType target_dummy_type=PeakGroup::TargetDummyType::target) const
bool operator<(const PeakGroup &a) const
comparison operators
void setSNR(float snr)
set SNR manually - for FLASHIda log file parsing
PeakGroup::TargetDummyType getTargetDummyType() const
get the target dummy type of this
void setIsotopeDaDistance(double d)
set distance between consecutive isotopes
float getChargeIsotopeCosine(int abs_charge) const
get per abs_charge isotope cosine
float getQscore() const
get Q score
void setChargeSNR(int abs_charge, float c_snr)
set charge SNR manually - for FLASHIda log file parsing
bool operator>(const PeakGroup &a) const
float getChargeScore() const
get charge score
void Qscore(float qscore)
set Q score - for FLASHIda log file parsing
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 getScanNumber() const
get scan number
PeakGroup()=default
default constructor
~PeakGroup()=default
default destructor
std::tuple< int, int > getAbsChargeRange() const
get charge range - the actual charge values
void setChargeIsotopeCosine(int abs_charge, float cos)
set per abs_charge isotope cosine
PeakGroup(const PeakGroup &)=default
copy constructor
std::vector< FLASHDeconvHelperStructs::LogMzPeak >::const_iterator begin() const noexcept
iterators for the signal LogMz peaks in this PeakGroup
float getIsotopeCosine() const
get isotopic cosine score
PeakGroup & operator=(const PeakGroup &t)=default
assignment operator
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 setQvalue(float q, PeakGroup::TargetDummyType target_dummy_type)
void setIndex(uint i)
set index of this peak group
TargetDummyType
target dummy type of PeakGroup. This specifies if a PeakGroup is a target (0), charge dummy (1),...
Definition: PeakGroup.h:33
@ charge_dummy
Definition: PeakGroup.h:35
@ noise_dummy
Definition: PeakGroup.h:36
double getIsotopeDaDistance() const
get distance between consecutive isotopes
void setChargeScore(float charge_score)
set charge score - for FLASHIda log file parsing
const std::vector< float > & getIsotopeIntensities() const
get per isotope intensities
std::vector< LogMzPeak > recruitAllPeaksInSpectrum(const MSSpectrum &spec, double tol, const FLASHDeconvHelperStructs::PrecalculatedAveragine &avg, double mono_mass, const std::unordered_set< double > &excluded_peak_mzs)
given a monoisotopic mass, recruit raw peaks from the raw input spectrum and add to this peakGroup....
bool operator==(const PeakGroup &a) const
bool isSignalMZ(double mz, double tol) const
determine is an mz is a signal of this peakgroup. Input tol is ppm tolerance (e.g....
void updateMonoMassAndIsotopeIntensities()
add monoisotopic indices of peaks by offset and discard negative isotope peaks. Total intensity is al...
double getMonoMass() const
get monoisotopic mass
bool isPositive() const
get if it is positive mode
std::tuple< double, double > getRepMzRange() const
get mz range that results in max Qscore
FLASHDeconvHelperStructs::PrecalculatedAveragine PrecalculatedAveragine
Definition: PeakGroup.h:28
int updateQscore(std::vector< LogMzPeak > &noisy_peaks, const FLASHDeconvHelperStructs::PrecalculatedAveragine &avg, double min_cos, int allowed_iso_error=1)
Update Qscore. Cosine and SNRs are also updated.
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
const double ISOTOPE_MASSDIFF_55K_U
Definition: Constants.h:100
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Wrapper struct for all the structs needed by the FLASHDeconv Three structures are defined: Precalcula...
Definition: FLASHDeconvHelperStructs.h:31