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

vector< vector<Peak> > createToyPeaks ( )

Definition at line 38 of file PeakelGrowerTest.cpp.

Referenced by testToyExample().

{
// rt\mz 1000 1001 1002
// 0 x x
// 1 x x x
// 2 x x
// 3 x x x
// 4 x x
vector< vector<Peak> > peaks(5);
Peak peak;
peak.retentionTime = 0;
peak.mz = 1000; peaks[0].push_back(peak);
peak.mz = 1002; peaks[0].push_back(peak);
peak.retentionTime = 1;
peak.mz = 1000.01; peaks[1].push_back(peak);
peak.mz = 1001; peaks[1].push_back(peak);
peak.mz = 1002.01; peaks[1].push_back(peak);
peak.retentionTime = 2;
peak.mz = 1001.01; peaks[2].push_back(peak);
peak.mz = 1002-.01; peaks[2].push_back(peak);
peak.retentionTime = 3;
peak.mz = 1000; peaks[3].push_back(peak);
peak.mz = 1001-.01; peaks[3].push_back(peak);
peak.mz = 1002.02; peaks[3].push_back(peak);
peak.retentionTime = 4;
peak.mz = 1000.01; peaks[4].push_back(peak);
peak.mz = 1002-.02; peaks[4].push_back(peak);
return peaks;
}
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().

{
vector< vector<Peak> > peaks = createToyPeaks();
config.mzTolerance = .1;
config.rtTolerance = 1.5;
PeakelGrower_Proximity peakelGrower(config);
PeakelField field;
peakelGrower.sowPeaks(field, peaks);
const double epsilon = .1;
unit_assert(field.size() == 4);
PeakelField::const_iterator it = field.begin();
unit_assert_equal((*it)->mz, 1000, epsilon);
unit_assert_equal((*it)->retentionTime, 0, epsilon);
++it;
unit_assert_equal((*it)->mz, 1000, epsilon);
unit_assert_equal((*it)->retentionTime, 3, epsilon);
++it;
unit_assert_equal((*it)->mz, 1001, epsilon);
unit_assert_equal((*it)->retentionTime, 1, epsilon);
++it;
unit_assert_equal((*it)->mz, 1002, epsilon);
unit_assert_equal((*it)->retentionTime, 0, epsilon);
}
void test ( )

Definition at line 111 of file PeakelGrowerTest.cpp.

References testToyExample().

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

Definition at line 117 of file PeakelGrowerTest.cpp.

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

{
TEST_PROLOG(argc, argv)
try
{
if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
test();
}
catch (exception& e)
{
TEST_FAILED(e.what())
}
catch (...)
{
TEST_FAILED("Caught unknown exception.")
}
}

Variable Documentation

ostream* os_ = 0

Definition at line 35 of file PeakelGrowerTest.cpp.