ProteoWizard
Classes | Functions | Variables
FeatureDetectorSimpleTest.cpp File Reference
#include "FeatureDetectorSimple.hpp"
#include "PeakFamilyDetectorFT.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/data/msdata/MSDataFile.hpp"
#include "pwiz/data/msdata/Serializer_mzML.hpp"
#include "boost/iostreams/positioning.hpp"
#include "boost/filesystem/path.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Classes

struct  mzrtEqual
 

Functions

void testFeatureDetectorSimple (const bfs::path &datadir)
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 
double mz_epsilon = .005
 
double rt_epsilon = 10
 

Function Documentation

§ testFeatureDetectorSimple()

void testFeatureDetectorSimple ( const bfs::path &  datadir)

Definition at line 61 of file FeatureDetectorSimpleTest.cpp.

References pwiz::analysis::PeakFamilyDetectorFT::Config::cp, pwiz::analysis::FeatureDetectorSimple::detect(), pwiz::analysis::PeakFamilyDetectorFT::Config::log, os_, and unit_assert.

Referenced by main().

62 {
63 
64  if (os_) *os_ << "testFeatureDetectorSimple() ... " << endl;
65 
66  // instantiate PeakFamilyDetectorFT
67  // (from PeakFamilyDetectorFTTest.cpp)
68 
69  ostream* os_log_ = 0; // don't log peak family detection
70 
72  config.log = os_log_;
73  config.cp = CalibrationParameters::thermo_FT();
74  boost::shared_ptr<PeakFamilyDetectorFT> detector(new PeakFamilyDetectorFT(config));
75  FeatureDetectorSimple fds(detector);
76 
77  // instantiate MSData from test file
78 
79  MSDataFile msd((datadir / "FeatureDetectorTest_Bombesin.mzML").string());
80 
81  FeatureField output_features;
82  fds.detect(msd, output_features);
83 
84  // instantiate the bombesin +2 feature that we know is correct, with calculated mzMonoisotopic and eyeballed retentionTime
85 
86  FeaturePtr bombesin2_truth(new Feature());
87  bombesin2_truth->mz = 810.4148;
88  bombesin2_truth->retentionTime = 1866;
89 
90  FeatureField::iterator bombesin2_hopeful = find_if(output_features.begin(), output_features.end(), mzrtEqual(bombesin2_truth));
91 
92  // assert that it is found, correctly, in the data
93  unit_assert(bombesin2_hopeful != output_features.end());
94 
95 
96  if (os_) *os_ << "\n[FeatureDetectorSimple] Bombesin detected at charge state +2 ... " << endl << *bombesin2_hopeful << endl;
97 
98 
99  // do the same for the +3 feature
100 
101  FeaturePtr bombesin3_truth(new Feature());
102  bombesin3_truth->mz = 540.6123;
103  bombesin3_truth->retentionTime = 1866;
104 
105  FeatureField::iterator bombesin3_hopeful = find_if(output_features.begin(), output_features.end(), mzrtEqual(bombesin3_truth));
106 
107  // assert that it is found, correctly, in the data
108  unit_assert(bombesin3_hopeful != output_features.end());
109 
110 
111  if (os_) *os_ << "\n[FeatureDetectorSimple] Bombesin detected at charge state +3 ... " << endl << *bombesin3_hopeful << endl;
112 
113  return;
114 
115 }
ostream * os_
FeatureDetectorSimple detects &#39;rectangular&#39; features, ie number of peaks in isotope envelope is the s...
MZRTField is a std::set of boost::shared_ptrs, stored as a binary tree ordered by LessThan_MZRT...
Definition: MZRTField.hpp:94
FT-specific implementation of PeakFamilyDetector.
boost::shared_ptr< Feature > FeaturePtr
Definition: PeakData.hpp:292
MSData object plus file I/O.
Definition: MSDataFile.hpp:40
#define unit_assert(x)
Definition: unit.hpp:85

§ main()

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

Definition at line 117 of file FeatureDetectorSimpleTest.cpp.

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

118 {
119  TEST_PROLOG(argc, argv)
120 
121  try
122  {
123  bfs::path datadir = ".";
124 
125  for (int i=1; i<argc; i++)
126  {
127  if (!strcmp(argv[i],"-v"))
128  os_ = &cout;
129  else
130  // hack to allow running unit test from a different directory:
131  // Jamfile passes full path to specified input file.
132  // we want the path, so we can ignore filename
133  datadir = bfs::path(argv[i]).branch_path();
134  }
135 
136  testFeatureDetectorSimple(datadir);
137  }
138  catch (exception& e)
139  {
140  TEST_FAILED(e.what())
141  }
142  catch (...)
143  {
144  TEST_FAILED("Caught unknown exception.")
145  }
146 
148 }
ostream * os_
void testFeatureDetectorSimple(const bfs::path &datadir)
#define TEST_EPILOG
Definition: unit.hpp:182
#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 40 of file FeatureDetectorSimpleTest.cpp.

Referenced by main(), and testFeatureDetectorSimple().

§ mz_epsilon

double mz_epsilon = .005

Definition at line 42 of file FeatureDetectorSimpleTest.cpp.

Referenced by mzrtEqual::operator()().

§ rt_epsilon

double rt_epsilon = 10

Definition at line 43 of file FeatureDetectorSimpleTest.cpp.

Referenced by mzrtEqual::operator()().