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

◆ verifyBombesinFeatures()

void verifyBombesinFeatures ( const FeatureField featureField)

Definition at line 42 of file FeatureDetectorPeakelTest.cpp.

43{
44 const double epsilon = .01;
45
46 const double mz_bomb2 = 810.415;
47 vector<FeaturePtr> bombesin_2_found = featureField.find(mz_bomb2, epsilon,
49 unit_assert(bombesin_2_found.size() == 1);
50 const Feature& bombesin_2 = *bombesin_2_found[0];
51 unit_assert(bombesin_2.charge == 2);
52 unit_assert(bombesin_2.peakels.size() == 5);
53 unit_assert_equal(bombesin_2.peakels[0]->mz, mz_bomb2, epsilon);
54 unit_assert_equal(bombesin_2.peakels[1]->mz, mz_bomb2+.5, epsilon);
55 unit_assert_equal(bombesin_2.peakels[2]->mz, mz_bomb2+1, epsilon);
56 unit_assert_equal(bombesin_2.peakels[3]->mz, mz_bomb2+1.5, epsilon);
57 unit_assert_equal(bombesin_2.peakels[4]->mz, mz_bomb2+2, epsilon);
58 //TODO: verify feature metadata
59
60 const double mz_bomb3 = 540.612;
61 vector<FeaturePtr> bombesin_3_found = featureField.find(mz_bomb3, epsilon,
63 unit_assert(bombesin_3_found.size() == 1);
64 const Feature& bombesin_3 = *bombesin_3_found[0];
65 unit_assert(bombesin_3.charge == 3);
66 unit_assert(bombesin_3.peakels.size() == 3);
67 unit_assert_equal(bombesin_3.peakels[0]->mz, mz_bomb3, epsilon);
68 unit_assert_equal(bombesin_3.peakels[1]->mz, mz_bomb3+1./3, epsilon);
69 unit_assert_equal(bombesin_3.peakels[2]->mz, mz_bomb3+2./3, epsilon);
70 //TODO: verify feature metadata
71}
const double epsilon
Definition DiffTest.cpp:41
std::vector< TPtr > find(double mz, MZTolerance mzTolerance, RTMatches matches) const
find all objects with a given m/z, within a given m/z tolerance, satisfying the 'matches' predicate
predicate returns true iff the object's retention time range contains the specified retention time
std::vector< PeakelPtr > peakels
Definition PeakData.hpp:274
#define unit_assert(x)
Definition unit.hpp:85
#define unit_assert_equal(x, y, epsilon)
Definition unit.hpp:99

References pwiz::data::peakdata::Feature::charge, epsilon, pwiz::analysis::MZRTField< T >::find(), pwiz::data::peakdata::Feature::peakels, unit_assert, and unit_assert_equal.

Referenced by testBombesin().

◆ createFeatureDetectorPeakel()

shared_ptr< FeatureDetectorPeakel > createFeatureDetectorPeakel ( )

Definition at line 74 of file FeatureDetectorPeakelTest.cpp.

75{
77
78 // these are just the defaults, to demonstrate usage
79
81
85
87
90
91 config.peakelPicker_Basic.log = 0; // ostream*
98
99 return FeatureDetectorPeakel::create(config);
100}
static boost::shared_ptr< FeatureDetectorPeakel > create(Config config)
struct for expressing m/z tolerance in either amu or ppm

References pwiz::analysis::FeatureDetectorPeakel::create(), 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::PeakelGrower_Proximity::Config::mzTolerance, pwiz::analysis::PeakelPicker_Basic::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::chemistry::MZTolerance::PPM, pwiz::analysis::PeakFinder_SNR::Config::preprocessWithLogarithm, pwiz::analysis::PeakelGrower_Proximity::Config::rtTolerance, pwiz::analysis::PeakelPicker_Basic::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().

◆ testBombesin()

void testBombesin ( const string &  filename)

Definition at line 103 of file FeatureDetectorPeakelTest.cpp.

104{
105 if (os_) *os_ << "testBombesin()" << endl;
106
107 // open data file and check sanity
108
109 MSDataFile msd(filename);
110 unit_assert(msd.run.spectrumListPtr.get());
111 unit_assert(msd.run.spectrumListPtr->size() == 8);
112
113 // instantiate FeatureDetector
114
115 shared_ptr<FeatureDetectorPeakel> featureDetectorPeakel = createFeatureDetectorPeakel();
116
117 FeatureField featureField;
118 featureDetectorPeakel->detect(msd, featureField);
119
120 if (os_) *os_ << "featureField:\n" << featureField << endl;
121 verifyBombesinFeatures(featureField);
122}
shared_ptr< FeatureDetectorPeakel > createFeatureDetectorPeakel()
void verifyBombesinFeatures(const FeatureField &featureField)
ostream * os_
MZRTField is a std::set of boost::shared_ptrs, stored as a binary tree ordered by LessThan_MZRT.
Definition MZRTField.hpp:95
MSData object plus file I/O.

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

Referenced by test().

◆ test()

void test ( const bfs::path &  datadir)

Definition at line 125 of file FeatureDetectorPeakelTest.cpp.

126{
127 testBombesin((datadir / "FeatureDetectorTest_Bombesin.mzML").string());
128}
void testBombesin(const string &filename)

References testBombesin().

◆ main()

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

Definition at line 131 of file FeatureDetectorPeakelTest.cpp.

132{
133 TEST_PROLOG(argc, argv)
134
135 try
136 {
137 bfs::path datadir = ".";
138
139 for (int i=1; i<argc; i++)
140 {
141 if (!strcmp(argv[i],"-v"))
142 os_ = &cout;
143 else
144 // hack to allow running unit test from a different directory:
145 // Jamfile passes full path to specified input file.
146 // we want the path, so we can ignore filename
147 datadir = bfs::path(argv[i]).branch_path();
148 }
149
150 test(datadir);
151 }
152 catch (exception& e)
153 {
154 TEST_FAILED(e.what())
155 }
156 catch (...)
157 {
158 TEST_FAILED("Caught unknown exception.")
159 }
160
162}
#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 39 of file FeatureDetectorPeakelTest.cpp.

Referenced by main(), and testBombesin().