ProteoWizard
Functions | Variables
FeatureDetectorPeakelTest.cpp File Reference
#include "FeatureDetectorPeakel.hpp"
#include "pwiz/data/msdata/MSDataFile.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "boost/filesystem/path.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Functions

void verifyBombesinFeatures (const FeatureField &featureField)
shared_ptr< FeatureDetectorPeakelcreateFeatureDetectorPeakel ()
void testBombesin (const string &filename)
void test (const bfs::path &datadir)
int main (int argc, char *argv[])

Variables

ostream * os_ = 0

Function Documentation

void verifyBombesinFeatures ( const FeatureField featureField)

Definition at line 42 of file FeatureDetectorPeakelTest.cpp.

References epsilon, pwiz::analysis::MZRTField< T >::find(), unit_assert, and unit_assert_equal.

Referenced by testBombesin().

{
const double epsilon = .01;
const double mz_bomb2 = 810.415;
vector<FeaturePtr> bombesin_2_found = featureField.find(mz_bomb2, epsilon,
unit_assert(bombesin_2_found.size() == 1);
const Feature& bombesin_2 = *bombesin_2_found[0];
unit_assert(bombesin_2.charge == 2);
unit_assert(bombesin_2.peakels.size() == 5);
unit_assert_equal(bombesin_2.peakels[0]->mz, mz_bomb2, epsilon);
unit_assert_equal(bombesin_2.peakels[1]->mz, mz_bomb2+.5, epsilon);
unit_assert_equal(bombesin_2.peakels[2]->mz, mz_bomb2+1, epsilon);
unit_assert_equal(bombesin_2.peakels[3]->mz, mz_bomb2+1.5, epsilon);
unit_assert_equal(bombesin_2.peakels[4]->mz, mz_bomb2+2, epsilon);
//TODO: verify feature metadata
const double mz_bomb3 = 540.612;
vector<FeaturePtr> bombesin_3_found = featureField.find(mz_bomb3, epsilon,
unit_assert(bombesin_3_found.size() == 1);
const Feature& bombesin_3 = *bombesin_3_found[0];
unit_assert(bombesin_3.charge == 3);
unit_assert(bombesin_3.peakels.size() == 3);
unit_assert_equal(bombesin_3.peakels[0]->mz, mz_bomb3, epsilon);
unit_assert_equal(bombesin_3.peakels[1]->mz, mz_bomb3+1./3, epsilon);
unit_assert_equal(bombesin_3.peakels[2]->mz, mz_bomb3+2./3, epsilon);
//TODO: verify feature metadata
}
shared_ptr<FeatureDetectorPeakel> createFeatureDetectorPeakel ( )

Definition at line 74 of file FeatureDetectorPeakelTest.cpp.

References pwiz::analysis::PeakelPicker_Basic::Config::log, pwiz::analysis::PeakelPicker_Basic::Config::maxCharge, pwiz::analysis::PeakelPicker_Basic::Config::minCharge, pwiz::analysis::PeakelPicker_Basic::Config::minMonoisotopicPeakelSize, pwiz::analysis::PeakelPicker_Basic::Config::minPeakelCount, pwiz::analysis::PeakelPicker_Basic::Config::mzTolerance, pwiz::analysis::PeakelGrower_Proximity::Config::mzTolerance, pwiz::analysis::FeatureDetectorPeakel::Config::noiseCalculator_2Pass, pwiz::analysis::FeatureDetectorPeakel::Config::peakelGrower_Proximity, pwiz::analysis::FeatureDetectorPeakel::Config::peakelPicker_Basic, pwiz::analysis::FeatureDetectorPeakel::Config::peakFinder_SNR, pwiz::analysis::FeatureDetectorPeakel::Config::peakFitter_Parabola, pwiz::analysis::PeakFinder_SNR::Config::preprocessWithLogarithm, pwiz::analysis::PeakelPicker_Basic::Config::rtTolerance, pwiz::analysis::PeakelGrower_Proximity::Config::rtTolerance, pwiz::analysis::PeakFinder_SNR::Config::windowRadius, pwiz::analysis::PeakFitter_Parabola::Config::windowRadius, pwiz::analysis::NoiseCalculator_2Pass::Config::zValueCutoff, and pwiz::analysis::PeakFinder_SNR::Config::zValueThreshold.

Referenced by testBombesin().

{
// these are just the defaults, to demonstrate usage
config.peakelPicker_Basic.log = 0; // ostream*
config.peakelPicker_Basic.mzTolerance = MZTolerance(10, MZTolerance::PPM);
return FeatureDetectorPeakel::create(config);
}
void testBombesin ( const string &  filename)

Definition at line 103 of file FeatureDetectorPeakelTest.cpp.

References createFeatureDetectorPeakel(), os_, pwiz::msdata::MSData::run, pwiz::msdata::Run::spectrumListPtr, unit_assert, and verifyBombesinFeatures().

Referenced by test().

{
if (os_) *os_ << "testBombesin()" << endl;
// open data file and check sanity
MSDataFile msd(filename);
unit_assert(msd.run.spectrumListPtr.get());
unit_assert(msd.run.spectrumListPtr->size() == 8);
// instantiate FeatureDetector
shared_ptr<FeatureDetectorPeakel> featureDetectorPeakel = createFeatureDetectorPeakel();
FeatureField featureField;
featureDetectorPeakel->detect(msd, featureField);
if (os_) *os_ << "featureField:\n" << featureField << endl;
verifyBombesinFeatures(featureField);
}
void test ( const bfs::path &  datadir)

Definition at line 125 of file FeatureDetectorPeakelTest.cpp.

References testBombesin().

{
testBombesin((datadir / "FeatureDetectorTest_Bombesin.mzML").string());
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 131 of file FeatureDetectorPeakelTest.cpp.

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

{
TEST_PROLOG(argc, argv)
try
{
bfs::path datadir = ".";
for (int i=1; i<argc; i++)
{
if (!strcmp(argv[i],"-v"))
os_ = &cout;
else
// hack to allow running unit test from a different directory:
// Jamfile passes full path to specified input file.
// we want the path, so we can ignore filename
datadir = bfs::path(argv[i]).branch_path();
}
test(datadir);
}
catch (exception& e)
{
TEST_FAILED(e.what())
}
catch (...)
{
TEST_FAILED("Caught unknown exception.")
}
}

Variable Documentation

ostream* os_ = 0

Definition at line 39 of file FeatureDetectorPeakelTest.cpp.