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

Go to the source code of this file.

Functions

vector< vector< Peak > > createToyPeaks ()
 
void testToyExample ()
 
void test ()
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 

Function Documentation

§ createToyPeaks()

vector< vector<Peak> > createToyPeaks ( )

Definition at line 38 of file PeakelGrowerTest.cpp.

Referenced by testToyExample().

39 {
40  // rt\mz 1000 1001 1002
41  // 0 x x
42  // 1 x x x
43  // 2 x x
44  // 3 x x x
45  // 4 x x
46 
47  vector< vector<Peak> > peaks(5);
48  Peak peak;
49 
50  peak.retentionTime = 0;
51  peak.mz = 1000; peaks[0].push_back(peak);
52  peak.mz = 1002; peaks[0].push_back(peak);
53 
54  peak.retentionTime = 1;
55  peak.mz = 1000.01; peaks[1].push_back(peak);
56  peak.mz = 1001; peaks[1].push_back(peak);
57  peak.mz = 1002.01; peaks[1].push_back(peak);
58 
59  peak.retentionTime = 2;
60  peak.mz = 1001.01; peaks[2].push_back(peak);
61  peak.mz = 1002-.01; peaks[2].push_back(peak);
62 
63  peak.retentionTime = 3;
64  peak.mz = 1000; peaks[3].push_back(peak);
65  peak.mz = 1001-.01; peaks[3].push_back(peak);
66  peak.mz = 1002.02; peaks[3].push_back(peak);
67 
68  peak.retentionTime = 4;
69  peak.mz = 1000.01; peaks[4].push_back(peak);
70  peak.mz = 1002-.02; peaks[4].push_back(peak);
71 
72  return peaks;
73 }
represents some generic metadata about a peak detected in a signal

§ testToyExample()

void testToyExample ( )

Definition at line 76 of file PeakelGrowerTest.cpp.

References createToyPeaks(), epsilon, pwiz::analysis::PeakelGrower_Proximity::Config::mzTolerance, pwiz::analysis::PeakelGrower_Proximity::Config::rtTolerance, pwiz::analysis::PeakelGrower::sowPeaks(), unit_assert, and unit_assert_equal.

Referenced by test().

77 {
78  vector< vector<Peak> > peaks = createToyPeaks();
79 
81  config.mzTolerance = .1;
82  config.rtTolerance = 1.5;
83 
84  PeakelGrower_Proximity peakelGrower(config);
85 
86  PeakelField field;
87  peakelGrower.sowPeaks(field, peaks);
88 
89  const double epsilon = .1;
90  unit_assert(field.size() == 4);
91 
92  PeakelField::const_iterator it = field.begin();
93 
94  unit_assert_equal((*it)->mz, 1000, epsilon);
95  unit_assert_equal((*it)->retentionTime, 0, epsilon);
96 
97  ++it;
98  unit_assert_equal((*it)->mz, 1000, epsilon);
99  unit_assert_equal((*it)->retentionTime, 3, epsilon);
100 
101  ++it;
102  unit_assert_equal((*it)->mz, 1001, epsilon);
103  unit_assert_equal((*it)->retentionTime, 1, epsilon);
104 
105  ++it;
106  unit_assert_equal((*it)->mz, 1002, epsilon);
107  unit_assert_equal((*it)->retentionTime, 0, epsilon);
108 }
MZRTField is a std::set of boost::shared_ptrs, stored as a binary tree ordered by LessThan_MZRT...
Definition: MZRTField.hpp:94
const double epsilon
Definition: DiffTest.cpp:41
#define unit_assert_equal(x, y, epsilon)
Definition: unit.hpp:99
vector< vector< Peak > > createToyPeaks()
simple PeakelGrower implementation, based on proximity of Peaks
#define unit_assert(x)
Definition: unit.hpp:85

§ test()

void test ( )

Definition at line 111 of file PeakelGrowerTest.cpp.

References testToyExample().

Referenced by main().

112 {
113  testToyExample();
114 }
void testToyExample()

§ main()

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

Definition at line 117 of file PeakelGrowerTest.cpp.

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

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

Variable Documentation

§ os_

ostream* os_ = 0

Definition at line 35 of file PeakelGrowerTest.cpp.

Referenced by main().