ProteoWizard
Functions | Variables
PeakDetectorMatchedFilterTest.cpp File Reference
#include "PeakDetectorMatchedFilter.hpp"
#include "PeakDetectorMatchedFilterTestData.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Functions

void initializeWithTestData (FrequencyData &fd)
void testCreation (const IsotopeEnvelopeEstimator &isotopeEnvelopeEstimator)
void testFind (FrequencyData &fd, const IsotopeEnvelopeEstimator &isotopeEnvelopeEstimator)
auto_ptr
< IsotopeEnvelopeEstimator
createIsotopeEnvelopeEstimator ()
void test ()
int main (int argc, char *argv[])

Variables

ostream * os_ = 0

Function Documentation

void initializeWithTestData ( FrequencyData fd)
void testCreation ( const IsotopeEnvelopeEstimator isotopeEnvelopeEstimator)

Definition at line 53 of file PeakDetectorMatchedFilterTest.cpp.

References pwiz::frequency::PeakDetectorMatchedFilter::config(), pwiz::frequency::PeakDetectorMatchedFilter::Config::filterMatchRate, pwiz::frequency::PeakDetectorMatchedFilter::Config::filterSampleRadius, pwiz::frequency::PeakDetectorMatchedFilter::Config::isotopeEnvelopeEstimator, pwiz::frequency::PeakDetectorMatchedFilter::Config::isotopeThresholdFactor, pwiz::frequency::PeakDetectorMatchedFilter::Config::monoisotopicPeakThresholdFactor, os_, pwiz::frequency::PeakDetectorMatchedFilter::Config::peakMaxCorrelationAngle, pwiz::frequency::PeakDetectorMatchedFilter::Config::peakThresholdFactor, and unit_assert.

Referenced by test().

{
if (os_) *os_ << "testCreation()\n";
const int filterMatchRate = 4;
const int filterSampleRadius = 2;
const double peakThresholdFactor = 0;
const double peakMaxCorrelationAngle = 5;
const double isotopeThresholdFactor = 666;
const double monoisotopicPeakThresholdFactor = 777;
config.isotopeEnvelopeEstimator = &isotopeEnvelopeEstimator;
config.filterMatchRate = filterMatchRate;
config.filterSampleRadius = filterSampleRadius;
config.peakThresholdFactor = peakThresholdFactor;
config.peakMaxCorrelationAngle = peakMaxCorrelationAngle;
config.isotopeThresholdFactor = isotopeThresholdFactor;
config.monoisotopicPeakThresholdFactor = monoisotopicPeakThresholdFactor;
auto_ptr<PeakDetectorMatchedFilter> pd = PeakDetectorMatchedFilter::create(config);
unit_assert(pd->config().filterMatchRate == filterMatchRate);
unit_assert(pd->config().filterSampleRadius == filterSampleRadius);
unit_assert(pd->config().peakThresholdFactor == peakThresholdFactor);
unit_assert(pd->config().peakMaxCorrelationAngle == peakMaxCorrelationAngle);
unit_assert(pd->config().isotopeThresholdFactor == isotopeThresholdFactor);
unit_assert(pd->config().monoisotopicPeakThresholdFactor == monoisotopicPeakThresholdFactor);
}
void testFind ( FrequencyData fd,
const IsotopeEnvelopeEstimator isotopeEnvelopeEstimator 
)

Definition at line 83 of file PeakDetectorMatchedFilterTest.cpp.

References pwiz::frequency::PeakDetectorMatchedFilter::Config::collapseRadius, e(), pwiz::frequency::PeakDetectorMatchedFilter::Config::filterMatchRate, pwiz::frequency::PeakDetectorMatchedFilter::Config::filterSampleRadius, pwiz::frequency::PeakDetectorMatchedFilter::findPeaks(), pwiz::frequency::PeakDetectorMatchedFilter::Config::isotopeEnvelopeEstimator, pwiz::frequency::PeakDetectorMatchedFilter::Config::isotopeMaxChargeState, pwiz::frequency::PeakDetectorMatchedFilter::Config::isotopeMaxNeutronCount, pwiz::frequency::PeakDetectorMatchedFilter::Config::isotopeThresholdFactor, pwiz::frequency::PeakDetectorMatchedFilter::Config::log, pwiz::frequency::PeakDetectorMatchedFilter::Config::logDetailLevel, pwiz::frequency::PeakDetectorMatchedFilter::Config::monoisotopicPeakThresholdFactor, norm(), os_, pwiz::frequency::PeakDetectorMatchedFilter::Config::peakMaxCorrelationAngle, pwiz::frequency::PeakDetectorMatchedFilter::Config::peakThresholdFactor, pwiz::data::peakdata::PeakData::scans, unit_assert, unit_assert_equal, and pwiz::frequency::PeakDetectorMatchedFilter::Config::useMagnitudeFilter.

Referenced by main(), test(), and testThreadSafetyWorker().

{
if (os_) *os_ << "testFind()\n";
// fill in config structure
config.isotopeEnvelopeEstimator = &isotopeEnvelopeEstimator;
config.filterMatchRate = 4;
config.filterSampleRadius = 2;
config.peakThresholdFactor = 2;
config.collapseRadius = 15;
config.useMagnitudeFilter = false;
config.logDetailLevel = 1;
config.log = os_;
// instantiate
auto_ptr<PeakDetectorMatchedFilter> pd = PeakDetectorMatchedFilter::create(config);
// find peaks
PeakData data;
data.scans.push_back(Scan());
vector<PeakDetectorMatchedFilter::Score> scores;
pd->findPeaks(fd, data.scans[0], scores);
// report results
if (os_)
{
*os_ << "peaks found: " << data.scans[0].peakFamilies.size() << endl;
*os_ << data.scans[0];
*os_ << "scores: " << scores.size() << endl;
copy(scores.begin(), scores.end(),
ostream_iterator<PeakDetectorMatchedFilter::Score>(*os_, "\n"));
}
// assertions
unit_assert(data.scans[0].peakFamilies.size() == 1);
const PeakFamily& peakFamily = data.scans[0].peakFamilies.back();
if (os_) *os_ << "peakFamily: " << peakFamily << endl;
unit_assert(peakFamily.peaks.size() > 1);
const Peak& peak = peakFamily.peaks[0];
unit_assert_equal(peak.getAttribute(Peak::Attribute_Frequency), 159455, 1);
unit_assert(peakFamily.charge == 2);
unit_assert(scores.size() == 1);
const PeakDetectorMatchedFilter::Score& score = scores.back();
unit_assert(score.charge == peakFamily.charge);
unit_assert(score.monoisotopicFrequency == peak.getAttribute(Peak::Attribute_Frequency));
unit_assert_equal(norm(score.monoisotopicIntensity -
polar(peak.intensity, peak.getAttribute(Peak::Attribute_Phase))),
0, 1e-14);
}
auto_ptr<IsotopeEnvelopeEstimator> createIsotopeEnvelopeEstimator ( )

Definition at line 142 of file PeakDetectorMatchedFilterTest.cpp.

References pwiz::chemistry::IsotopeEnvelopeEstimator::Config::isotopeCalculator.

Referenced by test().

{
const double abundanceCutoff = .01;
const double massPrecision = .1;
IsotopeCalculator isotopeCalculator(abundanceCutoff, massPrecision);
config.isotopeCalculator = &isotopeCalculator;
return auto_ptr<IsotopeEnvelopeEstimator>(new IsotopeEnvelopeEstimator(config));
}
void test ( )

Definition at line 155 of file PeakDetectorMatchedFilterTest.cpp.

References createIsotopeEnvelopeEstimator(), initializeWithTestData(), os_, testCreation(), and testFind().

{
if (os_) *os_ << setprecision(12);
auto_ptr<IsotopeEnvelopeEstimator> isotopeEnvelopeEstimator = createIsotopeEnvelopeEstimator();
testCreation(*isotopeEnvelopeEstimator);
testFind(fd, *isotopeEnvelopeEstimator);
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 170 of file PeakDetectorMatchedFilterTest.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;
if (os_) *os_ << "PeakDetectorMatchedFilterTest\n";
test();
}
catch (exception& e)
{
TEST_FAILED(e.what())
}
catch (...)
{
TEST_FAILED("Caught unknown exception.")
}
}

Variable Documentation

ostream* os_ = 0

Definition at line 38 of file PeakDetectorMatchedFilterTest.cpp.