~ubuntu-branches/ubuntu/wily/openms/wily

« back to all changes in this revision

Viewing changes to source/TEST/MapAlignmentAlgorithmSpectrumAlignment_test.C

  • Committer: Package Import Robot
  • Author(s): Filippo Rusconi
  • Date: 2012-11-12 15:58:12 UTC
  • Revision ID: package-import@ubuntu.com-20121112155812-vr15wtg9b50cuesg
Tags: upstream-1.9.0
ImportĀ upstreamĀ versionĀ 1.9.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
// -*- mode: C++; tab-width: 2; -*-
 
3
// vi: set ts=2:
 
4
//
 
5
// --------------------------------------------------------------------------
 
6
//                   OpenMS Mass Spectrometry Framework 
 
7
// --------------------------------------------------------------------------
 
8
//  Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
 
9
//
 
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.
 
14
//
 
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.
 
19
//
 
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
 
23
//
 
24
// --------------------------------------------------------------------------
 
25
// $Maintainer: Erhan Kenar $
 
26
// $Authors: Vipul Patel $
 
27
// --------------------------------------------------------------------------
 
28
 
 
29
#include <OpenMS/CONCEPT/ClassTest.h>
 
30
 
 
31
#include <OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmSpectrumAlignment.h>
 
32
 
 
33
using namespace std;
 
34
using namespace OpenMS;
 
35
 
 
36
 
 
37
/////////////////////////////////////////////////////////////
 
38
 
 
39
START_TEST(MapAlignmentAlgorithmSpectrumAlignment, "$Id: MapAlignmentAlgorithmSpectrumAlignment_test.C 8788 2011-09-10 20:44:01Z hendrikweisser $")
 
40
 
 
41
/////////////////////////////////////////////////////////////
 
42
/////////////////////////////////////////////////////////////
 
43
 
 
44
 
 
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)
 
51
END_SECTION
 
52
 
 
53
START_SECTION((virtual ~MapAlignmentAlgorithmSpectrumAlignment()))
 
54
        delete ptr;
 
55
END_SECTION
 
56
 
 
57
START_SECTION((static MapAlignmentAlgorithm* create()))
 
58
  TEST_NOT_EQUAL(MapAlignmentAlgorithmSpectrumAlignment::create(),base_nullPointer)
 
59
END_SECTION
 
60
 
 
61
START_SECTION((static String getProductName()))
 
62
        TEST_EQUAL(MapAlignmentAlgorithmSpectrumAlignment::getProductName(), "spectrum_alignment")
 
63
END_SECTION
 
64
 
 
65
START_SECTION((virtual void alignPeakMaps(std::vector< MSExperiment<> > &, std::vector< TransformationDescription > &)))
 
66
{
 
67
  MapAlignmentAlgorithmSpectrumAlignment ma;
 
68
  std::vector< MSExperiment<> > maps;
 
69
        PeakMap map1;
 
70
        PeakMap map2;   
 
71
        for (UInt i= 0; i< 15; ++i)
 
72
        {
 
73
                for (UInt j =1 ; j < 5; ++j)
 
74
                {
 
75
                        PeakSpectrum spectrum;
 
76
                        spectrum.setRT(i);
 
77
                        spectrum.setMSLevel(j);
 
78
                
 
79
                        for (Real mz=500.0; mz<=900; mz+=100.0)
 
80
                    { 
 
81
                                Peak1D peak;
 
82
                                peak.setMZ(mz+i);
 
83
                                peak.setIntensity(mz+i);
 
84
                                spectrum.push_back(peak);  
 
85
                    }
 
86
                    map1.push_back(spectrum);
 
87
                }
 
88
        }
 
89
        for (UInt i= 0; i< 15; ++i)
 
90
                {
 
91
                        for (UInt j =1 ; j < 5; ++j)
 
92
                        {
 
93
                                PeakSpectrum spectrum;
 
94
                                spectrum.setRT(i*1.2+200);
 
95
                                spectrum.setMSLevel(j);
 
96
                        
 
97
                                for (Real mz=500.0; mz<=900; mz+=100.0)
 
98
                            { 
 
99
                                        Peak1D peak;
 
100
                                        peak.setMZ(mz+i);
 
101
                                        peak.setIntensity(mz+i);
 
102
                                        spectrum.push_back(peak);  
 
103
                            }
 
104
                            map2.push_back(spectrum);
 
105
                        }
 
106
                }
 
107
        
 
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";
 
113
        Param params;
 
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)
 
120
  {
 
121
                if((maps[0])[i].getMSLevel() <2)
 
122
                {
 
123
                        TEST_REAL_SIMILAR(maps[0][i].getRT(), maps[1][i].getRT());
 
124
                }
 
125
  }
 
126
}
 
127
END_SECTION
 
128
 
 
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));
 
134
END_SECTION
 
135
 
 
136
/////////////////////////////////////////////////////////////
 
137
/////////////////////////////////////////////////////////////
 
138
END_TEST
 
139