OpenMS
Loading...
Searching...
No Matches
FLASHHelperClasses.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
17#include <boost/dynamic_bitset.hpp>
18#include <functional>
19
20namespace OpenMS
21{
37 struct OPENMS_DLLAPI FLASHHelperClasses
38 {
40 class OPENMS_DLLAPI PrecalculatedAveragine
41 {
42 private:
44 std::vector<IsotopeDistribution> isotopes_;
46 std::vector<double> norms_;
48 std::vector<double> average_mono_mass_difference_;
50 std::vector<double> abundant_mono_mass_difference_;
51
52 std::vector<double> snr_mul_factor_;
54 std::vector<int> left_count_from_apex_;
56 std::vector<int> right_count_from_apex_;
58 std::vector<Size> apex_index_;
59
65 double min_mass_;
67 Size massToIndex_(double mass) const;
68
69 public:
72
82 PrecalculatedAveragine(double min_mass, double max_mass, double delta, CoarseIsotopePatternGenerator& generator, bool use_RNA_averagine, double decoy_iso_distance = -1);
83
86
89
92
95
98
99
101 IsotopeDistribution get(double mass) const;
102
104 size_t getMaxIsotopeIndex() const;
105
107 void setMaxIsotopeIndex(int index);
108
111 Size getLeftCountFromApex(double mass) const;
112
115 Size getRightCountFromApex(double mass) const;
116
118 Size getApexIndex(double mass) const;
119
121 Size getLastIndex(double mass) const;
122
125 double getAverageMassDelta(double mass) const;
126
129 double getMostAbundantMassDelta(double mass) const;
130
132 double getSNRMultiplicationFactor(double mass) const;
133 };
134
136 struct OPENMS_DLLAPI MassFeature
137 {
138 public:
140 uint index;
144 std::vector<float> per_charge_intensity;
145 std::vector<float> per_isotope_intensity;
149 int scan_number, min_scan_number, max_scan_number, rep_charge;
151 double avg_mass;
153 int min_charge, max_charge, charge_count;
154 double isotope_score, qscore;
155 double rep_mz;
159 bool operator<(const MassFeature& a) const
160 {
161 return avg_mass < a.avg_mass;
162 }
163 bool operator>(const MassFeature& a) const
164 {
165 return avg_mass > a.avg_mass;
166 }
167 bool operator==(const MassFeature& other) const
168 {
169 return avg_mass == other.avg_mass;
170 }
171 };
172
174 struct OPENMS_DLLAPI IsobaricQuantities
175 {
176 public:
177 int scan;
178 double rt;
181 std::vector<double> quantities;
182 std::vector<double> merged_quantities;
184 bool empty() const;
185 };
186
188 class OPENMS_DLLAPI LogMzPeak
189 {
190 public:
192 double mz = 0;
194 float intensity = 0;
196 double logMz = -1000;
198 double mass = .0;
200 int abs_charge = 0;
202 bool is_positive = true;
204 int isotopeIndex = -1;
205
207 LogMzPeak() = default;
208
216 explicit LogMzPeak(const Peak1D& peak, bool positive);
217
219 LogMzPeak(const LogMzPeak&) = default;
220
222 ~LogMzPeak() = default;
223
226 double getUnchargedMass() const;
227
229 bool operator<(const LogMzPeak& a) const;
230 bool operator>(const LogMzPeak& a) const;
231 bool operator==(const LogMzPeak& other) const;
232 };
233
239 static double getLogMz(double mz, bool positive);
240
245 static float getChargeMass(bool positive_ioniziation_mode);
246 };
247} // namespace OpenMS
248
249namespace std
250{
252 template<>
253 struct hash<OpenMS::FLASHHelperClasses::MassFeature>
254 {
255 std::size_t operator()(const OpenMS::FLASHHelperClasses::MassFeature& mf) const noexcept
256 {
257 // Hash based on avg_mass (the field used in operator==)
258 return OpenMS::hash_float(mf.avg_mass);
259 }
260 };
261
263 template<>
264 struct hash<OpenMS::FLASHHelperClasses::LogMzPeak>
265 {
266 std::size_t operator()(const OpenMS::FLASHHelperClasses::LogMzPeak& peak) const noexcept
267 {
268 // Hash based on logMz and intensity (the fields used in operator==)
269 std::size_t seed = OpenMS::hash_float(peak.logMz);
270 OpenMS::hash_combine(seed, OpenMS::hash_float(peak.intensity));
271 return seed;
272 }
273 };
274} // namespace std
Isotope pattern generator for coarse isotope distributions.
Definition CoarseIsotopePatternGenerator.h:79
log transformed peak. After deconvolution, all necessary information from deconvolution such as charg...
Definition FLASHHelperClasses.h:189
bool operator>(const LogMzPeak &a) const
bool operator<(const LogMzPeak &a) const
log mz values are compared
LogMzPeak(const Peak1D &peak, bool positive)
constructor from Peak1D.
LogMzPeak()=default
default constructor
bool operator==(const LogMzPeak &other) const
LogMzPeak(const LogMzPeak &)=default
copy constructor
Averagine patterns pre-calculated for speed up. Other variables are also calculated for fast cosine c...
Definition FLASHHelperClasses.h:41
Size getApexIndex(double mass) const
get index of most abundant isotope. If input mass exceeds the maximum mass (specified in constructor)...
double getSNRMultiplicationFactor(double mass) const
get the SNR multiplication factor - used for quick SNR calculation
void setMaxIsotopeIndex(int index)
set max isotope index
std::vector< double > norms_
L2 norms_ for masses - for quick isotope cosine calculation.
Definition FLASHHelperClasses.h:46
std::vector< double > average_mono_mass_difference_
mass differences between average mass and monoisotopic mass
Definition FLASHHelperClasses.h:48
PrecalculatedAveragine()=default
default constructor
Size max_isotope_index_
max isotope index
Definition FLASHHelperClasses.h:61
PrecalculatedAveragine & operator=(const PrecalculatedAveragine &pc)=default
copy assignment operator
size_t getMaxIsotopeIndex() const
get max isotope index
double min_mass_
min mass for calculation
Definition FLASHHelperClasses.h:65
double mass_interval_
mass interval for calculation
Definition FLASHHelperClasses.h:63
Size massToIndex_(double mass) const
calculate the mass bin index from mass
std::vector< double > abundant_mono_mass_difference_
mass differences between most abundant mass and monoisotopic mass
Definition FLASHHelperClasses.h:50
std::vector< double > snr_mul_factor_
Definition FLASHHelperClasses.h:52
Size getLastIndex(double mass) const
get index of last isotope. If input mass exceeds the maximum mass (specified in constructor),...
PrecalculatedAveragine(double min_mass, double max_mass, double delta, CoarseIsotopePatternGenerator &generator, bool use_RNA_averagine, double decoy_iso_distance=-1)
constructor with parameters such as mass ranges and bin size.
IsotopeDistribution get(double mass) const
get distribution for input mass. If input mass exceeds the maximum mass (specified in constructor),...
PrecalculatedAveragine & operator=(PrecalculatedAveragine &&pc) noexcept=default
move assignment operator
std::vector< IsotopeDistribution > isotopes_
isotope distributions for different (binned) masses
Definition FLASHHelperClasses.h:44
std::vector< Size > apex_index_
most abundant isotope index
Definition FLASHHelperClasses.h:58
std::vector< int > left_count_from_apex_
Isotope start indices: isotopes of the indices less than them have very low intensities.
Definition FLASHHelperClasses.h:54
PrecalculatedAveragine(PrecalculatedAveragine &&other) noexcept=default
move constructor
PrecalculatedAveragine(const PrecalculatedAveragine &)=default
copy constructor
std::vector< int > right_count_from_apex_
Isotope end indices: isotopes of the indices larger than them have very low intensities.
Definition FLASHHelperClasses.h:56
Definition IsotopeDistribution.h:40
A container type that gathers peaks similar in m/z and moving along retention time.
Definition MassTrace.h:36
A 1-dimensional raw data point or peak.
Definition Peak1D.h:30
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
void hash_combine(std::size_t &seed, std::size_t value) noexcept
Combine a hash value with additional data using golden ratio mixing.
Definition HashUtils.h:87
std::size_t hash_float(T value) noexcept
Hash for a floating point type (float or double).
Definition HashUtils.h:142
STL namespace.
Isobaric quantities.
Definition FLASHHelperClasses.h:175
int scan
Definition FLASHHelperClasses.h:177
std::vector< double > quantities
Definition FLASHHelperClasses.h:181
bool empty() const
return true if no isobaric quantities have been stored
std::vector< double > merged_quantities
Definition FLASHHelperClasses.h:182
double precursor_mass
Definition FLASHHelperClasses.h:180
double rt
Definition FLASHHelperClasses.h:178
double precursor_mz
Definition FLASHHelperClasses.h:179
Mass feature (Deconvolved masses in spectra are traced by Mass tracing to generate mass features - li...
Definition FLASHHelperClasses.h:137
bool operator<(const MassFeature &a) const
features are compared
Definition FLASHHelperClasses.h:159
double avg_mass
average mass
Definition FLASHHelperClasses.h:151
std::vector< float > per_charge_intensity
per charge and isotope intensities
Definition FLASHHelperClasses.h:144
uint index
feature index;
Definition FLASHHelperClasses.h:140
bool operator>(const MassFeature &a) const
Definition FLASHHelperClasses.h:163
bool is_decoy
Definition FLASHHelperClasses.h:156
int iso_offset
isotope offset between deconvolved masses and mass feature
Definition FLASHHelperClasses.h:147
std::vector< float > per_isotope_intensity
Definition FLASHHelperClasses.h:145
uint ms_level
Definition FLASHHelperClasses.h:157
double rep_mz
Definition FLASHHelperClasses.h:155
MassTrace mt
the trace calculated from the masses
Definition FLASHHelperClasses.h:142
bool operator==(const MassFeature &other) const
Definition FLASHHelperClasses.h:167
int charge_count
Definition FLASHHelperClasses.h:153
double isotope_score
Definition FLASHHelperClasses.h:154
int max_scan_number
Definition FLASHHelperClasses.h:149
Wrapper struct for all the structs needed by the FLASHDeconv The following structures/classes are def...
Definition FLASHHelperClasses.h:38
static double getLogMz(double mz, bool positive)
calculate log mzs from mzs
static float getChargeMass(bool positive_ioniziation_mode)
get charge carrier mass : positive mode mass of (Constants::PROTON_MASS_U) and negative mode mass of ...
std::size_t operator()(const OpenMS::FLASHHelperClasses::LogMzPeak &peak) const noexcept
Definition FLASHHelperClasses.h:266
std::size_t operator()(const OpenMS::FLASHHelperClasses::MassFeature &mf) const noexcept
Definition FLASHHelperClasses.h:255