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 
38 
39 namespace OpenMS
40 {
50  class OPENMS_DLLAPI PeakGroup
51  {
54  public:
56  PeakGroup() = default;
57 
64  explicit PeakGroup(const int min_abs_charge, const int max_abs_charge, const bool is_positive);
65 
68 
70  PeakGroup(const PeakGroup& ) = default;
71 
73  PeakGroup(PeakGroup&& other) = default;
74 
76  bool operator<(const PeakGroup& a) const;
77 
78  bool operator>(const PeakGroup& a) const;
79 
80  bool operator==(const PeakGroup& a) const;
81 
83  PeakGroup& operator=(const PeakGroup& t) = default;
84 
90 
91  void updateIsotopeCosineAndQScore(const FLASHDeconvHelperStructs::PrecalculatedAveragine& avg, double min_cos, double iso_da_distance);
92 
93  //MSSpectrum getSubspectrumForMass(const MSSpectrum& spec, const FLASHDeconvHelperStructs::PrecalculatedAveragine& avg, double mono_mass);
94 
96  void recruitAllPeaksInSpectrum(const MSSpectrum& spec, const double tol, const FLASHDeconvHelperStructs::PrecalculatedAveragine& avg, double mono_mass, bool write_detail);
97 
99  void updateSNR();
100 
102  bool isSignalMZ(const double mz, const double tol) const;
103 
105  void setScanNumber(const int scan_number);
106 
108  void setChargeIsotopeCosine(const int abs_charge, const float cos);
109 
110 
112  void setMaxQScoreMzRange(const double min, const double max);
113 
115  void setAbsChargeRange(const int min_abs_charge, const int max_abs_charge);
116 
118  void setIsotopeCosine(const float cos);
119 
121  void setRepAbsCharge(const int max_qscore_charge);
122 
124  void setQScore(const float qscore);
125 
127  void setChargeScore(const float charge_score);
128 
130  void setAvgPPMError(const float error);
131 
133  void setSNR(const float snr);
135  void setChargeSNR(const int abs_charge, const float c_snr);
136 
138  void setTargeted();
139 
141  void setSecondBestMonsMass(const double mass);
142 
144  int getScanNumber() const;
145 
147  double getMonoMass() const;
148 
150  double getSecondBestMonoMass() const;
151 
153  double getIntensity() const;
154 
156  float getChargeSNR(const int abs_charge) const;
157 
159  float getChargeIsotopeCosine(const int abs_charge) const;
160 
162  float getChargeIntensity(const int abs_charge) const;
163 
165  std::tuple<double, double> getMaxQScoreMzRange() const;
166 
168  std::tuple<double, double> getMzRange(int abs_charge) const;
169 
171  std::tuple<int, int> getAbsChargeRange() const;
172 
173  std::vector<float> getIsotopeIntensities() const;
174 
176  float getIsotopeCosine() const;
177 
179  int getRepAbsCharge() const;
180 
182  float getQScore() const;
183 
185  float getSNR() const;
186 
188  float getChargeScore() const;
189 
191  float getAvgPPMError() const;
192 
194  bool isPositive() const;
195 
197  bool isTargeted() const;
198 
199  //float getDecoyQScore() const;
200 
201  //void setDecoyQScore(const float d);
202 
203  //float getDecoyIsoScore() const;
204 
205  //void setDecoyIsoScore(const float d);
206 
207  int getDecoyIndex() const;
208 
209  void setDecoyIndex(int index);
210 
211  float getQvalue() const;
212 
213  void setQvalue(const float q);
214 
216 
218 
220 
221  void setQvalueWithChargeDecoyOnly(const float q);
222 
223  void setQvalueWithIsotopeDecoyOnly(const float q);
224 
225  void setQvalueWithNoiseDecoyOnly(const float q);
226 
227  void setIsotopeDaDistance(const double d);
228 
229  double getIsotopeDaDistance() const;
230 
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 
238  const FLASHDeconvHelperStructs::LogMzPeak& operator[](const Size i) const;
239 
240  void push_back (const FLASHDeconvHelperStructs::LogMzPeak& pg);
241  Size size() const noexcept;
242  void clear();
243  void reserve (Size n);
244  bool empty() const;
245  void swap (std::vector<FLASHDeconvHelperStructs::LogMzPeak>& x);
246  void shrink_to_fit();
247  void sort();
248  std::vector<FLASHDeconvHelperStructs::LogMzPeak> noisy_peaks;
249 
250  private:
251 
253  void setChargePowers_(const int abs_charge, const double signal_pwr, const double noise_pwr, const double intensity);
254  void updateChargeFitScoreAndChargeIntensities_();
255  //update avg ppm error
256  void updateAvgPPMError_(double iso_da_distance);
257 
258 
260  std::vector<FLASHDeconvHelperStructs::LogMzPeak> logMzpeaks_;
261 
262 
264  std::vector<float> per_charge_signal_pwr_;
265  std::vector<float> per_charge_pwr_;
266  std::vector<float> per_charge_cos_;
267  std::vector<float> per_charge_int_;
268  std::vector<float> per_charge_snr_;
270  std::vector<float> per_isotope_int_;
272  double max_qscore_mz_end_, max_qscore_mz_start_;
274  int min_abs_charge_ = 0, max_abs_charge_ = -1;
276  int scan_number_;
278  bool is_positive_;
280  bool is_targeted_ = false;
282  double monoisotopic_mass_ = -1.0;
283  double second_best_monomass_ = -1.0;
284  double intensity_;// total intensity
286  int decoy_index_ = 0;
287 
289  double iso_da_distance_ = Constants::ISOTOPE_MASSDIFF_55K_U;
291  int max_qscore_abs_charge_ = -1;
292  float isotope_cosine_score_ = 0;
293  float charge_score_;
294  float qscore_ = .0f;
295  float avg_ppm_error_ = 0;
296  float snr_ = 0;
297  float qvalue_ = 1.0;
298 
299  float qvalue_with_isotope_decoy_only_ = 1.0;
300  float qvalue_with_noise_decoy_only_ = 1.0;
301  float qvalue_with_charge_decoy_only_ = 1.0;
302  };
303 }
log transformed peak. After deconvolution, all necessary information from deconvolution such as charg...
Definition: FLASHDeconvHelperStructs.h:192
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 peaks of different charges and isotope ...
Definition: PeakGroup.h:51
void setScanNumber(const int scan_number)
set scan number
void updateMonomassAndIsotopeIntensities()
add monoisotopic indices of peaks by offset and discard negative isotope peaks. Total intensity is al...
void setTargeted()
set if it is targeted
std::vector< float > getIsotopeIntensities() const
void setChargeScore(const float charge_score)
set charge score - for FLASHIda log file parsing
std::tuple< double, double > getMzRange(int abs_charge) const
get mz range of the charge
FLASHDeconvHelperStructs::LogMzPeak LogMzPeak
Definition: PeakGroup.h:52
std::tuple< double, double > getMaxQScoreMzRange() const
get mz range that results in max QScore
bool isTargeted() const
get if it is targeted
void setIsotopeCosine(const float cos)
set isotope cosine score
void setQvalueWithIsotopeDecoyOnly(const float q)
void setSecondBestMonsMass(const double mass)
set second best monoisotopic mass
float getQScore() const
get Q score
void setChargeIsotopeCosine(const int abs_charge, const float cos)
set per abs_charge isotope cosine
bool isSignalMZ(const double mz, const double tol) const
determine is an mz is a signal of this peakgroup. Input tol is ppm tolerance (e.g....
float getChargeIsotopeCosine(const int abs_charge) const
get per abs_charge isotope cosine
double getSecondBestMonoMass() const
get second best monoisotopic mass
float getSNR() const
get total SNR
int getRepAbsCharge() const
get representative charge
bool operator<(const PeakGroup &a) const
comparison operators
~PeakGroup()
default destructor
void updateSNR()
using signal and total (signal + noise) power, update SNR value
void setQvalueWithNoiseDecoyOnly(const float q)
bool operator>(const PeakGroup &a) const
float getChargeScore() const
get charge score
void setMaxQScoreMzRange(const double min, const double max)
set mz range that results in max QScore
void setQScore(const float qscore)
set Q score - for FLASHIda log file parsing
void setAbsChargeRange(const int min_abs_charge, const int max_abs_charge)
set min_abs_charge and max_abs_charge charge range
void setDecoyIndex(int index)
float getQvalue() const
void setSNR(const float snr)
set SNR manually - for FLASHIda log file parsing
void setAvgPPMError(const float error)
set average mass ppm error
float getQvalueWithIsotopeDecoyOnly() const
float getChargeSNR(const int abs_charge) const
get per abs_charge SNR
int getScanNumber() const
get scan number
PeakGroup()=default
default constructor
std::tuple< int, int > getAbsChargeRange() const
get charge range - the actual charge values
void setChargeSNR(const int abs_charge, const float c_snr)
set charge SNR manually - for FLASHIda log file parsing
PeakGroup(const PeakGroup &)=default
copy constructor
std::vector< FLASHDeconvHelperStructs::LogMzPeak >::const_iterator begin() const noexcept
float getIsotopeCosine() const
get isotopic cosine score
void setQvalue(const float q)
PeakGroup & operator=(const PeakGroup &t)=default
assignment operator
PeakGroup(PeakGroup &&other)=default
move constructor
float getChargeIntensity(const int abs_charge) const
get per abs_charge intenstiy
double getIsotopeDaDistance() const
bool operator==(const PeakGroup &a) const
int getDecoyIndex() const
void updateIsotopeCosineAndQScore(const FLASHDeconvHelperStructs::PrecalculatedAveragine &avg, double min_cos, double iso_da_distance)
void setIsotopeDaDistance(const double d)
float getQvalueWithNoiseDecoyOnly() const
double getMonoMass() const
get monoisotopic mass
bool isPositive() const
get if it is positive mode
FLASHDeconvHelperStructs::PrecalculatedAveragine PrecalculatedAveragine
Definition: PeakGroup.h:53
void recruitAllPeaksInSpectrum(const MSSpectrum &spec, const double tol, const FLASHDeconvHelperStructs::PrecalculatedAveragine &avg, double mono_mass, bool write_detail)
recruit peaks and then return as a spectrum.
void setQvalueWithChargeDecoyOnly(const float q)
void setRepAbsCharge(const int max_qscore_charge)
set representative max_qscore_charge
float getQvalueWithChargeDecoyOnly() const
PeakGroup(const int min_abs_charge, const int max_abs_charge, const bool is_positive)
Constructor specifying charge range.
float getAvgPPMError() const
get average mass ppm error;
double getIntensity() const
get intensity
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
FLASHIda C++ to C# (or vice versa) bridge functions The functions here are called in C# to invoke fun...
Definition: FeatureDeconvolution.h:48
static FLASHDeconvHelperStructs::PrecalculatedAveragine avg
keeps the precalculated averagine to calculate average masses from monoisotopic masses
Definition: FLASHIdaBridgeFunctions.h:81
Wrapper struct for all the structs needed by the FLASHDeconv Three structures are defined: Precalcula...
Definition: FLASHDeconvHelperStructs.h:57