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

void test ( )

Definition at line 170 of file PeakExtractorTest.cpp.

References epsilon, pwiz::analysis::PeakExtractor::extractPeaks(), pwiz::chemistry::Ion::mz(), 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.

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 
182  PeakFitter_Parabola::Config pfpConfig;
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 }
int main ( int  argc,
char *  argv[] 
)

Definition at line 206 of file PeakExtractorTest.cpp.

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

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 }

Variable Documentation

ostream* os_ = 0

Definition at line 36 of file PeakExtractorTest.cpp.

const double testData_[]

Definition at line 39 of file PeakExtractorTest.cpp.

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

Definition at line 167 of file PeakExtractorTest.cpp.