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

FeaturePtr getFeature ( const string &  filename)

Definition at line 40 of file FeatureModelerTest.cpp.

Referenced by test().

{
ifstream is(filename.c_str());
if (!is) throw runtime_error(("Unable to open file " + filename).c_str());
FeaturePtr feature(new Feature);
is >> *feature;
return feature;
}
void testGaussian_Bombesin2 ( const Feature bombesin2)

Definition at line 52 of file FeatureModelerTest.cpp.

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

Referenced by test().

{
if (os_) *os_ << "testGaussian_Bombesin2()\n";
unit_assert(bombesin2.peakels.size() == 5);
if (os_) *os_ << "before:\n" << bombesin2;
Feature result;
fm.fitFeature(bombesin2, result);
if (os_) *os_ << "after:\n" << result << endl;
}
void testGaussian_Bombesin3 ( const Feature bombesin3)

Definition at line 67 of file FeatureModelerTest.cpp.

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

Referenced by test().

{
if (os_) *os_ << "testGaussian_Bombesin3()\n";
unit_assert(bombesin3.peakels.size() == 3);
if (os_) *os_ << "before:\n" << bombesin3;
Feature result;
fm.fitFeature(bombesin3, result);
if (os_) *os_ << "after:\n" << result << endl;
}
void testMulti ( const FeatureField ff)

Definition at line 82 of file FeatureModelerTest.cpp.

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

Referenced by test().

{
if (os_) *os_ << "testMulti()\n";
FeatureField result;
unit_assert(result.empty());
fm.fitFeatures(ff, result);
if (os_) *os_ << result << endl;
unit_assert(result.size() == 2);
}
void test ( const bfs::path &  datadir)

Definition at line 97 of file FeatureModelerTest.cpp.

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

{
FeaturePtr bombesin2 = getFeature((datadir / "Bombesin2.feature").string());
FeaturePtr bombesin3 = getFeature((datadir / "Bombesin3.feature").string());
ff.insert(bombesin2);
ff.insert(bombesin3);
testMulti(ff);
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 112 of file FeatureModelerTest.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 37 of file FeatureModelerTest.cpp.