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

Go to the source code of this file.

Functions

shared_ptr< PeakelFieldcreateToyPeakelField ()
 
void testToy ()
 
void test ()
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 

Function Documentation

§ createToyPeakelField()

shared_ptr<PeakelField> createToyPeakelField ( )

Definition at line 38 of file PeakelPickerTest.cpp.

Referenced by testToy().

39 {
40  //
41  // 0 1 2
42  // |.....:.....|.....:.....|
43  // 10 x x o
44  // 20 x x o x
45  // 30 x x o x
46  // 40 x x o <-- feature z==3, noise Peakel at mono+.5
47  // 50
48  // 60 x x
49  // 70 x x x
50  // 80 x x x
51  // 90 x <-- feature z==2
52  //
53 
54  shared_ptr<PeakelField> toy(new PeakelField);
55 
56  PeakelPtr battery(new Peakel(Peak(0,10)));
57  battery->peaks.push_back(Peak(0, 20));
58  battery->peaks.push_back(Peak(0, 30));
59  battery->peaks.push_back(Peak(0, 40));
60  toy->insert(battery);
61 
62  battery.reset(new Peakel(Peak(1./3 + 1e-6, 10)));
63  battery->peaks.push_back(Peak(1./3, 20));
64  battery->peaks.push_back(Peak(1./3, 30));
65  battery->peaks.push_back(Peak(1./3, 40));
66  toy->insert(battery);
67 
68  battery.reset(new Peakel(Peak(.5, 10)));
69  battery->peaks.push_back(Peak(.5, 20));
70  battery->peaks.push_back(Peak(.5, 30));
71  battery->peaks.push_back(Peak(.5, 40));
72  toy->insert(battery);
73 
74  battery.reset(new Peakel(Peak(2./3, 20)));
75  battery->peaks.push_back(Peak(2./3, 30));
76  toy->insert(battery);
77 
78  battery.reset(new Peakel(Peak(1./3, 60)));
79  battery->peaks.push_back(Peak(1./3, 70));
80  battery->peaks.push_back(Peak(1./3, 80));
81  battery->peaks.push_back(Peak(1./3, 90));
82  toy->insert(battery);
83 
84  battery.reset(new Peakel(Peak(1./3 + .5, 60)));
85  battery->peaks.push_back(Peak(1./3 + .5, 70));
86  battery->peaks.push_back(Peak(1./3 + .5, 80));
87  toy->insert(battery);
88 
89  battery.reset(new Peakel(Peak(1./3 + 1, 70)));
90  battery->peaks.push_back(Peak(1./3 + 1, 80));
91  toy->insert(battery);
92 
93  return toy;
94 }
MZRTField is a std::set of boost::shared_ptrs, stored as a binary tree ordered by LessThan_MZRT...
Definition: MZRTField.hpp:94
boost::shared_ptr< Peakel > PeakelPtr
Definition: PeakData.hpp:242
represents some generic metadata about a peak detected in a signal
struct for an eluted peak (PEAK ELution)
Definition: PeakData.hpp:211

§ testToy()

void testToy ( )

Definition at line 97 of file PeakelPickerTest.cpp.

References createToyPeakelField(), pwiz::analysis::PeakelPicker_Basic::Config::log, os_, pwiz::analysis::PeakelPicker_Basic::pick(), unit_assert, and unit_assert_equal.

Referenced by test().

98 {
99  PeakelPicker_Basic::Config config; // TODO: specify parameters?
100 
101  if (os_)
102  {
103  *os_ << "testToy()\n";
104  config.log = os_;
105  }
106 
107  PeakelPicker_Basic peterPiper(config);
108 
109  shared_ptr<PeakelField> peakels = createToyPeakelField();
110  unit_assert(peakels->size() == 7);
111 
112  FeatureField peck;
113  peterPiper.pick(*peakels, peck);
114 
115  unit_assert(peck.size() == 2);
116  unit_assert(peakels->size() == 1);
117 
118  FeatureField::const_iterator it = peck.begin();
119  unit_assert((*it)->mz == 0);
120  unit_assert((*it)->charge == 3);
121  unit_assert_equal((*it)->retentionTime, 25, 20);
122 
123  ++it;
124  unit_assert((*it)->mz == 1./3);
125  unit_assert((*it)->charge == 2);
126  unit_assert_equal((*it)->retentionTime, 75, 20);
127 }
MZRTField is a std::set of boost::shared_ptrs, stored as a binary tree ordered by LessThan_MZRT...
Definition: MZRTField.hpp:94
ostream * os_
#define unit_assert_equal(x, y, epsilon)
Definition: unit.hpp:99
shared_ptr< PeakelField > createToyPeakelField()
#define unit_assert(x)
Definition: unit.hpp:85

§ test()

void test ( )

Definition at line 130 of file PeakelPickerTest.cpp.

References testToy().

Referenced by main().

131 {
132  testToy();
133 }
void testToy()

§ main()

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

Definition at line 136 of file PeakelPickerTest.cpp.

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

137 {
138  TEST_PROLOG(argc, argv)
139 
140  try
141  {
142  if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
143  test();
144  }
145  catch (exception& e)
146  {
147  TEST_FAILED(e.what())
148  }
149  catch (...)
150  {
151  TEST_FAILED("Caught unknown exception.")
152  }
153 
155 }
ostream * os_
#define TEST_EPILOG
Definition: unit.hpp:182
void test()
#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 35 of file PeakelPickerTest.cpp.

Referenced by main(), and testToy().