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
// --------------------------------------------------------------------------
28
#include <OpenMS/CONCEPT/ClassTest.h>
30
///////////////////////////
32
#include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/LmaGaussModel.h>
34
///////////////////////////
36
START_TEST(LmaGaussModel, "$Id: LmaGaussModel_test.C 8210 2011-03-28 13:19:52Z aiche $")
38
/////////////////////////////////////////////////////////////
39
/////////////////////////////////////////////////////////////
41
using namespace OpenMS;
42
using std::stringstream;
45
LmaGaussModel* ptr = 0;
46
LmaGaussModel* nullPointer = 0;
47
START_SECTION((LmaGaussModel()))
48
ptr = new LmaGaussModel();
49
TEST_EQUAL(ptr->getName(), "LmaGaussModel")
50
TEST_NOT_EQUAL(ptr, nullPointer)
54
START_SECTION((virtual ~LmaGaussModel()))
58
START_SECTION((static const String getProductName()))
59
TEST_EQUAL(LmaGaussModel::getProductName(),"LmaGaussModel")
60
TEST_EQUAL(LmaGaussModel().getName(),"LmaGaussModel")
63
START_SECTION((static BaseModel<1>* create()))
64
BaseModel<1>* ptr = LmaGaussModel::create();
65
TEST_EQUAL(ptr->getName(), "LmaGaussModel")
66
TEST_NOT_EQUAL(ptr, nullPointer)
69
// assignment operator
70
START_SECTION((virtual LmaGaussModel& operator=(const LmaGaussModel &source)))
72
lm1.setInterpolationStep(0.3);
75
tmp.setValue("bounding_box:min", 678.9);
76
tmp.setValue("bounding_box:max", 789.0);
77
tmp.setValue("statistics:mean", 680.1 );
78
tmp.setValue("statistics:variance", 2.0);
79
tmp.setValue("lma:scale_factor", 1000000.0);
80
tmp.setValue("lma:standard_deviation", 2.0);
81
tmp.setValue("lma:expected_value", 680.0);
82
lm1.setParameters(tmp);
88
lm3.setInterpolationStep(0.3);
89
lm3.setParameters(tmp);
91
TEST_EQUAL(lm3.getParameters(), lm2.getParameters())
95
START_SECTION((LmaGaussModel(const LmaGaussModel& source)))
97
lm1.setInterpolationStep(0.3);
100
tmp.setValue("bounding_box:min", 678.9);
101
tmp.setValue("bounding_box:max", 789.0);
102
tmp.setValue("statistics:mean", 680.1 );
103
tmp.setValue("statistics:variance", 2.0);
104
tmp.setValue("lma:scale_factor", 10.0);
105
tmp.setValue("lma:standard_deviation", 2.0);
106
tmp.setValue("lma:expected_value", 680.0);
107
lm1.setParameters(tmp);
109
LmaGaussModel lm2(lm1);
111
lm3.setInterpolationStep(0.3);
112
lm3.setParameters(tmp);
114
TEST_EQUAL(lm3.getParameters(), lm2.getParameters())
117
START_SECTION([EXTRA] DefaultParamHandler::setParameters(...))
118
TOLERANCE_ABSOLUTE(0.001)
122
tmp.setValue("bounding_box:min", 678.9);
123
tmp.setValue("bounding_box:max", 680.9);
124
tmp.setValue("statistics:mean", 679.1 );
125
tmp.setValue("statistics:variance", 2.0);
126
tmp.setValue("lma:scale_factor", 10.0);
127
tmp.setValue("lma:standard_deviation", 2.0);
128
tmp.setValue("lma:expected_value", 700.0);
129
lm1.setParameters(tmp);
130
lm1.setOffset(680.0);
132
TEST_REAL_SIMILAR(lm1.getCenter(), 680.2)
135
lm2.setParameters(lm1.getParameters());
137
std::vector<Peak1D> dpa1;
138
std::vector<Peak1D> dpa2;
139
lm1.getSamples(dpa1);
140
lm2.getSamples(dpa2);
142
TOLERANCE_ABSOLUTE(0.0001)
143
TEST_EQUAL(dpa1.size(),dpa2.size())
144
ABORT_IF(dpa1.size()!=dpa2.size());
145
for (Size i=0; i<dpa1.size(); ++i)
147
TEST_REAL_SIMILAR(dpa1[i].getPosition()[0],dpa2[i].getPosition()[0])
148
TEST_REAL_SIMILAR(dpa1[i].getIntensity(),dpa2[i].getIntensity())
152
START_SECTION([EXTRA] DefaultParamHandler::setParameters(...))
156
tmp.setValue("bounding_box:min", -1.0);
157
tmp.setValue("bounding_box:max", 4.0);
158
tmp.setValue("statistics:mean", 0.0 );
159
tmp.setValue("statistics:variance", 0.1);
160
tmp.setValue("lma:scale_factor", 1.0);
161
tmp.setValue("lma:standard_deviation", 2.0);
162
tmp.setValue("lma:expected_value", 3.0);
163
lm1.setParameters(tmp);
165
TEST_REAL_SIMILAR(lm1.getCenter(), 0.0)
167
TOLERANCE_ABSOLUTE(0.001)
168
TEST_REAL_SIMILAR(lm1.getIntensity(-1.0), 0.0269955);
169
TEST_REAL_SIMILAR(lm1.getIntensity(0.0), 0.0647588);
170
TEST_REAL_SIMILAR(lm1.getIntensity(1.0), 0.120985);
171
TEST_REAL_SIMILAR(lm1.getIntensity(2.0), 0.176033);
173
lm1.setInterpolationStep(0.2);
176
TEST_REAL_SIMILAR(lm1.getIntensity(-1.0), 0.0269955);
177
TEST_REAL_SIMILAR(lm1.getIntensity(0.0), 0.0647588);
178
TEST_REAL_SIMILAR(lm1.getIntensity(1.0), 0.120985);
179
TEST_REAL_SIMILAR(lm1.getIntensity(2.0), 0.176033);
181
TOLERANCE_ABSOLUTE(0.1)
182
tmp.setValue("lma:scale_factor", 10.0);
183
lm1.setParameters(tmp);
186
TEST_REAL_SIMILAR(lm1.getIntensity(-1.0), 0.269955);
187
TEST_REAL_SIMILAR(lm1.getIntensity(0.0), 0.647588);
188
TEST_REAL_SIMILAR(lm1.getIntensity(1.0), 1.20985);
189
TEST_REAL_SIMILAR(lm1.getIntensity(2.0), 1.76033);
192
START_SECTION((void setOffset(CoordinateType offset)))
197
tmp.setValue("bounding_box:min", 678.9);
198
tmp.setValue("bounding_box:max", 789.0);
199
tmp.setValue("statistics:mean", 680.1 );
200
tmp.setValue("statistics:variance", 2.0);
201
tmp.setValue("lma:scale_factor", 10.0);
202
tmp.setValue("lma:standard_deviation", 2.0);
203
tmp.setValue("lma:expected_value", 700.0);
204
lm1.setParameters(tmp);
205
lm1.setOffset(680.9);
208
lm2.setParameters(tmp);
209
lm2.setOffset(680.9);
211
TEST_EQUAL(lm1.getParameters(), lm2.getParameters())
212
TEST_REAL_SIMILAR(lm1.getCenter(), lm2.getCenter())
213
TEST_REAL_SIMILAR(lm1.getCenter(), 682.1)
215
std::vector<Peak1D> dpa1;
216
std::vector<Peak1D> dpa2;
217
lm1.getSamples(dpa1);
218
lm2.getSamples(dpa2);
220
TOLERANCE_ABSOLUTE(0.01)
221
TEST_EQUAL(dpa1.size(),dpa2.size())
222
ABORT_IF(dpa1.size()!=dpa2.size());
223
for (Size i=0; i<dpa1.size(); ++i)
225
TEST_REAL_SIMILAR(dpa1[i].getPosition()[0],dpa2[i].getPosition()[0])
226
TEST_REAL_SIMILAR(dpa1[i].getIntensity(),dpa2[i].getIntensity())
231
START_SECTION((CoordinateType getCenter() const))
232
// already test above, but just for the sake of it
233
TOLERANCE_ABSOLUTE(0.001)
237
tmp.setValue("bounding_box:min", 678.9);
238
tmp.setValue("bounding_box:max", 789.0);
239
tmp.setValue("statistics:mean", 680.1 );
240
tmp.setValue("statistics:variance", 2.0);
241
tmp.setValue("lma:scale_factor", 10.0);
242
tmp.setValue("lma:standard_deviation", 2.0);
243
tmp.setValue("lma:expected_value", 700.0);
244
lm1.setParameters(tmp);
245
lm1.setOffset(680.0);
247
TEST_REAL_SIMILAR(lm1.getCenter(), 681.2)
251
START_SECTION((void setSamples()))
259
/////////////////////////////////////////////////////////////
260
/////////////////////////////////////////////////////////////