2
// -*- mode: C++; tab-width: 2; -*-
5
// --------------------------------------------------------------------------
6
// OpenMS Mass Spectrometry Framework
7
// --------------------------------------------------------------------------
8
// Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
10
// This library is free software; you can redistribute it and/or
11
// modify it under the terms of the GNU Lesser General Public
12
// License as published by the Free Software Foundation; either
13
// version 2.1 of the License, or (at your option) any later version.
15
// This library is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
// Lesser General Public License for more details.
20
// You should have received a copy of the GNU Lesser General Public
21
// License along with this library; if not, write to the Free Software
22
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
// --------------------------------------------------------------------------
25
// $Maintainer: Erhan Kenar $
26
// $Authors: Vipul Patel $
27
// --------------------------------------------------------------------------
29
#include <OpenMS/CONCEPT/ClassTest.h>
31
#include <OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmSpectrumAlignment.h>
34
using namespace OpenMS;
37
/////////////////////////////////////////////////////////////
39
START_TEST(MapAlignmentAlgorithmSpectrumAlignment, "$Id: MapAlignmentAlgorithmSpectrumAlignment_test.C 8788 2011-09-10 20:44:01Z hendrikweisser $")
41
/////////////////////////////////////////////////////////////
42
/////////////////////////////////////////////////////////////
45
MapAlignmentAlgorithmSpectrumAlignment* ptr = 0;
46
MapAlignmentAlgorithmSpectrumAlignment* nullPointer = 0;
47
MapAlignmentAlgorithm* base_nullPointer = 0;
48
START_SECTION((MapAlignmentAlgorithmSpectrumAlignment()))
49
ptr = new MapAlignmentAlgorithmSpectrumAlignment();
50
TEST_NOT_EQUAL(ptr, nullPointer)
53
START_SECTION((virtual ~MapAlignmentAlgorithmSpectrumAlignment()))
57
START_SECTION((static MapAlignmentAlgorithm* create()))
58
TEST_NOT_EQUAL(MapAlignmentAlgorithmSpectrumAlignment::create(),base_nullPointer)
61
START_SECTION((static String getProductName()))
62
TEST_EQUAL(MapAlignmentAlgorithmSpectrumAlignment::getProductName(), "spectrum_alignment")
65
START_SECTION((virtual void alignPeakMaps(std::vector< MSExperiment<> > &, std::vector< TransformationDescription > &)))
67
MapAlignmentAlgorithmSpectrumAlignment ma;
68
std::vector< MSExperiment<> > maps;
71
for (UInt i= 0; i< 15; ++i)
73
for (UInt j =1 ; j < 5; ++j)
75
PeakSpectrum spectrum;
77
spectrum.setMSLevel(j);
79
for (Real mz=500.0; mz<=900; mz+=100.0)
83
peak.setIntensity(mz+i);
84
spectrum.push_back(peak);
86
map1.push_back(spectrum);
89
for (UInt i= 0; i< 15; ++i)
91
for (UInt j =1 ; j < 5; ++j)
93
PeakSpectrum spectrum;
94
spectrum.setRT(i*1.2+200);
95
spectrum.setMSLevel(j);
97
for (Real mz=500.0; mz<=900; mz+=100.0)
101
peak.setIntensity(mz+i);
102
spectrum.push_back(peak);
104
map2.push_back(spectrum);
108
maps.push_back(map1);
109
maps.push_back(map2);
110
std::vector<TransformationDescription> transformations;
111
ma.alignPeakMaps(maps, transformations);
112
String model_type = "interpolated";
114
params.setValue("interpolation_type", "cspline");
115
ma.fitModel(model_type, params, transformations);
116
ma.transformPeakMaps(maps, transformations);
117
maps[0].updateRanges(-1);
118
maps[1].updateRanges(-1);
119
for (Size i=0; i< maps[0].size(); ++i)
121
if((maps[0])[i].getMSLevel() <2)
123
TEST_REAL_SIMILAR(maps[0][i].getRT(), maps[1][i].getRT());
129
START_SECTION([EXTRA] void alignFeatureMaps(std::vector< FeatureMap<> >&))
130
MapAlignmentAlgorithmSpectrumAlignment ma;
131
std::vector< FeatureMap<> > maps;
132
std::vector<TransformationDescription> transformations;
133
TEST_EXCEPTION(Exception::NotImplemented, ma.alignFeatureMaps(maps,transformations));
136
/////////////////////////////////////////////////////////////
137
/////////////////////////////////////////////////////////////