ProteoWizard
Public Member Functions | Protected Member Functions | List of all members
SpectrumPeakExtractorTest Class Reference

Public Member Functions

void Run ()
 

Protected Member Functions

virtual void SetUp ()
 
void TearDown ()
 
void ExtractPeaksTest ()
 

Detailed Description

Definition at line 30 of file SpectrumPeakExtractorTest.cpp.

Member Function Documentation

◆ Run()

void SpectrumPeakExtractorTest::Run ( )
inline

◆ SetUp()

virtual void SpectrumPeakExtractorTest::SetUp ( )
inlineprotectedvirtual

Definition at line 41 of file SpectrumPeakExtractorTest.cpp.

42 {
43 }

Referenced by Run().

◆ TearDown()

void SpectrumPeakExtractorTest::TearDown ( )
inlineprotected

Definition at line 45 of file SpectrumPeakExtractorTest.cpp.

46 {
47 }

Referenced by Run().

◆ ExtractPeaksTest()

void SpectrumPeakExtractorTest::ExtractPeaksTest ( )
inlineprotected

Definition at line 49 of file SpectrumPeakExtractorTest.cpp.

50 {
51 // Generate test data
52 MSData msd;
54
55 // Remember which spectra correspond to what states
56 const int MS2_INDEX_0 = 1;
57 const int MS2_INDEX_1 = 3;
58
59 auto centroidedPtr = msd.run.spectrumListPtr;
60
61 Spectrum_const_ptr s20 = centroidedPtr->spectrum(MS2_INDEX_0, true);
62 SpectrumPtr s21 = centroidedPtr->spectrum(MS2_INDEX_1, true);
63
64 // Build new mz and intensity arrays for the second spectrum
65 s21->binaryDataArrayPtrs.clear();
66 s21->setMZIntensityArrays(vector<double>(), vector<double>(), MS_number_of_detector_counts);
67 BinaryData<double>& newMzs = s21->getMZArray()->data;
68 BinaryData<double>& newIntensities = s21->getIntensityArray()->data;
69
70 newMzs = vector<double>({ 0.0, 2.0, 2.000001, 3.999999, 4.0, 4.000001, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0 });
71 for (size_t mz = 0; mz < newMzs.size(); ++mz)
72 {
73 newIntensities.push_back(1.0);
74 }
75
76 vector<double> s21ExpectedIntensities = { 1.0, 2.0, 3.0 };
77 while (s21ExpectedIntensities.size() < s20->getIntensityArray()->data.size())
78 {
79 s21ExpectedIntensities.push_back(1.0);
80 }
81
82 // Create peak extractor to match mz set of the first spectrum
83 BinaryDataArrayPtr mzsToDemux = s20->getMZArray();
85
86 // Test number of peaks
87 unit_assert_operator_equal(peakExtractor.numPeaks(), mzsToDemux->data.size());
88
89 // Make matrix to extract peak info into
90 MatrixPtr signal;
91 int numSpectra = 2;
92 signal.reset(new MatrixType(numSpectra, mzsToDemux->data.size()));
93
94 // Extract spectra
95 peakExtractor(s20, *signal, 0);
96 peakExtractor(s21, *signal, 1);
97
98 // Check that self extraction returns the original spectrum
99 Spectrum_const_ptr baseSpectrum = centroidedPtr->spectrum(MS2_INDEX_0, true);
100 BinaryDataArrayPtr baseIntensities = baseSpectrum->getIntensityArray();
101 for (size_t i = 0; i < baseIntensities->data.size(); ++i)
102 {
103 unit_assert_equal(signal->row(0)[i], baseIntensities->data.at(i), 0.0001);
104 }
105
106 // Check the second spectrum extraction
107 for (size_t i = 0; i < s21ExpectedIntensities.size(); ++i)
108 {
109 unit_assert_equal(signal->row(1)[i], s21ExpectedIntensities[i], 0.0001);
110 }
111
112 // Now extract from the second spectrum, which has closely spaced peaks to simulate non-centroided data
114 unit_assert_operator_equal(binExamplePeakExtractor.numPeaks(), s21->getMZArray()->data.size());
115
116 // Extract spectra
117 signal.reset(new MatrixType(numSpectra, s21->getMZArray()->data.size()));
118 binExamplePeakExtractor(s21, *signal, 0);
119 binExamplePeakExtractor(s20, *signal, 1);
120
121 // Check the self extraction returns the original spectrum
122 for (size_t i = 0; i < s21->getIntensityArray()->data.size(); ++i)
123 {
124 unit_assert_equal(signal->row(0)[i], s21->getIntensityArray()->data.at(i), 0.0001);
125 }
126 }
Extracts sets of centroided peaks from spectra using a user-defined list of peaks to extract.
A custom vector class that can store its contents in either a std::vector or a cli::array (when compi...
void push_back(const T &value)
MS_number_of_detector_counts
number of detector counts: The number of counted events observed in one or a group of elements of a d...
Definition cv.hpp:741
boost::shared_ptr< MatrixType > MatrixPtr
Matrix< DemuxScalar, Dynamic, Dynamic > MatrixType
double mz(double neutralMass, int protonDelta, int electronDelta=0, int neutronDelta=0)
Definition Ion.hpp:78
PWIZ_API_DECL void initializeTiny(MSData &msd)
boost::shared_ptr< const msdata::Spectrum > Spectrum_const_ptr
boost::shared_ptr< BinaryDataArray > BinaryDataArrayPtr
Definition MSData.hpp:417
boost::shared_ptr< Spectrum > SpectrumPtr
Definition MSData.hpp:573
struct for expressing m/z tolerance in either amu or ppm
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition MSData.hpp:850
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument.
Definition MSData.hpp:886
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here....
Definition MSData.hpp:827
#define unit_assert_equal(x, y, epsilon)
Definition unit.hpp:99
#define unit_assert_operator_equal(expected, actual)
Definition unit.hpp:92

References pwiz::msdata::examples::initializeTiny(), MS_number_of_detector_counts, pwiz::analysis::SpectrumPeakExtractor::numPeaks(), pwiz::chemistry::MZTolerance::PPM, pwiz::util::BinaryData< T >::push_back(), pwiz::msdata::MSData::run, pwiz::util::BinaryData< T >::size(), pwiz::msdata::Run::spectrumListPtr, unit_assert_equal, and unit_assert_operator_equal.

Referenced by Run().


The documentation for this class was generated from the following file: