1
// -*- mode: C++; tab-width: 2; -*-
4
// --------------------------------------------------------------------------
5
// OpenMS Mass Spectrometry Framework
6
// --------------------------------------------------------------------------
7
// Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
9
// This library is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU Lesser General Public
11
// License as published by the Free Software Foundation; either
12
// version 2.1 of the License, or (at your option) any later version.
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
// Lesser General Public License for more details.
19
// You should have received a copy of the GNU Lesser General Public
20
// License along with this library; if not, write to the Free Software
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
// --------------------------------------------------------------------------
24
// $Maintainer: Clemens Groepl $
26
// --------------------------------------------------------------------------
29
#include <OpenMS/CONCEPT/ClassTest.h>
31
///////////////////////////
33
#include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/EmgModel.h>
34
#include <OpenMS/MATH/MISC/MathFunctions.h>
35
#include <boost/math/special_functions/fpclassify.hpp>
38
///////////////////////////
40
START_TEST(EmgModel, "$Id: EmgModel_test.C 8210 2011-03-28 13:19:52Z aiche $")
42
/////////////////////////////////////////////////////////////
43
/////////////////////////////////////////////////////////////
45
using namespace OpenMS;
46
using std::stringstream;
50
EmgModel* nullPointer = 0;
51
START_SECTION((EmgModel()))
53
TEST_EQUAL(ptr->getName(), "EmgModel")
54
TEST_NOT_EQUAL(ptr, nullPointer)
58
START_SECTION((virtual ~EmgModel()))
62
START_SECTION((static const String getProductName()))
63
TEST_EQUAL(EmgModel::getProductName(),"EmgModel")
64
TEST_EQUAL(EmgModel().getName(),"EmgModel")
67
START_SECTION((static BaseModel<1>* create()))
68
BaseModel<1>* ptr = EmgModel::create();
69
TEST_EQUAL(ptr->getName(), "EmgModel")
70
TEST_NOT_EQUAL(ptr, nullPointer)
73
// assignment operator
74
START_SECTION((virtual EmgModel& operator=(const EmgModel &source)))
76
em1.setInterpolationStep(0.2);
79
tmp.setValue("bounding_box:min", 678.9);
80
tmp.setValue("bounding_box:max", 789.0);
81
tmp.setValue("statistics:mean", 680.1 );
82
tmp.setValue("statistics:variance", 2.0);
83
tmp.setValue("emg:height",100000.0);
84
tmp.setValue("emg:width",5.0);
85
tmp.setValue("emg:symmetry",5.0);
86
tmp.setValue("emg:retention",725.0);
87
em1.setParameters(tmp);
93
em3.setInterpolationStep(0.2);
94
em3.setParameters(tmp);
95
TEST_EQUAL(em3.getParameters(), em2.getParameters())
99
START_SECTION((EmgModel(const EmgModel& source)))
101
em1.setInterpolationStep(0.2);
104
tmp.setValue("bounding_box:min", 678.9);
105
tmp.setValue("bounding_box:max", 789.0);
106
tmp.setValue("statistics:mean", 680.1 );
107
tmp.setValue("statistics:variance", 2.0);
108
tmp.setValue("emg:height",100000.0);
109
tmp.setValue("emg:width",5.0);
110
tmp.setValue("emg:symmetry",5.0);
111
tmp.setValue("emg:retention",725.0);
112
em1.setParameters(tmp);
116
em3.setInterpolationStep(0.2);
117
em3.setParameters(tmp);
120
TEST_EQUAL(em3.getParameters(), em2.getParameters())
124
START_SECTION([EXTRA] DefaultParamHandler::setParameters(...))
126
TOLERANCE_ABSOLUTE(0.001)
130
tmp.setValue("bounding_box:min", 678.9);
131
tmp.setValue("bounding_box:max", 680.9);
132
tmp.setValue("statistics:mean", 679.1 );
133
tmp.setValue("statistics:variance", 2.0);
134
tmp.setValue("emg:height", 100000.0);
135
tmp.setValue("emg:width", 5.0);
136
tmp.setValue("emg:symmetry", 5.0);
137
tmp.setValue("emg:retention", 1200.0);
138
em1.setParameters(tmp);
139
em1.setOffset(680.0);
141
TEST_REAL_SIMILAR(em1.getCenter(), 680.2)
144
em3.setParameters(em1.getParameters());
146
std::vector<Peak1D> dpa1;
147
std::vector<Peak1D> dpa2;
148
em1.getSamples(dpa1);
149
em3.getSamples(dpa2);
151
TOLERANCE_ABSOLUTE(0.0001)
152
TEST_EQUAL(dpa1.size(),dpa2.size())
153
ABORT_IF(dpa1.size()!=dpa2.size());
154
for (Size i=0; i<dpa1.size(); ++i)
156
TEST_REAL_SIMILAR(dpa1[i].getPosition()[0],dpa2[i].getPosition()[0])
157
TEST_REAL_SIMILAR(dpa1[i].getIntensity(),dpa2[i].getIntensity())
161
em2.setInterpolationStep(0.1);
163
tmp.setValue("bounding_box:min", -1.0);
164
tmp.setValue("bounding_box:max", 4.0);
165
tmp.setValue("statistics:mean", 0.0 );
166
tmp.setValue("statistics:variance", 0.1);
167
tmp.setValue("emg:height", 10.0);
168
tmp.setValue("emg:width", 1.0);
169
tmp.setValue("emg:symmetry", 2.0);
170
tmp.setValue("emg:retention", 3.0);
171
em2.setParameters(tmp);
173
TEST_REAL_SIMILAR(em2.getCenter(), 0.0)
175
TOLERANCE_ABSOLUTE(0.01)
176
TEST_REAL_SIMILAR(em2.getIntensity(-1.0), 0.0497198);
177
TEST_REAL_SIMILAR(em2.getIntensity(0.0), 0.164882);
178
TEST_REAL_SIMILAR(em2.getIntensity(1.0), 0.54166);
179
TEST_REAL_SIMILAR(em2.getIntensity(2.0), 1.69364);
181
em2.setInterpolationStep(0.2);
184
TEST_REAL_SIMILAR(em2.getIntensity(-1.0), 0.0497198);
185
TEST_REAL_SIMILAR(em2.getIntensity(0.0), 0.164882);
186
TEST_REAL_SIMILAR(em2.getIntensity(1.0), 0.54166);
187
TEST_REAL_SIMILAR(em2.getIntensity(2.0), 1.69364);
190
// checked small values of parameter symmetry
191
tmp.setValue("bounding_box:min", 0.0);
192
tmp.setValue("bounding_box:max", 10.0);
193
tmp.setValue("statistics:mean", 0.0 );
194
tmp.setValue("statistics:variance", 0.1);
195
tmp.setValue("emg:height", 10.0);
196
tmp.setValue("emg:width", 6.0);
197
tmp.setValue("emg:symmetry", 1.0);
198
tmp.setValue("emg:retention", 3.0);
199
em2.setParameters(tmp);
201
TEST_REAL_SIMILAR(em2.getIntensity(2.0), 747203);
203
tmp.setValue("emg:symmetry", 0.1);
204
em2.setParameters(tmp);
205
ABORT_IF(boost::math::isinf(em2.getIntensity(2.0)))
207
tmp.setValue("emg:symmetry", 0.16);
208
em2.setParameters(tmp);
209
ABORT_IF(boost::math::isinf(em2.getIntensity(2.0)))
211
tmp.setValue("emg:symmetry", 0.17);
212
em2.setParameters(tmp);
213
ABORT_IF(boost::math::isinf(float(!em2.getIntensity(2.0))))
215
tmp.setValue("emg:symmetry", 0.2);
216
em2.setParameters(tmp);
217
ABORT_IF(!boost::math::isinf(em2.getIntensity(2.0)))
221
START_SECTION((void setOffset(CoordinateType offset)))
225
tmp.setValue("bounding_box:min", 678.9);
226
tmp.setValue("bounding_box:max", 789.0);
227
tmp.setValue("statistics:mean", 680.1 );
228
tmp.setValue("statistics:variance", 2.0);
229
tmp.setValue("emg:height", 100000.0);
230
tmp.setValue("emg:width", 5.0);
231
tmp.setValue("emg:symmetry", 5.0);
232
tmp.setValue("emg:retention", 725.0);
233
em1.setParameters(tmp);
234
em1.setOffset(680.9);
237
em2.setParameters(tmp);
238
em2.setOffset(680.9);
240
TEST_EQUAL(em1.getParameters(), em2.getParameters())
241
TEST_REAL_SIMILAR(em1.getCenter(), em2.getCenter())
242
TEST_REAL_SIMILAR(em1.getCenter(), 682.1)
244
std::vector<Peak1D> dpa1;
245
std::vector<Peak1D> dpa2;
246
em1.getSamples(dpa1);
247
em2.getSamples(dpa2);
249
TOLERANCE_ABSOLUTE(0.01)
250
TEST_EQUAL(dpa1.size(),dpa2.size())
251
ABORT_IF(dpa1.size()!=dpa2.size());
252
for (Size i=0; i<dpa1.size(); ++i)
254
TEST_REAL_SIMILAR(dpa1[i].getPosition()[0],dpa2[i].getPosition()[0])
255
TEST_REAL_SIMILAR(dpa1[i].getIntensity(),dpa2[i].getIntensity())
259
START_SECTION((CoordinateType getCenter() const))
260
TOLERANCE_ABSOLUTE(0.001)
264
tmp.setValue("bounding_box:min", 678.9);
265
tmp.setValue("bounding_box:max", 789.0);
266
tmp.setValue("statistics:mean", 680.1 );
267
tmp.setValue("statistics:variance", 2.0);
268
tmp.setValue("emg:height", 100000.0);
269
tmp.setValue("emg:width", 5.0);
270
tmp.setValue("emg:symmetry", 5.0);
271
tmp.setValue("emg:retention", 725.0);
272
em1.setParameters(tmp);
273
em1.setOffset(680.0);
274
TEST_REAL_SIMILAR(em1.getCenter(), 681.2)
278
START_SECTION((void setSamples()))
285
/////////////////////////////////////////////////////////////
286
/////////////////////////////////////////////////////////////