ProteoWizard
Functions | Variables
PeakExtractorTest.cpp File Reference
#include "PeakExtractor.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include <cstring>

Go to the source code of this file.

Functions

void test ()
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 
const double testData_ []
 
const size_t testDataSize_ = sizeof(testData_)/sizeof(double)
 

Function Documentation

◆ test()

void test ( )

Definition at line 170 of file PeakExtractorTest.cpp.

171{
172 if (os_) *os_ << "test()\n";
173
174 shared_ptr<NoiseCalculator> noiseCalculator(new NoiseCalculator_2Pass);
175
176 PeakFinder_SNR::Config pfsnrConfig;
177 pfsnrConfig.windowRadius = 2;
178 pfsnrConfig.zValueThreshold = 2;
179
180 shared_ptr<PeakFinder> peakFinder(new PeakFinder_SNR(noiseCalculator, pfsnrConfig));
181
183 pfpConfig.windowRadius = 1; // (windowRadius != 1) is not good for real data
184 shared_ptr<PeakFitter> peakFitter(new PeakFitter_Parabola(pfpConfig));
185
186 PeakExtractor peakExtractor(peakFinder, peakFitter);
187
189 vector<Peak> peaks;
190 peakExtractor.extractPeaks(data, peaks);
191
192 if (os_)
193 {
194 *os_ << "peaks: " << peaks.size() << endl;
195 copy(peaks.begin(), peaks.end(), ostream_iterator<Peak>(*os_, "\n"));
196 }
197
198 const double epsilon = .01;
199 unit_assert(peaks.size() == 3);
200 unit_assert_equal(peaks[0].mz, 810.41, epsilon);
201 unit_assert_equal(peaks[1].mz, 810.91, epsilon);
202 unit_assert_equal(peaks[2].mz, 811.41, epsilon);
203}
const double testData_[]
const size_t testDataSize_
ostream * os_
Class for extracting Peak objects from an array of ordered pairs; in design pattern lingo,...
PeakFinder implementation based on signal-to-noise ratio.
PeakFitter implementation based on fitting a parabola.
wrapper class for accessing contiguous data as a container of OrderedPairs; note that it does not own...
const double epsilon
Definition DiffTest.cpp:41
#define unit_assert(x)
Definition unit.hpp:85
#define unit_assert_equal(x, y, epsilon)
Definition unit.hpp:99

References epsilon, pwiz::analysis::PeakExtractor::extractPeaks(), os_, testData_, testDataSize_, unit_assert, unit_assert_equal, pwiz::analysis::PeakFinder_SNR::Config::windowRadius, pwiz::analysis::PeakFitter_Parabola::Config::windowRadius, and pwiz::analysis::PeakFinder_SNR::Config::zValueThreshold.

Referenced by main().

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 206 of file PeakExtractorTest.cpp.

207{
208 TEST_PROLOG(argc, argv)
209
210 try
211 {
212 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
213 test();
214 }
215 catch (exception& e)
216 {
217 TEST_FAILED(e.what())
218 }
219 catch (...)
220 {
221 TEST_FAILED("Caught unknown exception.")
222 }
223
225}
void test()
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175

References os_, test(), TEST_EPILOG, TEST_FAILED, and TEST_PROLOG.

Variable Documentation

◆ os_

ostream* os_ = 0

Definition at line 36 of file PeakExtractorTest.cpp.

Referenced by main(), and test().

◆ testData_

const double testData_[]

Definition at line 39 of file PeakExtractorTest.cpp.

40{
41 807.9820, 0.0000,
42 807.9860, 0.0000,
43 807.9899, 0.0000,
44 807.9939, 0.0000,
45 808.9221, 0.0000,
46 808.9261, 0.0000,
47 808.9300, 0.0000,
48 808.9340, 0.0000,
49 808.9379, 46.1869,
50 808.9419, 68.1574,
51 808.9459, 74.2945,
52 808.9498, 67.5736,
53 808.9538, 55.4186,
54 808.9577, 0.0000,
55 808.9617, 0.0000,
56 808.9656, 0.0000,
57 808.9696, 0.0000,
58 810.3800, 0.0000,
59 810.3840, 0.0000,
60 810.3880, 0.0000,
61 810.3919, 0.0000,
62 810.3959, 0.0000,
63 810.3999, 72.5160,
64 810.4038, 450.4998,
65 810.4078, 1138.1459,
66 810.4118, 1834.3859,
67 810.4158, 2075.0105,
68 810.4197, 1699.1493,
69 810.4237, 1021.4493,
70 810.4277, 500.8886,
71 810.4316, 276.2554,
72 810.4356, 179.6894,
73 810.4396, 127.4826,
74 810.4435, 91.4053,
75 810.4475, 55.3596,
76 810.4515, 0.0000,
77 810.4554, 0.0000,
78 810.4594, 0.0000,
79 810.4634, 0.0000,
80 810.8248, 0.0000,
81 810.8288, 0.0000,
82 810.8327, 0.0000,
83 810.8367, 0.0000,
84 810.8407, 32.4939,
85 810.8447, 66.3772,
86 810.8486, 89.7902,
87 810.8526, 70.5686,
88 810.8566, 16.7061,
89 810.8605, 0.0000,
90 810.8645, 32.4340,
91 810.8685, 71.6267,
92 810.8725, 91.5372,
93 810.8764, 81.2383,
94 810.8804, 52.8255,
95 810.8844, 0.0000,
96 810.8884, 0.0000,
97 810.8923, 0.0000,
98 810.8963, 0.0000,
99 810.9003, 0.0000,
100 810.9043, 54.5496,
101 810.9082, 532.4702,
102 810.9122, 1171.1777,
103 810.9162, 1586.9846,
104 810.9202, 1490.4944,
105 810.9241, 979.2804,
106 810.9281, 434.2267,
107 810.9321, 162.3475,
108 810.9361, 128.5575,
109 810.9400, 134.1554,
110 810.9440, 123.5086,
111 810.9480, 88.7253,
112 810.9520, 48.2328,
113 810.9559, 0.0000,
114 810.9599, 0.0000,
115 810.9639, 0.0000,
116 810.9678, 0.0000,
117 811.3854, 0.0000,
118 811.3894, 0.0000,
119 811.3934, 0.0000,
120 811.3973, 0.0000,
121 811.4013, 9.2748,
122 811.4053, 133.5402,
123 811.4093, 298.1690,
124 811.4132, 463.7706,
125 811.4172, 554.1553,
126 811.4212, 503.8234,
127 811.4252, 333.9661,
128 811.4292, 149.2269,
129 811.4331, 48.4688,
130 811.4371, 0.0000,
131 811.4411, 0.0000,
132 811.4451, 0.0000,
133 811.4491, 0.0000,
134 811.7675, 0.0000,
135 811.7715, 0.0000,
136 811.7755, 0.0000,
137 811.7795, 0.0000,
138 811.7835, 41.8127,
139 811.7874, 69.9106,
140 811.7914, 87.5734,
141 811.7954, 91.7424,
142 811.7994, 90.7267,
143 811.8034, 87.8043,
144 811.8074, 74.6657,
145 811.8113, 46.1904,
146 811.8153, 0.0000,
147 811.8193, 0.0000,
148 811.8233, 0.0000,
149 811.8273, 0.0000,
150 812.3853, 0.0000,
151 812.3893, 0.0000,
152 812.3933, 0.0000,
153 812.3972, 0.0000,
154 812.4012, 23.7360,
155 812.4052, 85.1701,
156 812.4092, 124.7133,
157 812.4132, 118.7524,
158 812.4172, 69.4944,
159 812.4212, 9.8729,
160 812.4252, 0.0000,
161 812.4292, 0.0000,
162 812.4331, 0.0000,
163 812.4371, 0.0000
164};

Referenced by test().

◆ testDataSize_

const size_t testDataSize_ = sizeof(testData_)/sizeof(double)

Definition at line 167 of file PeakExtractorTest.cpp.

Referenced by test().