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
13#ifdef _MSC_VER
14using uint = unsigned int; // POSIX uint not available on MSVC; was provided transitively via Qt
15#endif
20#include <boost/dynamic_bitset.hpp>
21#include <functional>
22
23namespace OpenMS
24{
40 struct OPENMS_DLLAPI FLASHHelperClasses
41 {
43 class OPENMS_DLLAPI PrecalculatedAveragine
44 {
45 private:
47 std::vector<IsotopeDistribution> isotopes_;
49 std::vector<double> norms_;
51 std::vector<double> average_mono_mass_difference_;
53 std::vector<double> abundant_mono_mass_difference_;
54
55 std::vector<double> snr_mul_factor_;
57 std::vector<int> left_count_from_apex_;
59 std::vector<int> right_count_from_apex_;
61 std::vector<Size> apex_index_;
62
68 double min_mass_;
70 Size massToIndex_(double mass) const;
71
72 public:
75
85 PrecalculatedAveragine(double min_mass, double max_mass, double delta, CoarseIsotopePatternGenerator& generator, bool use_RNA_averagine, double decoy_iso_distance = -1);
86
89
92
95
98
101
102
104 IsotopeDistribution get(double mass) const;
105
107 size_t getMaxIsotopeIndex() const;
108
110 void setMaxIsotopeIndex(int index);
111
114 Size getLeftCountFromApex(double mass) const;
115
118 Size getRightCountFromApex(double mass) const;
119
121 Size getApexIndex(double mass) const;
122
124 Size getLastIndex(double mass) const;
125
128 double getAverageMassDelta(double mass) const;
129
132 double getMostAbundantMassDelta(double mass) const;
133
135 double getSNRMultiplicationFactor(double mass) const;
136 };
137
139 struct OPENMS_DLLAPI MassFeature
140 {
141 public:
143 uint index;
147 std::vector<float> per_charge_intensity;
148 std::vector<float> per_isotope_intensity;
152 int scan_number, min_scan_number, max_scan_number, rep_charge;
154 double avg_mass;
156 int min_charge, max_charge, charge_count;
157 double isotope_score, qscore;
158 double rep_mz;
162 bool operator<(const MassFeature& a) const
163 {
164 return avg_mass < a.avg_mass;
165 }
166 bool operator>(const MassFeature& a) const
167 {
168 return avg_mass > a.avg_mass;
169 }
170 bool operator==(const MassFeature& other) const
171 {
172 return avg_mass == other.avg_mass;
173 }
174 };
175
177 struct OPENMS_DLLAPI IsobaricQuantities
178 {
179 public:
180 int scan;
181 double rt;
184 std::vector<double> quantities;
185 std::vector<double> merged_quantities;
187 bool empty() const;
188 };
189
191 class OPENMS_DLLAPI LogMzPeak
192 {
193 public:
195 double mz = 0;
197 float intensity = 0;
199 double logMz = -1000;
201 double mass = .0;
203 int abs_charge = 0;
205 bool is_positive = true;
207 int isotopeIndex = -1;
208
210 LogMzPeak() = default;
211
219 explicit LogMzPeak(const Peak1D& peak, bool positive);
220
222 LogMzPeak(const LogMzPeak&) = default;
223
225 ~LogMzPeak() = default;
226
229 double getUnchargedMass() const;
230
232 bool operator<(const LogMzPeak& a) const;
233 bool operator>(const LogMzPeak& a) const;
234 bool operator==(const LogMzPeak& other) const;
235 };
236
242 static double getLogMz(double mz, bool positive);
243
248 static float getChargeMass(bool positive_ioniziation_mode);
249 };
250} // namespace OpenMS
251
252namespace std
253{
255 template<>
256 struct hash<OpenMS::FLASHHelperClasses::MassFeature>
257 {
258 std::size_t operator()(const OpenMS::FLASHHelperClasses::MassFeature& mf) const noexcept
259 {
260 // Hash based on avg_mass (the field used in operator==)
261 return OpenMS::hash_float(mf.avg_mass);
262 }
263 };
264
266 template<>
267 struct hash<OpenMS::FLASHHelperClasses::LogMzPeak>
268 {
269 std::size_t operator()(const OpenMS::FLASHHelperClasses::LogMzPeak& peak) const noexcept
270 {
271 // Hash based on logMz and intensity (the fields used in operator==)
272 std::size_t seed = OpenMS::hash_float(peak.logMz);
273 OpenMS::hash_combine(seed, OpenMS::hash_float(peak.intensity));
274 return seed;
275 }
276 };
277} // 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:192
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:44
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:49
std::vector< double > average_mono_mass_difference_
mass differences between average mass and monoisotopic mass
Definition FLASHHelperClasses.h:51
PrecalculatedAveragine()=default
default constructor
Size max_isotope_index_
max isotope index
Definition FLASHHelperClasses.h:64
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:68
double mass_interval_
mass interval for calculation
Definition FLASHHelperClasses.h:66
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:53
std::vector< double > snr_mul_factor_
Definition FLASHHelperClasses.h:55
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:47
std::vector< Size > apex_index_
most abundant isotope index
Definition FLASHHelperClasses.h:61
std::vector< int > left_count_from_apex_
Isotope start indices: isotopes of the indices less than them have very low intensities.
Definition FLASHHelperClasses.h:57
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:59
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:178
int scan
Definition FLASHHelperClasses.h:180
std::vector< double > quantities
Definition FLASHHelperClasses.h:184
bool empty() const
return true if no isobaric quantities have been stored
std::vector< double > merged_quantities
Definition FLASHHelperClasses.h:185
double precursor_mass
Definition FLASHHelperClasses.h:183
double rt
Definition FLASHHelperClasses.h:181
double precursor_mz
Definition FLASHHelperClasses.h:182
Mass feature (Deconvolved masses in spectra are traced by Mass tracing to generate mass features - li...
Definition FLASHHelperClasses.h:140
bool operator<(const MassFeature &a) const
features are compared
Definition FLASHHelperClasses.h:162
double avg_mass
average mass
Definition FLASHHelperClasses.h:154
std::vector< float > per_charge_intensity
per charge and isotope intensities
Definition FLASHHelperClasses.h:147
uint index
feature index;
Definition FLASHHelperClasses.h:143
bool operator>(const MassFeature &a) const
Definition FLASHHelperClasses.h:166
bool is_decoy
Definition FLASHHelperClasses.h:159
int iso_offset
isotope offset between deconvolved masses and mass feature
Definition FLASHHelperClasses.h:150
std::vector< float > per_isotope_intensity
Definition FLASHHelperClasses.h:148
uint ms_level
Definition FLASHHelperClasses.h:160
double rep_mz
Definition FLASHHelperClasses.h:158
MassTrace mt
the trace calculated from the masses
Definition FLASHHelperClasses.h:145
bool operator==(const MassFeature &other) const
Definition FLASHHelperClasses.h:170
int charge_count
Definition FLASHHelperClasses.h:156
double isotope_score
Definition FLASHHelperClasses.h:157
int max_scan_number
Definition FLASHHelperClasses.h:152
Wrapper struct for all the structs needed by the FLASHDeconv The following structures/classes are def...
Definition FLASHHelperClasses.h:41
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:269
std::size_t operator()(const OpenMS::FLASHHelperClasses::MassFeature &mf) const noexcept
Definition FLASHHelperClasses.h:258