ProteoWizard
Functions | Variables
PeakDetectorNaiveTest.cpp File Reference
#include "PeakDetectorNaive.hpp"
#include "pwiz/data/misc/FrequencyData.hpp"
#include "pwiz/data/misc/PeakData.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Functions

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

Variables

ostream * os_ = 0
 
FrequencyDatum data_ []
 
const unsigned int dataSize_ = sizeof(data_)/sizeof(FrequencyDatum)
 

Function Documentation

§ testCreation()

void testCreation ( )

Definition at line 39 of file PeakDetectorNaiveTest.cpp.

References pwiz::frequency::PeakDetectorNaive::detectionRadius(), pwiz::frequency::PeakDetectorNaive::noiseFactor(), and unit_assert.

Referenced by test().

40 {
41  const double noiseFactor = 666;
42  const unsigned int detectionRadius = 13;
43  auto_ptr<PeakDetectorNaive> pd = PeakDetectorNaive::create(noiseFactor, detectionRadius);
44  unit_assert(pd->noiseFactor() == noiseFactor);
45  unit_assert(pd->detectionRadius() == detectionRadius);
46 }
virtual unsigned int detectionRadius() const =0
virtual double noiseFactor() const =0
#define unit_assert(x)
Definition: unit.hpp:85

§ testFind()

void testFind ( )

Definition at line 70 of file PeakDetectorNaiveTest.cpp.

References pwiz::data::FrequencyData::analyze(), pwiz::data::FrequencyData::data(), dataSize_, pwiz::frequency::PeakDetectorNaive::findPeaks(), os_, pwiz::data::peakdata::PeakData::scans, and unit_assert.

Referenced by test().

71 {
72  FrequencyData fd;
73  copy(data_, data_+dataSize_, back_inserter(fd.data()));
74  if (os_) copy(fd.data().begin(), fd.data().end(), ostream_iterator<FrequencyDatum>(*os_, "\n"));
75  fd.analyze();
76 
77  PeakData pd;
78  pd.scans.resize(3);
79 
80  const double noiseFactor = 1;
81 
82  auto_ptr<PeakDetectorNaive> pdn1 = PeakDetectorNaive::create(noiseFactor, 1);
83  pdn1->findPeaks(fd, pd.scans[0]);
84  unit_assert(pd.scans[0].peakFamilies.size() == 3);
85 
86  auto_ptr<PeakDetectorNaive> pdn2 = PeakDetectorNaive::create(noiseFactor, 2);
87  pdn2->findPeaks(fd, pd.scans[1]);
88  unit_assert(pd.scans[1].peakFamilies.size() == 2);
89 
90  auto_ptr<PeakDetectorNaive> pdn3 = PeakDetectorNaive::create(noiseFactor, 3);
91  pdn3->findPeaks(fd, pd.scans[2]);
92  unit_assert(pd.scans[2].peakFamilies.size() == 1);
93 
94  if (os_)
95  {
96  *os_ << "pd:\n" << pd << endl;
97 
98  for (unsigned int i=0; i<pd.scans.size(); i++)
99  {
100  *os_ << "scan " << i << ":\n";
101  *os_ << pd.scans[i] << endl;
102  }
103  }
104 }
ostream * os_
Class for binary storage of complex frequency data.
const unsigned int dataSize_
void analyze()
recache statistics calculations after any direct data changes via non-const data() ...
virtual void findPeaks(const pwiz::data::FrequencyData &fd, pwiz::data::peakdata::Scan &result) const =0
Find the peaks in the frequency data, filling in Scan structure.
const container & data() const
const access to underlying data
std::vector< Scan > scans
Definition: PeakData.hpp:194
FrequencyDatum data_[]
#define unit_assert(x)
Definition: unit.hpp:85

§ test()

void test ( )

Definition at line 107 of file PeakDetectorNaiveTest.cpp.

References testCreation(), and testFind().

Referenced by main().

108 {
109  testCreation();
110  testFind();
111 }
void testFind()
void testCreation()

§ main()

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

Definition at line 114 of file PeakDetectorNaiveTest.cpp.

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

115 {
116  TEST_PROLOG(argc, argv)
117 
118  try
119  {
120  if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
121  if (os_) *os_ << "PeakDetectorNaiveTest\n";
122  test();
123  }
124  catch (exception& e)
125  {
126  TEST_FAILED(e.what())
127  }
128  catch (...)
129  {
130  TEST_FAILED("Caught unknown exception.")
131  }
132 
134 }
ostream * os_
void test()
#define TEST_EPILOG
Definition: unit.hpp:182
#define TEST_FAILED(x)
Definition: unit.hpp:176
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:174

Variable Documentation

§ os_

ostream* os_ = 0

Definition at line 36 of file PeakDetectorNaiveTest.cpp.

Referenced by main(), and testFind().

§ data_

FrequencyDatum data_[]
Initial value:
=
{
}
SampleDatum< double, std::complex< double > > FrequencyDatum

Definition at line 49 of file PeakDetectorNaiveTest.cpp.

§ dataSize_

const unsigned int dataSize_ = sizeof(data_)/sizeof(FrequencyDatum)

Definition at line 67 of file PeakDetectorNaiveTest.cpp.

Referenced by testFind().