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.

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

Referenced by testBombesin().

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 }
predicate returns true iff the object&#39;s retention time range contains the specified retention time ...
Definition: MZRTField.hpp:130
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 &#39;matches&#39; predicate ...
#define unit_assert_equal(x, y, epsilon)
Definition: unit.hpp:99
#define unit_assert(x)
Definition: unit.hpp:85

§ createFeatureDetectorPeakel()

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().

75 {
77 
78  // these are just the defaults, to demonstrate usage
79 
81 
82  config.peakFinder_SNR.windowRadius = 2;
85 
87 
90 
91  config.peakelPicker_Basic.log = 0; // ostream*
92  config.peakelPicker_Basic.minCharge = 2;
93  config.peakelPicker_Basic.maxCharge = 5;
95  config.peakelPicker_Basic.mzTolerance = MZTolerance(10, MZTolerance::PPM);
98 
99  return FeatureDetectorPeakel::create(config);
100 }
PeakelGrower_Proximity::Config peakelGrower_Proximity
struct for expressing m/z tolerance in either amu or ppm
Definition: MZTolerance.hpp:38

§ testBombesin()

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().

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 }
MZRTField is a std::set of boost::shared_ptrs, stored as a binary tree ordered by LessThan_MZRT...
Definition: MZRTField.hpp:94
void verifyBombesinFeatures(const FeatureField &featureField)
ostream * os_
shared_ptr< FeatureDetectorPeakel > createFeatureDetectorPeakel()
MSData object plus file I/O.
Definition: MSDataFile.hpp:40
#define unit_assert(x)
Definition: unit.hpp:85

§ test()

void test ( const bfs::path &  datadir)

Definition at line 125 of file FeatureDetectorPeakelTest.cpp.

References testBombesin().

Referenced by main().

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

§ main()

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

Definition at line 131 of file FeatureDetectorPeakelTest.cpp.

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

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:182
ostream * os_
void test(const bfs::path &datadir)
#define TEST_FAILED(x)
Definition: unit.hpp:176
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:174

Variable Documentation

§ os_

ostream* os_ = 0

Definition at line 39 of file FeatureDetectorPeakelTest.cpp.

Referenced by main(), and testBombesin().