OpenMS
PeakGroup.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- 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,
38  non_specific
39  };
40 
41 
43  PeakGroup() = default;
44 
51  explicit PeakGroup(int min_abs_charge, int max_abs_charge, bool is_positive);
52 
54  ~PeakGroup() = default;
55 
57  PeakGroup(const PeakGroup&) = default;
58 
60  PeakGroup(PeakGroup&& other) = default;
61 
63  bool operator<(const PeakGroup& a) const;
64 
65  bool operator>(const PeakGroup& a) const;
66 
67  bool operator==(const PeakGroup& a) const;
68 
70  PeakGroup& operator=(const PeakGroup& t) = default;
71 
76 
89  int updateQscore(const std::vector<LogMzPeak>& noisy_peaks, const MSSpectrum& spec, const FLASHHelperClasses::PrecalculatedAveragine& avg, double min_cos, double tol, bool is_low_charge, int allowed_iso_error, const bool is_last = false);
90 
101  std::vector<LogMzPeak> recruitAllPeaksInSpectrum(const MSSpectrum& spec, double tol, const FLASHHelperClasses::PrecalculatedAveragine& avg, double mono_mass, bool renew_signal_peaks = true);
102 
104  bool isSignalMZ(double mz, double tol) const;
105 
107  void setScanNumber(int scan_number);
108 
110  void setChargeIsotopeCosine(int abs_charge, float cos);
111 
113  void setAbsChargeRange(int min_abs_charge, int max_abs_charge);
114 
116  void setIsotopeCosine(float cos);
117 
119  void setRepAbsCharge(int max_snr_abs_charge);
120 
122  void setMonoisotopicMass(double mono_mass);
123 
125  void setQscore(double qscore);
126 
128  void setChargeScore(float charge_score);
129 
131  void setAvgPPMError(float error);
132 
134  void setSNR(float snr);
135 
137  void setChargeSNR(int abs_charge, float c_snr);
138 
140  void setTargeted();
141 
143  int getScanNumber() const;
144 
146  double getMonoMass() const;
147 
149  float getIntensity() const;
150 
152  float getChargeSNR(int abs_charge) const;
153 
155  float getChargeIsotopeCosine(int abs_charge) const;
156 
158  float getChargeIntensity(int abs_charge) const;
159 
161  std::tuple<double, double> getRepMzRange() const;
162 
164  std::tuple<double, double> getMzRange(int abs_charge) const;
165 
167  std::tuple<int, int> getAbsChargeRange() const;
168 
170  const std::vector<float>& getIsotopeIntensities() const;
171 
173  float getIsotopeCosine() const;
174 
176  float getPeakOccupancy() const;
177 
179  int getRepAbsCharge() const;
180 
182  double getQscore() const;
183 
185  double getQscore2D() const;
186 
188  float getSNR() const;
189 
191  float getChargeScore() const;
192 
194  float getAvgPPMError() const;
195 
197  float getAvgDaError() const;
198 
200  bool isPositive() const;
201 
203  bool isTargeted() const;
204 
207 
210 
214  float getQvalue() const;
215 
219  void setQvalue(double q);
220 
222  void setIsotopeDaDistance(double d);
223 
225  double getIsotopeDaDistance() const;
226 
229 
231  void setIndex(uint i);
232 
234  void setQscore2D(double fqscore);
235 
237  void setFeatureIndex(uint findex);
238 
240  uint getIndex() const;
242  int getFeatureIndex() const;
243 
245  std::vector<FLASHHelperClasses::LogMzPeak>::const_iterator begin() const noexcept;
246  std::vector<FLASHHelperClasses::LogMzPeak>::const_iterator end() const noexcept;
247 
248  std::vector<FLASHHelperClasses::LogMzPeak>::iterator begin() noexcept;
249  std::vector<FLASHHelperClasses::LogMzPeak>::iterator end() noexcept;
250 
251  const FLASHHelperClasses::LogMzPeak& operator[](Size i) const;
252 
254  std::vector<FLASHHelperClasses::LogMzPeak>::const_iterator getNoisePeakBegin() const noexcept;
255  std::vector<FLASHHelperClasses::LogMzPeak>::const_iterator getNoisePeakEnd() const noexcept;
256 
257  std::vector<FLASHHelperClasses::LogMzPeak>::iterator getNoisePeakBegin() noexcept;
258  std::vector<FLASHHelperClasses::LogMzPeak>::iterator getNoisePeakEnd() noexcept;
259 
260  std::vector<float> getMassErrors(bool ppm = true) const;
261 
263  void push_back(const FLASHHelperClasses::LogMzPeak& pg);
265  Size size() const noexcept;
266 
267  void reserve(Size n);
268  bool empty() const;
269  void swap(std::vector<FLASHHelperClasses::LogMzPeak>& x);
270  void sort();
271 
272  std::tuple<std::vector<double>, std::vector<double>> getDLVector(const MSSpectrum& spec, const Size charge_count, const Size isotope_count, const FLASHHelperClasses::PrecalculatedAveragine& avg, double tol);
273 
274  private:
276  void updateChargeFitScoreAndChargeIntensities_(bool is_low_charge);
278  void updateAvgMassError_();
280  float getPPMError_(const LogMzPeak& p) const;
282  float getDaError_(const LogMzPeak& p) const;
284  void updateSNR_(float mul_factor);
286  void clear_();
288  void getPerIsotopeIntensities_(std::vector<float>& intensities, int& min_isotope_index, int& max_isotope_index, int abs_charge, int min_negative_isotope_index, double tol);
290  void updatePerChargeInformation_(const std::vector<LogMzPeak>& noisy_peaks, const double tol, const bool is_last);
292  void updateChargeRange_();
294  void updatePerChargeCos_(const FLASHHelperClasses::PrecalculatedAveragine& avg, double tol);
295 
303  float getNoisePeakPower_(const std::vector<LogMzPeak>& noisy_peaks, const int z, const double tol) const;
304 
306  std::vector<FLASHHelperClasses::LogMzPeak> logMzpeaks_;
308  std::vector<FLASHHelperClasses::LogMzPeak> negative_iso_peaks_;
310  std::vector<float> per_charge_sum_signal_squared_;
311  std::vector<float> per_charge_noise_pwr_;
312  std::vector<float> per_charge_cos_;
313  std::vector<float> per_charge_int_;
314  std::vector<float> per_charge_snr_;
316  std::vector<float> per_isotope_int_;
318  int min_abs_charge_ = 0, max_abs_charge_ = -1;
320  uint index_ = 0;
322  uint findex_ = 0;
324  int scan_number_ = 0;
326  bool is_positive_ = false;
328  bool is_targeted_ = false;
330  double monoisotopic_mass_ = -1.0;
331  float intensity_ = 0.f; // total intensity
333  PeakGroup::TargetDecoyType target_decoy_type_ = target;
335  int min_negative_isotope_index_ = -1;
336 
338  double iso_da_distance_ = Constants::ISOTOPE_MASSDIFF_55K_U;
340  int max_snr_abs_charge_ = -1;
341  float isotope_cosine_score_ = 0.f;
342  float charge_score_ = 0.f;
343  double qscore_ = .0;
344  double qscore2D_ = -1.0f;
345  float avg_ppm_error_ = 0.f;
346  float avg_da_error_ = 0.f;
347  float snr_ = 0.f;
349  float qvalue_ = 1.f;
350  };
351 } // namespace OpenMS
log transformed peak. After deconvolution, all necessary information from deconvolution such as charg...
Definition: FLASHHelperClasses.h:177
Averagine patterns pre-calculated for speed up. Other variables are also calculated for fast cosine c...
Definition: FLASHHelperClasses.h:35
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
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
int getFeatureIndex() const
get feature 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 Q score 2D
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
int updateQscore(const std::vector< LogMzPeak > &noisy_peaks, const MSSpectrum &spec, const FLASHHelperClasses::PrecalculatedAveragine &avg, double min_cos, double tol, bool is_low_charge, int allowed_iso_error, const bool is_last=false)
Update setQscore. Cosine and SNRs are also updated.
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
double getQscore() const
get Q score
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 feature index
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 Q score - 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
bool isSignalMZ(double mz, double tol) const
determine is an mz is a signal of this peakgroup. Input tol is ppm tolerance (e.g....
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
target decoy type of PeakGroup. This specifies if a PeakGroup is a target (0), charge decoy (1),...
Definition: PeakGroup.h:33
@ charge_decoy
Definition: PeakGroup.h:35
@ noise_decoy
Definition: PeakGroup.h:36
@ isotope_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 feature Q score
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
FLASHIda C++ to C# (or vice versa) bridge functions The functions here are called in C# to invoke fun...
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
static FLASHHelperClasses::PrecalculatedAveragine avg
keeps the precalculated averagine to calculate average masses from monoisotopic masses
Definition: FLASHIdaBridgeFunctions.h:92
Wrapper struct for all the structs needed by the FLASHDeconv Three structures are defined: Precalcula...
Definition: FLASHHelperClasses.h:32