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:
34  {
35  target = 0,
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 
87  int updateQscore(const std::vector<LogMzPeak>& noisy_peaks, const FLASHHelperClasses::PrecalculatedAveragine& avg, double min_cos,
88  double tol, bool is_low_charge, const std::vector<double>& excluded_masses, bool is_last = false);
89 
100  std::vector<LogMzPeak> recruitAllPeaksInSpectrum(const MSSpectrum& spec, double tol, const FLASHHelperClasses::PrecalculatedAveragine& avg, double mono_mass, bool renew_signal_peaks = true);
101 
110  std::vector<LogMzPeak> getNoisyPeaks(const MSSpectrum& spec, double tol, const FLASHHelperClasses::PrecalculatedAveragine& avg) const;
111 
113  void setScanNumber(int scan_number);
114 
116  void setChargeIsotopeCosine(int abs_charge, float cos);
117 
119  void setAbsChargeRange(int min_abs_charge, int max_abs_charge);
120 
122  void setIsotopeCosine(float cos);
123 
125  void setRepAbsCharge(int max_snr_abs_charge);
126 
128  void setMonoisotopicMass(double mono_mass);
129 
131  void setQscore(double qscore);
132 
134  void setChargeScore(float charge_score);
135 
137  void setAvgPPMError(float error);
138 
140  void setSNR(float snr);
141 
143  void setChargeSNR(int abs_charge, float c_snr);
144 
146  void setTargeted();
147 
149  int getScanNumber() const;
150 
152  double getMonoMass() const;
153 
155  float getIntensity() const;
156 
158  float getChargeSNR(int abs_charge) const;
159 
161  float getChargeIsotopeCosine(int abs_charge) const;
162 
164  float getChargeIntensity(int abs_charge) const;
165 
167  std::tuple<double, double> getRepMzRange() const;
168 
170  std::tuple<double, double> getMzRange(int abs_charge) const;
171 
173  std::tuple<int, int> getAbsChargeRange() const;
174 
176  const std::vector<float>& getIsotopeIntensities() const;
177 
179  float getIsotopeCosine() const;
180 
182 
186  float getPeakOccupancy() const;
188  int getRepAbsCharge() const;
189 
199  double getQscore() const;
200 
212  double getQscore2D() const;
213 
215  float getSNR() const;
216 
218  float getChargeScore() const;
219 
221  float getAvgPPMError() const;
222 
224  float getAvgDaError() const;
225 
227  bool isPositive() const;
228 
230  bool isTargeted() const;
231 
234 
237 
241  float getQvalue() const;
242 
246  void setQvalue(double q);
247 
249  void setIsotopeDaDistance(double d);
250 
252  double getIsotopeDaDistance() const;
253 
256 
258  void setIndex(uint i);
259 
268  void setQscore2D(double fqscore);
269 
277  void setFeatureIndex(uint findex);
278 
280  uint getIndex() const;
290  uint getFeatureIndex() const;
291 
293  std::vector<FLASHHelperClasses::LogMzPeak>::const_iterator begin() const noexcept;
294  std::vector<FLASHHelperClasses::LogMzPeak>::const_iterator end() const noexcept;
295 
296  std::vector<FLASHHelperClasses::LogMzPeak>::iterator begin() noexcept;
297  std::vector<FLASHHelperClasses::LogMzPeak>::iterator end() noexcept;
298 
299  const FLASHHelperClasses::LogMzPeak& operator[](Size i) const;
300 
312  std::vector<float> getMassErrors(bool ppm = true) const;
313 
315  void push_back(const FLASHHelperClasses::LogMzPeak& pg);
317  Size size() const noexcept;
318 
319  void reserve(Size n);
320  bool empty() const;
321  void swap(std::vector<FLASHHelperClasses::LogMzPeak>& x);
322  void sort();
323 
334  std::tuple<std::vector<double>, std::vector<double>> getDLVector(const MSSpectrum& spec, const Size charge_count, const Size isotope_count,
335  const FLASHHelperClasses::PrecalculatedAveragine& avg, double tol);
336 
337  private:
339  void updateChargeFitScoreAndChargeIntensities_(bool is_low_charge);
341  void updateAvgMassError_();
343  float getPPMError_(const LogMzPeak& p) const;
345  float getDaError_(const LogMzPeak& p) const;
347  void updateSNR_(float mul_factor);
349  void clear_();
351  void getPerIsotopeIntensities_(std::vector<float>& intensities, int& min_isotope_index, int& max_isotope_index, int abs_charge, int min_negative_isotope_index, double tol);
353  void updatePerChargeInformation_(const std::vector<LogMzPeak>& noisy_peaks, double tol, bool is_last);
355  void updateChargeRange_();
357  void updatePerChargeCos_(const FLASHHelperClasses::PrecalculatedAveragine& avg, double tol);
358 
366  float getNoisePeakPower_(const std::vector<LogMzPeak>& noisy_peaks, int z, double tol) const;
367 
369  std::vector<FLASHHelperClasses::LogMzPeak> logMzpeaks_;
371  std::vector<FLASHHelperClasses::LogMzPeak> negative_iso_peaks_;
373  std::vector<float> per_charge_sum_signal_squared_;
374  std::vector<float> per_charge_noise_pwr_;
375  std::vector<float> per_charge_cos_;
376  std::vector<float> per_charge_int_;
377  std::vector<float> per_charge_snr_;
379  std::vector<float> per_isotope_int_;
381  int min_abs_charge_ = 0, max_abs_charge_ = -1;
383  uint index_ = 0;
385  uint findex_ = 0;
387  int scan_number_ = 0;
389  bool is_positive_ = false;
391  bool is_targeted_ = false;
393  double monoisotopic_mass_ = -1.0;
395  float intensity_ = 0.f;
397  PeakGroup::TargetDecoyType target_decoy_type_ = target;
400  int min_negative_isotope_index_ = -1;
401 
403  double iso_da_distance_ = Constants::ISOTOPE_MASSDIFF_55K_U;
406  int max_snr_abs_charge_ = -1;
408  float isotope_cosine_score_ = 0.f;
410  float charge_score_ = 0.f;
412  double qscore_ = .0;
414  double qscore2D_ = -1.0f;
415  float avg_ppm_error_ = 0.f;
416  float avg_da_error_ = 0.f;
418  float snr_ = 0.f;
420  float qvalue_ = 1.f;
421  };
422 } // namespace OpenMS
log transformed peak. After deconvolution, all necessary information from deconvolution such as charg...
Definition: FLASHHelperClasses.h:187
Averagine patterns pre-calculated for speed up. Other variables are also calculated for fast cosine c...
Definition: FLASHHelperClasses.h:39
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
FLASHHelperClasses::PrecalculatedAveragine PrecalculatedAveragine
Definition: PeakGroup.h:28
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
std::tuple< double, double > getMzRange(int abs_charge) const
get mz range of the charge
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...
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
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
float getChargeScore() const
get charge score
float getPeakOccupancy() const
get the density of the peaks within charge and isotope range
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
std::tuple< int, int > getAbsChargeRange() const
get charge range - the actual charge values
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
float getIsotopeCosine() const
get isotopic cosine score
FLASHHelperClasses::LogMzPeak LogMzPeak
Definition: PeakGroup.h:27
void setFeatureIndex(uint findex)
Set the feature index for this peak group.
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
std::vector< FLASHHelperClasses::LogMzPeak >::const_iterator begin() const noexcept
iterators for the signal LogMz peaks in this PeakGroup
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
const std::vector< float > & getIsotopeIntensities() const
get per isotope intensities
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
std::tuple< double, double > getRepMzRange() const
get mz range that results in max setQscore
void updateMonoMassAndIsotopeIntensities(double tol)
add monoisotopic indices of peaks by offset and discard negative isotope peaks. Total intensity is al...
TargetDecoyType
Definition: PeakGroup.h:34
@ noise_decoy
Definition: PeakGroup.h:36
@ signal_decoy
Definition: PeakGroup.h:37
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....
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
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 The following structures/classes are def...
Definition: FLASHHelperClasses.h:36