| OpenMS 2.5.0

RawMSSignalSimulation.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-2020.
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: Timo Sachsenberg$
32 // $Authors: Stephan Aiche, Chris Bielow$
33 // --------------------------------------------------------------------------
34
35 #pragma once
36
37 #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
38 #include <OpenMS/CONCEPT/ProgressLogger.h>
39
40 #include <OpenMS/SIMULATION/SimTypes.h>
41 #include <OpenMS/SIMULATION/EGHModel.h>
42
43 #include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/ProductModel.h>
44
45 namespace OpenMS
46 {
47
48 class IsotopeModel;
49
60 class OPENMS_DLLAPI RawMSSignalSimulation :
61 public DefaultParamHandler,
62 public ProgressLogger
63 {
64
65 public:
69 RawMSSignalSimulation();
71
73 explicit RawMSSignalSimulation(SimTypes::MutableSimRandomNumberGeneratorPtr rng);
74
76 RawMSSignalSimulation(const RawMSSignalSimulation& source);
77
79 ~RawMSSignalSimulation() override;
81
82 RawMSSignalSimulation& operator=(const RawMSSignalSimulation& source);
83
87 void loadContaminants();
88
90 void generateRawSignals(SimTypes::FeatureMapSim& features,
91 SimTypes::MSSimExperiment& experiment,
92 SimTypes::MSSimExperiment& experiment_ct,
93 SimTypes::FeatureMapSim& contaminants);
94
95 protected:
96
97 enum IONIZATIONMETHOD {IM_ESI = 0, IM_MALDI = 1, IM_ALL = 2};
98 enum PROFILESHAPE {RT_RECTANGULAR, RT_GAUSSIAN};
99 enum RESOLUTIONMODEL {RES_CONSTANT, RES_LINEAR, RES_SQRT};
100
102 void updateMembers_() override;
103
105 void setDefaultParams_();
106
114 void add1DSignal_(Feature& feature, SimTypes::MSSimExperiment& experiment, SimTypes::MSSimExperiment& experiment_ct);
115
123 void add2DSignal_(Feature& feature, SimTypes::MSSimExperiment& experiment, SimTypes::MSSimExperiment& experiment_ct);
124
135 void samplePeptideModel1D_(const IsotopeModel& iso,
136 const SimTypes::SimCoordinateType mz_start,
137 const SimTypes::SimCoordinateType mz_end,
138 SimTypes::MSSimExperiment& experiment,
139 SimTypes::MSSimExperiment& experiment_ct,
140 Feature& activeFeature);
141
154 void samplePeptideModel2D_(const ProductModel<2>& pm,
155 const SimTypes::SimCoordinateType mz_start,
156 const SimTypes::SimCoordinateType mz_end,
157 SimTypes::SimCoordinateType rt_start,
158 SimTypes::SimCoordinateType rt_end,
159 SimTypes::MSSimExperiment& experiment,
160 SimTypes::MSSimExperiment& experiment_ct,
161 Feature& activeFeature);
162
166 void chooseElutionProfile_(EGHModel* const elutionmodel,
167 Feature& feature,
168 const double scale,
169 const double rt_sampling_rate,
170 const SimTypes::MSSimExperiment& experiment);
171
175 void createContaminants_(SimTypes::FeatureMapSim& contaminants, SimTypes::MSSimExperiment& exp, SimTypes::MSSimExperiment& exp_ct);
176
178 void addShotNoise_(SimTypes::MSSimExperiment& experiment, SimTypes::SimCoordinateType minimal_mz_measurement_limit, SimTypes::SimCoordinateType maximal_mz_measurement_limit);
179
181 void addWhiteNoise_(SimTypes::MSSimExperiment& experiment);
182
184 void addDetectorNoise_(SimTypes::MSSimExperiment& experiment);
185
187 void addBaseLine_(SimTypes::MSSimExperiment& experiment, SimTypes::SimCoordinateType minimal_mz_measurement_limit);
188
190 void getSamplingGrid_(std::vector<SimTypes::SimCoordinateType>& grid,
191 const SimTypes::SimCoordinateType mz_min,
192 const SimTypes::SimCoordinateType mz_max,
193 const Int step_Da);
194
196 void compressSignals_(SimTypes::MSSimExperiment& experiment);
197
199 Int sampling_points_per_FWHM_;
200
202 SimTypes::SimCoordinateType mz_error_mean_;
204 SimTypes::SimCoordinateType mz_error_stddev_;
205
214 SimTypes::SimIntensityType getFeatureScaledIntensity_(const SimTypes::SimIntensityType feature_intensity,
215 const SimTypes::SimIntensityType natural_scaling_factor);
216
217
229 double getResolution_(const double query_mz, const double resolution, const RESOLUTIONMODEL model) const;
230
234 double getPeakWidth_(const double mz, const bool is_gaussian) const;
235
237 SimTypes::SimIntensityType intensity_scale_;
239 SimTypes::SimIntensityType intensity_scale_stddev_;
240
241
243 RESOLUTIONMODEL res_model_;
245 double res_base_;
247 std::vector<SimTypes::SimCoordinateType> grid_;
248
250 SimTypes::MutableSimRandomNumberGeneratorPtr rnd_gen_;
251
252 struct ContaminantInfo
253 {
254 String name;
255 EmpiricalFormula sf;
256 double rt_start, rt_end, intensity;
257 Int q;
258 PROFILESHAPE shape;
259 IONIZATIONMETHOD im;
260 };
261
262 std::vector<ContaminantInfo> contaminants_;
263
267 std::vector<std::vector<double> > threaded_random_numbers_;
268
273 std::vector<Size> threaded_random_numbers_index_;
274
275 static const Size THREADED_RANDOM_NUMBER_POOL_SIZE_ = 500;
276
277 bool contaminants_loaded_;
278 };
279
280 }
281
OpenMS::RawMSSignalSimulation::contaminants_
std::vector< ContaminantInfo > contaminants_
Definition: RawMSSignalSimulation.h:262
OpenMS::Feature
An LC-MS feature.
Definition: Feature.h:70
OpenMS::RawMSSignalSimulation::threaded_random_numbers_index_
std::vector< Size > threaded_random_numbers_index_
Definition: RawMSSignalSimulation.h:273
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::ProductModel< 2 >
The class template is only implemented for D=2 because we use Peak2D here.
Definition: ProductModel.h:64
EGHModel.h
OpenMS::DefaultParamHandler
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
OpenMS::RawMSSignalSimulation
Simulates MS signals for a given set of peptides.
Definition: RawMSSignalSimulation.h:60
SimTypes.h
OpenMS::RawMSSignalSimulation::intensity_scale_stddev_
SimTypes::SimIntensityType intensity_scale_stddev_
Standard deviation of peak intensity scaling.
Definition: RawMSSignalSimulation.h:239
OpenMS::RawMSSignalSimulation::ContaminantInfo::rt_start
double rt_start
Definition: RawMSSignalSimulation.h:256
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
OpenMS::RawMSSignalSimulation::grid_
std::vector< SimTypes::SimCoordinateType > grid_
m/z sampling grid for all signals
Definition: RawMSSignalSimulation.h:247
OpenMS::RawMSSignalSimulation::intensity_scale_
SimTypes::SimIntensityType intensity_scale_
Scaling factor of peak intensities.
Definition: RawMSSignalSimulation.h:237
OpenMS::FeatureMap
A container for features.
Definition: FeatureMap.h:95
OpenMS::RawMSSignalSimulation::ContaminantInfo
Definition: RawMSSignalSimulation.h:252
OpenMS::EGHModel
Exponential-Gaussian hybrid distribution model for elution profiles.
Definition: EGHModel.h:55
OpenMS::RawMSSignalSimulation::RESOLUTIONMODEL
RESOLUTIONMODEL
Definition: RawMSSignalSimulation.h:99
OpenMS::RawMSSignalSimulation::ContaminantInfo::q
Int q
Definition: RawMSSignalSimulation.h:257
OpenMS::IsotopeModel
Isotope distribution approximated using linear interpolation.
Definition: IsotopeModel.h:58
OpenMS::RawMSSignalSimulation::ContaminantInfo::sf
EmpiricalFormula sf
Definition: RawMSSignalSimulation.h:255
OpenMS::RawMSSignalSimulation::ContaminantInfo::name
String name
Definition: RawMSSignalSimulation.h:254
ProgressLogger.h
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::RawMSSignalSimulation::RT_RECTANGULAR
Definition: RawMSSignalSimulation.h:98
OpenMS::RawMSSignalSimulation::mz_error_mean_
SimTypes::SimCoordinateType mz_error_mean_
Mean of peak m/z error.
Definition: RawMSSignalSimulation.h:202
OpenMS::RawMSSignalSimulation::threaded_random_numbers_
std::vector< std::vector< double > > threaded_random_numbers_
Definition: RawMSSignalSimulation.h:267
OpenMS::ProgressLogger
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:54
OpenMS::RawMSSignalSimulation::ContaminantInfo::shape
PROFILESHAPE shape
Definition: RawMSSignalSimulation.h:258
OpenMS::RawMSSignalSimulation::PROFILESHAPE
PROFILESHAPE
Definition: RawMSSignalSimulation.h:98
OpenMS::RawMSSignalSimulation::res_model_
RESOLUTIONMODEL res_model_
model of how resolution behaves with increasing m/z
Definition: RawMSSignalSimulation.h:243
OpenMS::RawMSSignalSimulation::sampling_points_per_FWHM_
Int sampling_points_per_FWHM_
number of points sampled per peak&#39;s FWHM
Definition: RawMSSignalSimulation.h:199
DefaultParamHandler.h
OpenMS::EmpiricalFormula
Representation of an empirical formula.
Definition: EmpiricalFormula.h:82
double
OpenMS::RawMSSignalSimulation::rnd_gen_
SimTypes::MutableSimRandomNumberGeneratorPtr rnd_gen_
Random number generator.
Definition: RawMSSignalSimulation.h:250
float
OpenMS::RawMSSignalSimulation::ContaminantInfo::im
IONIZATIONMETHOD im
Definition: RawMSSignalSimulation.h:259
OpenMS::RawMSSignalSimulation::IONIZATIONMETHOD
IONIZATIONMETHOD
Definition: RawMSSignalSimulation.h:97
OpenMS::RawMSSignalSimulation::res_base_
double res_base_
base resolution at 400 Th
Definition: RawMSSignalSimulation.h:245
int
OpenMS::RawMSSignalSimulation::mz_error_stddev_
SimTypes::SimCoordinateType mz_error_stddev_
Standard deviation of peak m/z error.
Definition: RawMSSignalSimulation.h:204
ProductModel.h
OpenMS::SimTypes::MutableSimRandomNumberGeneratorPtr
boost::shared_ptr< SimRandomNumberGenerator > MutableSimRandomNumberGeneratorPtr
Definition: SimTypes.h:174
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::RawMSSignalSimulation::contaminants_loaded_
bool contaminants_loaded_
Definition: RawMSSignalSimulation.h:277