ProteoWizard
Functions | Variables
SpectrumList_PrecursorRecalculatorTest.cpp File Reference
#include "SpectrumList_PrecursorRecalculator.hpp"
#include "pwiz/data/msdata/MSDataFile.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

void verifyPrecursorInfo (const Spectrum &spectrum, double precursorMZ, int precursorCharge)
void test5peptideFT (const bfs::path &datadir)
void test (const bfs::path &datadir)
int main (int argc, char *argv[])

Variables

ostream * os_ = 0

Function Documentation

void verifyPrecursorInfo ( const Spectrum spectrum,
double  precursorMZ,
int  precursorCharge 
)

Definition at line 42 of file SpectrumList_PrecursorRecalculatorTest.cpp.

References e(), epsilon, pwiz::msdata::SpectrumIdentity::id, pwiz::msdata::SpectrumIdentity::index, MS_charge_state, MS_selected_ion_m_z, os_, pwiz::msdata::Spectrum::precursors, unit_assert, and unit_assert_equal.

Referenced by test5peptideFT().

{
unit_assert(!spectrum.precursors.empty());
const Precursor& precursor = spectrum.precursors[0];
unit_assert(!precursor.selectedIons.empty());
const SelectedIon& selectedIon = precursor.selectedIons[0];
const double epsilon = 1e-2;
if (os_)
{
*os_ << "[verifyPrecursorInfo] " << spectrum.index << " " << spectrum.id << " "
<< precursorMZ << " " << precursorCharge << ": "
<< selectedIon.cvParam(MS_selected_ion_m_z).value << " " << selectedIon.cvParam(MS_charge_state).value << endl;
}
unit_assert_equal(selectedIon.cvParam(MS_selected_ion_m_z).valueAs<double>(), precursorMZ, epsilon);
if (precursorCharge != 0)
unit_assert(selectedIon.cvParam(MS_charge_state).valueAs<int>() == precursorCharge);
}
void test5peptideFT ( const bfs::path &  datadir)

Definition at line 64 of file SpectrumList_PrecursorRecalculatorTest.cpp.

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

Referenced by test().

{
MSDataFile msd((datadir / "5peptideFT.mzML").string());
unit_assert(msd.run.spectrumListPtr.get() && msd.run.spectrumListPtr->size()==7);
if (os_) *os_ << "original spectra:\n";
verifyPrecursorInfo(*msd.run.spectrumListPtr->spectrum(2), 810.79, 0);
verifyPrecursorInfo(*msd.run.spectrumListPtr->spectrum(3), 837.34, 0);
verifyPrecursorInfo(*msd.run.spectrumListPtr->spectrum(4), 725.36, 0);
verifyPrecursorInfo(*msd.run.spectrumListPtr->spectrum(5), 558.87, 0);
verifyPrecursorInfo(*msd.run.spectrumListPtr->spectrum(6), 812.33, 0);
shared_ptr<SpectrumList_PrecursorRecalculator> spectrumListRecalculated(
unit_assert(spectrumListRecalculated->size() == 7);
if (os_) *os_ << "recalculated spectra:\n";
verifyPrecursorInfo(*spectrumListRecalculated->spectrum(2), 810.42, 2);
verifyPrecursorInfo(*spectrumListRecalculated->spectrum(3), 836.96, 2);
verifyPrecursorInfo(*spectrumListRecalculated->spectrum(4), 724.91, 2);
verifyPrecursorInfo(*spectrumListRecalculated->spectrum(5), 558.31, 3);
verifyPrecursorInfo(*spectrumListRecalculated->spectrum(6), 810.42, 2);
}
void test ( const bfs::path &  datadir)

Definition at line 89 of file SpectrumList_PrecursorRecalculatorTest.cpp.

References test5peptideFT().

{
test5peptideFT(datadir);
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 95 of file SpectrumList_PrecursorRecalculatorTest.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();
}
if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
test(datadir);
}
catch (exception& e)
{
TEST_FAILED(e.what())
}
catch (...)
{
TEST_FAILED("Caught unknown exception.")
}
}

Variable Documentation

ostream* os_ = 0

Definition at line 39 of file SpectrumList_PrecursorRecalculatorTest.cpp.