ProteoWizard
Functions | Variables
SpectrumList_PrecursorRefineTest.cpp File Reference
#include "SpectrumList_PrecursorRefine.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 verifyPrecursorMZ (const Spectrum &spectrum, double precursorMZ)
 
void testPrecursorRefine (const bfs::path &datadir)
 
void test (const bfs::path &datadir)
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 

Function Documentation

◆ verifyPrecursorMZ()

void verifyPrecursorMZ ( const Spectrum spectrum,
double  precursorMZ 
)

Definition at line 42 of file SpectrumList_PrecursorRefineTest.cpp.

43{
44 unit_assert(!spectrum.precursors.empty());
45 const Precursor& precursor = spectrum.precursors[0];
46 unit_assert(!precursor.selectedIons.empty());
47 const SelectedIon& selectedIon = precursor.selectedIons[0];
48
49 double foo = selectedIon.cvParam(MS_selected_ion_m_z).valueAs<double>();
50 foo++; // quiet an "initalized but not used" warning
51
52 const double epsilon = 1e-4;
53 if (os_)
54 {
55 *os_ << "[verifyPrecursorMZ] " << spectrum.index << " " << spectrum.id << " "
56 << precursorMZ << ": "
57 << selectedIon.cvParam(MS_selected_ion_m_z).value << " " << selectedIon.cvParam(MS_charge_state).value << endl;
58 }
59
60 unit_assert_equal(selectedIon.cvParam(MS_selected_ion_m_z).valueAs<double>(), precursorMZ, epsilon);
61
62}
MS_charge_state
charge state: The charge state of the ion, single or multiple and positive or negatively charged.
Definition cv.hpp:396
MS_selected_ion_m_z
selected ion m/z: Mass-to-charge ratio of an selected ion.
Definition cv.hpp:2901
const double epsilon
Definition DiffTest.cpp:41
value_type valueAs() const
templated value access with type conversion
CVParam cvParam(CVID cvid) const
finds cvid in the container:
The method of precursor ion selection and activation.
Definition MSData.hpp:312
std::vector< SelectedIon > selectedIons
this list of precursor ions that were selected.
Definition MSData.hpp:329
std::vector< Precursor > precursors
list and descriptions of precursors to the spectrum currently being described.
Definition MSData.hpp:520
std::string id
a unique identifier for this spectrum. It should be expected that external files may use this identif...
Definition MSData.hpp:476
size_t index
the zero-based, consecutive index of the spectrum in the SpectrumList.
Definition MSData.hpp:473
#define unit_assert(x)
Definition unit.hpp:85
#define unit_assert_equal(x, y, epsilon)
Definition unit.hpp:99

References pwiz::data::ParamContainer::cvParam(), epsilon, pwiz::msdata::SpectrumIdentity::id, pwiz::msdata::SpectrumIdentity::index, MS_charge_state, MS_selected_ion_m_z, os_, pwiz::msdata::Spectrum::precursors, pwiz::msdata::Precursor::selectedIons, unit_assert, unit_assert_equal, pwiz::data::CVParam::value, and pwiz::data::CVParam::valueAs().

Referenced by testPrecursorRefine().

◆ testPrecursorRefine()

void testPrecursorRefine ( const bfs::path &  datadir)

Definition at line 65 of file SpectrumList_PrecursorRefineTest.cpp.

66{
67 MSDataFile msd((datadir / "PrecursorRefineOrbi.mzML").string());
68
69 unit_assert(msd.run.spectrumListPtr.get() && msd.run.spectrumListPtr->size()==51);
70 if (os_) *os_ << "original spectra:\n";
71 verifyPrecursorMZ(*msd.run.spectrumListPtr->spectrum(21), 747.37225);
72 verifyPrecursorMZ(*msd.run.spectrumListPtr->spectrum(22), 614.867065);
73 verifyPrecursorMZ(*msd.run.spectrumListPtr->spectrum(24), 547.2510);
74 verifyPrecursorMZ(*msd.run.spectrumListPtr->spectrum(25), 533.2534);
75 verifyPrecursorMZ(*msd.run.spectrumListPtr->spectrum(26), 401.22787);
76
77 shared_ptr<SpectrumList_PrecursorRefine> spectrumListRecalculated(
79
80 unit_assert(spectrumListRecalculated->size() == 51);
81 if (os_) *os_ << "recalculated spectra:\n";
82 verifyPrecursorMZ(*spectrumListRecalculated->spectrum(21), 747.37078);
83 verifyPrecursorMZ(*spectrumListRecalculated->spectrum(22), 614.86648);
84 verifyPrecursorMZ(*spectrumListRecalculated->spectrum(24), 547.2507);
85 verifyPrecursorMZ(*spectrumListRecalculated->spectrum(25), 533.2534);
86 verifyPrecursorMZ(*spectrumListRecalculated->spectrum(26), 401.226957);
87}
void verifyPrecursorMZ(const Spectrum &spectrum, double precursorMZ)
SpectrumList wrapper that recalculates precursor info on spectrum() requests.
MSData object plus file I/O.

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

Referenced by test().

◆ test()

void test ( const bfs::path &  datadir)

Definition at line 90 of file SpectrumList_PrecursorRefineTest.cpp.

91{
92 testPrecursorRefine(datadir);
93}
void testPrecursorRefine(const bfs::path &datadir)

References testPrecursorRefine().

◆ main()

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

Definition at line 96 of file SpectrumList_PrecursorRefineTest.cpp.

97{
98 TEST_PROLOG(argc, argv)
99
100 try
101 {
102 bfs::path datadir = ".";
103
104 for (int i=1; i<argc; i++)
105 {
106 if (!strcmp(argv[i],"-v"))
107 os_ = &cout;
108 else
109 // hack to allow running unit test from a different directory:
110 // Jamfile passes full path to specified input file.
111 // we want the path, so we can ignore filename
112 datadir = bfs::path(argv[i]).branch_path();
113 }
114
115 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
116 test(datadir);
117 }
118 catch (exception& e)
119 {
120 TEST_FAILED(e.what())
121 }
122 catch (...)
123 {
124 TEST_FAILED("Caught unknown exception.")
125 }
126
128}
#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