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.

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.

Referenced by main().

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 }
const double testData_[]
const double epsilon
Definition: DiffTest.cpp:41
#define unit_assert_equal(x, y, epsilon)
Definition: unit.hpp:99
PeakFitter implementation based on fitting a parabola.
Definition: PeakFitter.hpp:61
ostream * os_
Class for extracting Peak objects from an array of ordered pairs; in design pattern lingo...
double mz(double neutralMass, int protonDelta, int electronDelta=0, int neutronDelta=0)
Definition: Ion.hpp:78
PeakFinder implementation based on signal-to-noise ratio.
Definition: PeakFinder.hpp:52
wrapper class for accessing contiguous data as a container of OrderedPairs; note that it does not own...
Definition: OrderedPair.hpp:83
#define unit_assert(x)
Definition: unit.hpp:85
const size_t testDataSize_

§ main()

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 }
#define TEST_EPILOG
Definition: unit.hpp:182
ostream * os_
#define TEST_FAILED(x)
Definition: unit.hpp:176
void test()
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:174

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.

Referenced by test().

§ testDataSize_

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

Definition at line 167 of file PeakExtractorTest.cpp.

Referenced by test().