OpenMS
PeakGroup.h
Go to the documentation of this file.
1 //--------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2023.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Kyowon Jeong, Jihyung Kim $
32 // $Authors: Kyowon Jeong, Jihyung Kim $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
39 
40 namespace OpenMS
41 {
51  class OPENMS_DLLAPI PeakGroup
52  {
55 
56  public:
59  {
60  target = 0,
63  isotope_dummy
64  };
65 
66 
68  PeakGroup() = default;
69 
76  explicit PeakGroup(int min_abs_charge, int max_abs_charge, bool is_positive);
77 
79  ~PeakGroup() = default;
80 
82  PeakGroup(const PeakGroup&) = default;
83 
85  PeakGroup(PeakGroup&& other) = default;
86 
88  bool operator<(const PeakGroup& a) const;
89 
90  bool operator>(const PeakGroup& a) const;
91 
92  bool operator==(const PeakGroup& a) const;
93 
95  PeakGroup& operator=(const PeakGroup& t) = default;
96 
101 
110  int updateQscore(std::vector<LogMzPeak>& noisy_peaks, const FLASHDeconvHelperStructs::PrecalculatedAveragine& avg, double min_cos, int allowed_iso_error = 1);
111 
122  std::vector<LogMzPeak> recruitAllPeaksInSpectrum(const MSSpectrum& spec, double tol, const FLASHDeconvHelperStructs::PrecalculatedAveragine& avg, double mono_mass,
123  const std::unordered_set<double>& excluded_peak_mzs);
124 
126  bool isSignalMZ(double mz, double tol) const;
127 
129  void setScanNumber(int scan_number);
130 
132  void setChargeIsotopeCosine(int abs_charge, float cos);
133 
135  void setAbsChargeRange(int min_abs_charge, int max_abs_charge);
136 
138  void setIsotopeCosine(float cos);
139 
141  void setRepAbsCharge(int max_snr_abs_charge);
142 
144  void setMonoisotopicMass(double mono_mass);
145 
147  void Qscore(float qscore);
148 
150  void setChargeScore(float charge_score);
151 
153  void setAvgPPMError(float error);
154 
156  void setSNR(float snr);
157 
159  void setChargeSNR(int abs_charge, float c_snr);
160 
162  void setTargeted();
163 
165  int getScanNumber() const;
166 
168  double getMonoMass() const;
169 
171  float getIntensity() const;
172 
174  float getChargeSNR(int abs_charge) const;
175 
177  float getChargeIsotopeCosine(int abs_charge) const;
178 
180  float getChargeIntensity(int abs_charge) const;
181 
183  std::tuple<double, double> getRepMzRange() const;
184 
186  std::tuple<double, double> getMzRange(int abs_charge) const;
187 
189  std::tuple<int, int> getAbsChargeRange() const;
190 
192  const std::vector<float>& getIsotopeIntensities() const;
193 
195  float getIsotopeCosine() const;
196 
198  int getRepAbsCharge() const;
199 
201  float getQscore() const;
202 
204  float getSNR() const;
205 
207  float getChargeScore() const;
208 
210  float getAvgPPMError() const;
211 
213  float getAvgDaError() const;
214 
216  bool isPositive() const;
217 
219  bool isTargeted() const;
220 
223 
226 
233  float getQvalue(PeakGroup::TargetDummyType target_dummy_type = PeakGroup::TargetDummyType::target) const;
234 
239  void setQvalue(float q, PeakGroup::TargetDummyType target_dummy_type);
240 
242  void setIsotopeDaDistance(double d);
243 
245  double getIsotopeDaDistance() const;
246 
250  void setIndex(uint i);
251 
253  uint getIndex() const;
254 
256  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::const_iterator begin() const noexcept;
257  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::const_iterator end() const noexcept;
258 
259  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::iterator begin() noexcept;
260  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::iterator end() noexcept;
261 
262  const FLASHDeconvHelperStructs::LogMzPeak& operator[](Size i) const;
263 
265  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::const_iterator getNoisePeakBegin() const noexcept;
266  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::const_iterator getNoisePeakEnd() const noexcept;
267 
268  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::iterator getNoisePeakBegin() noexcept;
269  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::iterator getNoisePeakEnd() noexcept;
270 
272  void push_back(const FLASHDeconvHelperStructs::LogMzPeak& pg);
273  Size size() const noexcept;
274 
275  void reserve(Size n);
276  bool empty() const;
277  void swap(std::vector<FLASHDeconvHelperStructs::LogMzPeak>& x);
278  void sort();
279 
280  private:
282  void updateChargeFitScoreAndChargeIntensities_();
284  void updateAvgPPMError_();
286  void updateAvgDaError_();
288  float getAbsPPMError_(const LogMzPeak& p) const;
290  float getAbsDaError_(LogMzPeak& p) const;
292  void updateSNR_();
294  void clear_();
296  void updatePerChargeInformation_(const std::vector<LogMzPeak>& noisy_peaks);
298  void updateChargeRange_(std::vector<LogMzPeak>& noisy_peaks);
300  void updatePerChargeCos_(const FLASHDeconvHelperStructs::PrecalculatedAveragine& avg);
301 
308  float getNoisePeakPower_(const std::vector<LogMzPeak>& noisy_peaks, const std::vector<LogMzPeak>& signal_peaks) const;
309 
311  std::vector<FLASHDeconvHelperStructs::LogMzPeak> logMzpeaks_;
313  std::vector<FLASHDeconvHelperStructs::LogMzPeak> negative_iso_peaks_;
315  std::vector<float> per_charge_sum_signal_squared_;
316  std::vector<float> per_charge_noise_pwr_;
317  std::vector<float> per_charge_cos_;
318  std::vector<float> per_charge_int_;
319  std::vector<float> per_charge_snr_;
321  std::vector<float> per_isotope_int_;
323  int min_abs_charge_ = 0, max_abs_charge_ = -1;
325  uint index_ = 0;
327  int scan_number_ = 0;
329  bool is_positive_;
331  bool is_targeted_ = false;
333  double monoisotopic_mass_ = -1.0;
334  float intensity_ = 0; // total intensity
336  PeakGroup::TargetDummyType target_dummy_type_ = target;
338  int min_negative_isotope_index_ = -1;
340  double iso_da_distance_ = Constants::ISOTOPE_MASSDIFF_55K_U;
342  int max_snr_abs_charge_ = -1;
343  float isotope_cosine_score_ = 0;
344  float charge_score_ = 0;
345  float qscore_ = .0f;
346  float avg_ppm_error_ = 0;
347  float avg_da_error_ = 0;
348  float snr_ = 0;
350  std::map<PeakGroup::TargetDummyType, float> qvalue_;
351  };
352 } // namespace OpenMS
log transformed peak. After deconvolution, all necessary information from deconvolution such as charg...
Definition: FLASHDeconvHelperStructs.h:165
Averagine patterns pre-calculated for speed up. Other variables are also calculated for fast cosine c...
Definition: FLASHDeconvHelperStructs.h:60
The representation of a 1D spectrum.
Definition: MSSpectrum.h:70
Class describing a deconvolved mass. A mass contains multiple (LogMz) peaks of different charges and ...
Definition: PeakGroup.h:52
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:53
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:59
@ charge_dummy
Definition: PeakGroup.h:61
@ noise_dummy
Definition: PeakGroup.h:62
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:54
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:127
const double ISOTOPE_MASSDIFF_55K_U
Definition: Constants.h:126
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48
Wrapper struct for all the structs needed by the FLASHDeconv Three structures are defined: Precalcula...
Definition: FLASHDeconvHelperStructs.h:57