ProteoWizard
Functions | Variables
PeakFinderTest.cpp File Reference
#include "PeakFinder.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 addSignal (OrderedPair *p)
 
vector< double > createTestData ()
 
void test_SNR ()
 
void test ()
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 
double testNoise_ []
 

Function Documentation

◆ addSignal()

void addSignal ( OrderedPair p)

Definition at line 53 of file PeakFinderTest.cpp.

54{
55 (p-2)->y += 3;
56 (p-1)->y += 5;
57 p->y += 6;
58 (p+1)->y += 5;
59 (p+2)->y += 3;
60}
KernelTraitsBase< Kernel >::space_type::ordinate_type y

References y, and pwiz::math::OrderedPair::y.

Referenced by createTestData().

◆ createTestData()

vector< double > createTestData ( )

Definition at line 63 of file PeakFinderTest.cpp.

64{
65 vector<double> data;
66 copy(testNoise_, testNoise_+sizeof(testNoise_)/sizeof(double), back_inserter(data));
67
68 addSignal((OrderedPair*)&data[50]);
69 addSignal((OrderedPair*)&data[100]);
70 addSignal((OrderedPair*)&data[150]);
71
72 return data;
73}
void addSignal(OrderedPair *p)
double testNoise_[]

References addSignal(), and testNoise_.

Referenced by test_SNR().

◆ test_SNR()

void test_SNR ( )

Definition at line 76 of file PeakFinderTest.cpp.

77{
78 if (os_) *os_ << "test_SNR()\n";
79
80 shared_ptr<NoiseCalculator> noiseCalculator(new NoiseCalculator_2Pass);
81
83 config.windowRadius = 2;
84 config.log = os_;
85
86 PeakFinder_SNR peakFinder(noiseCalculator, config);
87
88 vector<double> data = createTestData();
89 vector<size_t> peakIndices;
90
91 peakFinder.findPeaks(data, peakIndices);
92
93 if (os_)
94 {
95 *os_ << "peakIndices: " << peakIndices.size() << endl;
96 copy(peakIndices.begin(), peakIndices.end(), ostream_iterator<size_t>(*os_, "\n"));
97 }
98
99 unit_assert(peakIndices.size() == 3);
100 unit_assert(peakIndices[0] == 25);
101 unit_assert(peakIndices[1] == 50);
102 unit_assert(peakIndices[2] == 75);
103}
vector< double > createTestData()
ostream * os_
PeakFinder implementation based on signal-to-noise ratio.
#define unit_assert(x)
Definition unit.hpp:85

References createTestData(), pwiz::analysis::PeakFinder_SNR::findPeaks(), pwiz::analysis::PeakFinder_SNR::Config::log, os_, unit_assert, and pwiz::analysis::PeakFinder_SNR::Config::windowRadius.

Referenced by test().

◆ test()

void test ( )

Definition at line 106 of file PeakFinderTest.cpp.

107{
108 test_SNR();
109}
void test_SNR()

References test_SNR().

Referenced by main().

◆ main()

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

Definition at line 112 of file PeakFinderTest.cpp.

113{
114 TEST_PROLOG(argc, argv)
115
116 try
117 {
118 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
119 test();
120 }
121 catch (exception& e)
122 {
123 TEST_FAILED(e.what())
124 }
125 catch (...)
126 {
127 TEST_FAILED("Caught unknown exception.")
128 }
129
131}
void test()
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175

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

Variable Documentation

◆ os_

ostream* os_ = 0

Definition at line 35 of file PeakFinderTest.cpp.

Referenced by main(), and test_SNR().

◆ testNoise_

double testNoise_[]
Initial value:
=
{
0, 10.2134, 1, 9.50442, 2, 11.5754, 3, 8.9408, 4, 11.8393, 5, 11.8858, 6, 10.6047, 7, 9.63402, 8, 9.42174, 9, 9.36562,
10, 11.0297, 11, 10.7241, 12, 9.88493, 13, 10.6358, 14, 6.99061, 15, 9.08698, 16, 13.2407, 17, 9.11359, 18, 12.5566, 19, 9.42665,
20, 10.8823, 21, 11.3452, 22, 12.7695, 23, 9.48237, 24, 10.4651, 25, 9.87172, 26, 8.21869, 27, 10.1641, 28, 10.2608, 29, 9.20198,
30, 10.0615, 31, 10.0762, 32, 9.56936, 33, 10.2306, 34, 11.2333, 35, 9.27828, 36, 10.5381, 37, 8.01883, 38, 11.1455, 39, 9.70199,
40, 9.00168, 41, 8.51621, 42, 10.9232, 43, 10.2107, 44, 10.4026, 45, 9.43944, 46, 11.3842, 47, 9.39058, 48, 9.56328, 49, 9.09075,
50, 10.0799, 51, 8.35904, 52, 9.95105, 53, 8.86625, 54, 9.18384, 55, 10.6562, 56, 9.65414, 57, 9.48778, 58, 10.4029, 59, 10.746,
60, 9.51285, 61, 8.28112, 62, 10.8551, 63, 10.1733, 64, 9.65835, 65, 12.0004, 66, 10.5445, 67, 10.1626, 68, 12.6242, 69, 11.8353,
70, 10.8273, 71, 8.33673, 72, 9.82429, 73, 9.51358, 74, 9.30484, 75, 11.55, 76, 11.1051, 77, 9.64263, 78, 11.4417, 79, 10.317,
80, 9.51919, 81, 10.1948, 82, 9.49461, 83, 10.4654, 84, 10.0316, 85, 9.67727, 86, 10.0763, 87, 9.73844, 88, 10.396, 89, 10.9456,
90, 8.89552, 91, 10.0711, 92, 8.91056, 93, 10.3877, 94, 8.92218, 95, 8.58656, 96, 9.43114, 97, 7.82059, 98, 10.0535, 99, 8.1854
}

Definition at line 38 of file PeakFinderTest.cpp.

39{
40 0, 10.2134, 1, 9.50442, 2, 11.5754, 3, 8.9408, 4, 11.8393, 5, 11.8858, 6, 10.6047, 7, 9.63402, 8, 9.42174, 9, 9.36562,
41 10, 11.0297, 11, 10.7241, 12, 9.88493, 13, 10.6358, 14, 6.99061, 15, 9.08698, 16, 13.2407, 17, 9.11359, 18, 12.5566, 19, 9.42665,
42 20, 10.8823, 21, 11.3452, 22, 12.7695, 23, 9.48237, 24, 10.4651, 25, 9.87172, 26, 8.21869, 27, 10.1641, 28, 10.2608, 29, 9.20198,
43 30, 10.0615, 31, 10.0762, 32, 9.56936, 33, 10.2306, 34, 11.2333, 35, 9.27828, 36, 10.5381, 37, 8.01883, 38, 11.1455, 39, 9.70199,
44 40, 9.00168, 41, 8.51621, 42, 10.9232, 43, 10.2107, 44, 10.4026, 45, 9.43944, 46, 11.3842, 47, 9.39058, 48, 9.56328, 49, 9.09075,
45 50, 10.0799, 51, 8.35904, 52, 9.95105, 53, 8.86625, 54, 9.18384, 55, 10.6562, 56, 9.65414, 57, 9.48778, 58, 10.4029, 59, 10.746,
46 60, 9.51285, 61, 8.28112, 62, 10.8551, 63, 10.1733, 64, 9.65835, 65, 12.0004, 66, 10.5445, 67, 10.1626, 68, 12.6242, 69, 11.8353,
47 70, 10.8273, 71, 8.33673, 72, 9.82429, 73, 9.51358, 74, 9.30484, 75, 11.55, 76, 11.1051, 77, 9.64263, 78, 11.4417, 79, 10.317,
48 80, 9.51919, 81, 10.1948, 82, 9.49461, 83, 10.4654, 84, 10.0316, 85, 9.67727, 86, 10.0763, 87, 9.73844, 88, 10.396, 89, 10.9456,
49 90, 8.89552, 91, 10.0711, 92, 8.91056, 93, 10.3877, 94, 8.92218, 95, 8.58656, 96, 9.43114, 97, 7.82059, 98, 10.0535, 99, 8.1854
50}; // testNoise_

Referenced by createTestData().