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

« back to all changes in this revision

Viewing changes to source/TEST/SignalToNoiseEstimatorMeanIterative_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
// -*- mode: C++; tab-width: 2; -*-
 
2
// vi: set ts=2:
 
3
//
 
4
// --------------------------------------------------------------------------
 
5
//                   OpenMS Mass Spectrometry Framework
 
6
// --------------------------------------------------------------------------
 
7
//  Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
 
8
//
 
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.
 
13
//
 
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.
 
18
//
 
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
 
22
//
 
23
// --------------------------------------------------------------------------
 
24
// $Maintainer: Chris Bielow $
 
25
// $Authors: $
 
26
// --------------------------------------------------------------------------
 
27
 
 
28
#include <OpenMS/CONCEPT/ClassTest.h>
 
29
#include <OpenMS/FORMAT/DTAFile.h>
 
30
 
 
31
///////////////////////////
 
32
#include <OpenMS/FILTERING/NOISEESTIMATION/SignalToNoiseEstimatorMeanIterative.h>
 
33
///////////////////////////
 
34
 
 
35
using namespace OpenMS;
 
36
using namespace std;
 
37
 
 
38
#define DEBUG_TEST
 
39
#undef DEBUG_TEST
 
40
 
 
41
START_TEST(SignalToNoiseEstimatorMeanIterative, "$Id: SignalToNoiseEstimatorMeanIterative_test.C 8210 2011-03-28 13:19:52Z aiche $")
 
42
 
 
43
/////////////////////////////////////////////////////////////
 
44
/////////////////////////////////////////////////////////////
 
45
 
 
46
SignalToNoiseEstimatorMeanIterative< >* ptr = 0;
 
47
SignalToNoiseEstimatorMeanIterative< >* nullPointer = 0;
 
48
START_SECTION((SignalToNoiseEstimatorMeanIterative()))
 
49
        ptr = new SignalToNoiseEstimatorMeanIterative<>;
 
50
        TEST_NOT_EQUAL(ptr, nullPointer)
 
51
        SignalToNoiseEstimatorMeanIterative<> sne;
 
52
END_SECTION
 
53
 
 
54
 
 
55
 
 
56
START_SECTION((SignalToNoiseEstimatorMeanIterative& operator=(const SignalToNoiseEstimatorMeanIterative &source)))
 
57
  MSSpectrum < > raw_data;
 
58
  SignalToNoiseEstimatorMeanIterative<> sne;
 
59
        sne.init(raw_data);
 
60
  SignalToNoiseEstimatorMeanIterative<> sne2 = sne;
 
61
        NOT_TESTABLE
 
62
END_SECTION
 
63
 
 
64
START_SECTION((SignalToNoiseEstimatorMeanIterative(const SignalToNoiseEstimatorMeanIterative &source)))
 
65
  MSSpectrum < > raw_data;
 
66
  SignalToNoiseEstimatorMeanIterative<> sne;
 
67
        sne.init(raw_data);
 
68
  SignalToNoiseEstimatorMeanIterative<> sne2(sne);
 
69
        NOT_TESTABLE
 
70
END_SECTION
 
71
 
 
72
START_SECTION((virtual ~SignalToNoiseEstimatorMeanIterative()))
 
73
  delete ptr;
 
74
END_SECTION
 
75
 
 
76
 
 
77
START_SECTION([EXTRA](virtual void init(const PeakIterator& it_begin, const PeakIterator& it_end)))
 
78
 
 
79
        TOLERANCE_ABSOLUTE(0.5)
 
80
 
 
81
  MSSpectrum < > raw_data;
 
82
  MSSpectrum< >::const_iterator it;
 
83
  DTAFile dta_file;
 
84
  dta_file.load(OPENMS_GET_TEST_DATA_PATH("SignalToNoiseEstimator_test.dta"), raw_data);
 
85
  
 
86
    
 
87
  SignalToNoiseEstimatorMeanIterative<> sne;  
 
88
        Param p;
 
89
        p.setValue("win_len", 40.1);
 
90
        p.setValue("noise_for_empty_window", 2.0);
 
91
        p.setValue("min_required_elements", 10);
 
92
        sne.setParameters(p);
 
93
  sne.init(raw_data.begin(),raw_data.end());
 
94
 
 
95
  MSSpectrum < > stn_data;
 
96
  
 
97
#ifdef DEBUG_TEST
 
98
  MSSpectrum < > stn_data__;
 
99
#endif
 
100
  
 
101
  dta_file.load(OPENMS_GET_TEST_DATA_PATH("SignalToNoiseEstimatorMeanIterative_test.out"), stn_data);
 
102
  int i = 0;
 
103
  for (it=raw_data.begin();it!=raw_data.end(); ++it)
 
104
  {
 
105
    TEST_REAL_SIMILAR (stn_data[i].getIntensity(), sne.getSignalToNoise(it));
 
106
#ifdef DEBUG_TEST    
 
107
    Peak1D peak = (*it);
 
108
    peak.setIntensity(stn_data[i].getIntensity() / sne.getSignalToNoise(it));
 
109
    stn_data__.push_back(peak);
 
110
#endif    
 
111
    ++i;
 
112
  }
 
113
  
 
114
#ifdef DEBUG_TEST
 
115
  dta_file.store(OPENMS_GET_TEST_DATA_PATH("SignalToNoiseEstimatorMeanIterative_test.debug"), stn_data__);
 
116
#endif  
 
117
  
 
118
END_SECTION
 
119
 
 
120
 
 
121
/////////////////////////////////////////////////////////////
 
122
/////////////////////////////////////////////////////////////
 
123
END_TEST
 
124
 
 
125