ProteoWizard
Functions | Variables
FeatureModelerTest.cpp File Reference
#include "FeatureModeler.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "boost/filesystem/path.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include <cstring>

Go to the source code of this file.

Functions

FeaturePtr getFeature (const string &filename)
 
void testGaussian_Bombesin2 (const Feature &bombesin2)
 
void testGaussian_Bombesin3 (const Feature &bombesin3)
 
void testMulti (const FeatureField &ff)
 
void test (const bfs::path &datadir)
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 

Function Documentation

◆ getFeature()

FeaturePtr getFeature ( const string &  filename)

Definition at line 40 of file FeatureModelerTest.cpp.

41{
42 std::ifstream is(filename.c_str());
43 if (!is) throw runtime_error(("Unable to open file " + filename).c_str());
44
45 FeaturePtr feature(new Feature);
46 is >> *feature;
47
48 return feature;
49}
boost::shared_ptr< Feature > FeaturePtr
Definition PeakData.hpp:292

Referenced by test().

◆ testGaussian_Bombesin2()

void testGaussian_Bombesin2 ( const Feature bombesin2)

Definition at line 52 of file FeatureModelerTest.cpp.

53{
54 if (os_) *os_ << "testGaussian_Bombesin2()\n";
55 unit_assert(bombesin2.peakels.size() == 5);
56
57 if (os_) *os_ << "before:\n" << bombesin2;
58
60 Feature result;
61 fm.fitFeature(bombesin2, result);
62
63 if (os_) *os_ << "after:\n" << result << endl;
64}
ostream * os_
virtual void fitFeature(const Feature &in, Feature &out) const
std::vector< PeakelPtr > peakels
Definition PeakData.hpp:274
#define unit_assert(x)
Definition unit.hpp:85

References pwiz::analysis::FeatureModeler_Gaussian::fitFeature(), os_, pwiz::data::peakdata::Feature::peakels, and unit_assert.

Referenced by test().

◆ testGaussian_Bombesin3()

void testGaussian_Bombesin3 ( const Feature bombesin3)

Definition at line 67 of file FeatureModelerTest.cpp.

68{
69 if (os_) *os_ << "testGaussian_Bombesin3()\n";
70 unit_assert(bombesin3.peakels.size() == 3);
71
72 if (os_) *os_ << "before:\n" << bombesin3;
73
75 Feature result;
76 fm.fitFeature(bombesin3, result);
77
78 if (os_) *os_ << "after:\n" << result << endl;
79}

References pwiz::analysis::FeatureModeler_Gaussian::fitFeature(), os_, pwiz::data::peakdata::Feature::peakels, and unit_assert.

Referenced by test().

◆ testMulti()

void testMulti ( const FeatureField ff)

Definition at line 82 of file FeatureModelerTest.cpp.

83{
84 if (os_) *os_ << "testMulti()\n";
85
86 FeatureField result;
87 unit_assert(result.empty());
88
90 fm.fitFeatures(ff, result);
91
92 if (os_) *os_ << result << endl;
93 unit_assert(result.size() == 2);
94}
virtual void fitFeatures(const FeatureField &in, FeatureField &out) const
MZRTField is a std::set of boost::shared_ptrs, stored as a binary tree ordered by LessThan_MZRT.
Definition MZRTField.hpp:95

References pwiz::analysis::FeatureModeler::fitFeatures(), os_, and unit_assert.

Referenced by test().

◆ test()

void test ( const bfs::path &  datadir)

Definition at line 97 of file FeatureModelerTest.cpp.

98{
99 FeaturePtr bombesin2 = getFeature((datadir / "Bombesin2.feature").string());
100 FeaturePtr bombesin3 = getFeature((datadir / "Bombesin3.feature").string());
101
102 testGaussian_Bombesin2(*bombesin2);
103 testGaussian_Bombesin3(*bombesin3);
104
105 FeatureField ff;
106 ff.insert(bombesin2);
107 ff.insert(bombesin3);
108 testMulti(ff);
109}
void testMulti(const FeatureField &ff)
void testGaussian_Bombesin2(const Feature &bombesin2)
FeaturePtr getFeature(const string &filename)
void testGaussian_Bombesin3(const Feature &bombesin3)

References getFeature(), testGaussian_Bombesin2(), testGaussian_Bombesin3(), and testMulti().

◆ main()

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

Definition at line 112 of file FeatureModelerTest.cpp.

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