OpenMS  3.0.0
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-2022.
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  public:
56 
58  enum DecoyFlag
59  {
60  target = 0,
63  isotope_decoy
64  };
65 
67  PeakGroup() = default;
68 
75  explicit PeakGroup(int min_abs_charge, int max_abs_charge, bool is_positive);
76 
78  ~PeakGroup() = default;
79 
81  PeakGroup(const PeakGroup& ) = default;
82 
84  PeakGroup(PeakGroup&& other) = default;
85 
87  bool operator<(const PeakGroup& a) const;
88 
89  bool operator>(const PeakGroup& a) const;
90 
91  bool operator==(const PeakGroup& a) const;
92 
94  PeakGroup& operator=(const PeakGroup& t) = default;
95 
99  void updateMonomassAndIsotopeIntensities();
100 
106  void updateIsotopeCosineSNRAvgErrorAndQScore(const FLASHDeconvHelperStructs::PrecalculatedAveragine& avg, double min_cos);
107 
120  std::vector<LogMzPeak> recruitAllPeaksInSpectrum(const MSSpectrum& spec, double tol, const FLASHDeconvHelperStructs::PrecalculatedAveragine& avg, double mono_mass, const std::unordered_set<int>& excluded_integer_mzs_, int charge_offset = 0, double charge_multiple = 1.0, double mz_off = .0);
121 
123  bool isSignalMZ(double mz, double tol) const;
124 
126  void setScanNumber(int scan_number);
127 
129  void setChargeIsotopeCosine(int abs_charge, float cos);
130 
132  void setAbsChargeRange(int min_abs_charge, int max_abs_charge);
133 
135  void setIsotopeCosine(float cos);
136 
138  void setRepAbsCharge(int max_qscore_charge);
139 
141  void setQScore(float qscore);
142 
144  void setChargeScore(float charge_score);
145 
147  void setAvgPPMError(float error);
148 
150  void setSNR(float snr);
151 
153  void setChargeSNR(int abs_charge, float c_snr);
154 
156  void setTargeted();
157 
159  int getScanNumber() const;
160 
162  double getMonoMass() const;
163 
165  float getIntensity() const;
166 
168  float getChargeSNR(int abs_charge) const;
169 
171  float getChargeIsotopeCosine(int abs_charge) const;
172 
174  float getChargeIntensity(int abs_charge) const;
175 
177  std::tuple<double, double> getRepMzRange() const;
178 
180  std::tuple<double, double> getMzRange(int abs_charge) const;
181 
183  std::tuple<int, int> getAbsChargeRange() const;
184 
186  const std::vector<float>& getIsotopeIntensities() const;
187 
189  float getIsotopeCosine() const;
190 
192  int getRepAbsCharge() const;
193 
195  float getQScore() const;
196 
198  float getSNR() const;
199 
201  float getChargeScore() const;
202 
204  float getAvgPPMError() const;
205 
207  float getAvgDaError() const;
208 
210  bool isPositive() const;
211 
213  bool isTargeted() const;
214 
216  PeakGroup::DecoyFlag getDecoyFlag() const;
217 
219  void setDecoyFlag(PeakGroup::DecoyFlag index);
220 
222  float getQvalue(PeakGroup::DecoyFlag flag = PeakGroup::DecoyFlag::target) const;
223 
225  void setQvalue(float q, PeakGroup::DecoyFlag flag);
226 
228  void setIsotopeDaDistance(double d);
229 
231  double getIsotopeDaDistance() const;
232 
234  void setIndex(uint i);
235 
237  uint getIndex() const;
238 
240  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::const_iterator begin() const noexcept;
241  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::const_iterator end() const noexcept;
242 
243  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::iterator begin() noexcept;
244  std::vector<FLASHDeconvHelperStructs::LogMzPeak>::iterator end() noexcept;
245 
246  const FLASHDeconvHelperStructs::LogMzPeak& operator[](Size i) const;
247 
249  void push_back (const FLASHDeconvHelperStructs::LogMzPeak& pg);
250  Size size() const noexcept;
251  void clear();
252  void reserve (Size n);
253  bool empty() const;
254  void swap (std::vector<FLASHDeconvHelperStructs::LogMzPeak>& x);
255  void shrink_to_fit();
256  void sort();
257 
258  private:
260  void setChargePowers_(int abs_charge, float signal_pwr, float noise_pwr, float intensity);
262  void updateChargeFitScoreAndChargeIntensities_();
264  void updateAvgPPMError_();
266  void updateAvgDaError_();
268  float getAbsPPMError_(const LogMzPeak& p) const;
270  float getAbsDaError_(LogMzPeak& p) const;
272  void updateSNR_();
273 
275  std::vector<Matrix<float>> dl_matrices_;
276 
278  std::vector<FLASHDeconvHelperStructs::LogMzPeak> logMzpeaks_;
279 
281  std::vector<float> per_charge_signal_pwr_;
282  std::vector<float> per_charge_noise_pwr_;
283  std::vector<float> per_charge_cos_;
284  std::vector<float> per_charge_int_;
285  std::vector<float> per_charge_snr_;
287  std::vector<float> per_isotope_int_;
289  int min_abs_charge_ = 0, max_abs_charge_ = -1;
291  uint index_ = 0;
293  int scan_number_;
295  bool is_positive_;
297  bool is_targeted_ = false;
299  double monoisotopic_mass_ = -1.0;
300  float intensity_;// total intensity
302  PeakGroup::DecoyFlag decoy_flag_ = target;
303 
305  double iso_da_distance_ = Constants::ISOTOPE_MASSDIFF_55K_U;
307  int max_qscore_abs_charge_ = -1;
308  float isotope_cosine_score_ = 0;
309  float charge_score_;
310  float qscore_ = .0f;
311  float avg_ppm_error_ = 0;
312  float avg_da_error_ = 0;
313  float snr_ = 0;
315  std::map<PeakGroup::DecoyFlag, float> qvalue_;
316  };
317 }
Averagine patterns pre-calculated for speed up. Other variables are also calculated for fast cosine c...
Definition: FLASHDeconvHelperStructs.h:59
Definition: PeakGroup.h:61
log transformed peak. After deconvolution, all necessary information from deconvolution such as charg...
Definition: FLASHDeconvHelperStructs.h:164
STL namespace.
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
const double ISOTOPE_MASSDIFF_55K_U
Definition: Constants.h:126
bool operator<(const MultiplexDeltaMasses &dm1, const MultiplexDeltaMasses &dm2)
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
FLASHDeconvHelperStructs::PrecalculatedAveragine PrecalculatedAveragine
Definition: PeakGroup.h:54
Class describing a deconvolved mass. A mass contains multiple (LogMz) peaks of different charges and ...
Definition: PeakGroup.h:51
FLASHDeconvHelperStructs::LogMzPeak LogMzPeak
Definition: PeakGroup.h:53
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Wrapper struct for all the structs needed by the FLASHDeconv Three structures are defined: Precalcula...
Definition: FLASHDeconvHelperStructs.h:56
DecoyFlag
decoy flag. This flag specifies if a PeakGroup is a target, charge decoy, noise decoy, or isotope decoy.
Definition: PeakGroup.h:58
Definition: PeakGroup.h:62
A two-dimensional matrix. Similar to std::vector, but uses a binary operator(,) for element access...
Definition: IsobaricQuantitationMethod.h:51