ProteoWizard
Functions | Variables
SpectrumListFactoryTest.cpp File Reference
#include "SpectrumListFactory.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include <cstring>

Go to the source code of this file.

Functions

void testUsage ()
 
void testWrap ()
 
void testWrapScanTimeRange ()
 
void testWrapSortScanTime ()
 
void testWrapMZWindow ()
 
void testWrapMSLevel ()
 
void testWrapChargeState ()
 
void testWrapDefaultArrayLength ()
 
void testWrapActivation ()
 
void testWrapMassAnalyzer ()
 
void testWrapPolarity ()
 
void testWrapTitleMaker ()
 
void intializeTinyWithThermoFilter (MSData &msd)
 
void testWrapThermoScanFilter ()
 
void testWrapPrecursorMzSet ()
 
void testWrapMZPresent ()
 
void test ()
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 

Function Documentation

◆ testUsage()

void testUsage ( )

Definition at line 39 of file SpectrumListFactoryTest.cpp.

References os_, and pwiz::analysis::SpectrumListFactory::usage().

Referenced by test().

40 {
41  if (os_) *os_ << "SpectrumListFactory::usage():\n" << SpectrumListFactory::usage() << endl;
42 }
ostream * os_

◆ testWrap()

void testWrap ( )

Definition at line 45 of file SpectrumListFactoryTest.cpp.

References pwiz::msdata::MSData::allDataProcessingPtrs(), pwiz::identdata::examples::initializeTiny(), pwiz::msdata::MSData::run, pwiz::msdata::Run::spectrumListPtr, unit_assert, unit_assert_operator_equal, and pwiz::analysis::SpectrumListFactory::wrap().

Referenced by test().

46 {
47  MSData msd;
49 
51 
52  unit_assert(sl.get());
53  unit_assert(sl->size() > 2);
54 
55  // CompassXtract and pwiz data processing
57  unit_assert_operator_equal(1, msd.allDataProcessingPtrs()[1]->processingMethods.size());
58 
59  SpectrumListFactory::wrap(msd, "scanNumber [19,20]");
60  unit_assert(sl->size() == 2);
61 
62  // make sure we can handle config file lines copied from commandline
63  // with quotes intact
64  SpectrumListFactory::wrap(msd, "'index [1,1]'");
65  unit_assert(sl->size() == 1);
66  unit_assert(sl->spectrumIdentity(0).id == "scan=20");
67 
68  vector<double> profileData(sl->spectrum(0)->getMZArray()->data);
69  unit_assert(profileData.size() == 10);
70  unit_assert(profileData[0] == 0);
71  unit_assert(profileData[9] == 18);
72 
74  unit_assert_operator_equal(1, msd.allDataProcessingPtrs()[1]->processingMethods.size());
75 
76  SpectrumListFactory::wrap(msd, "peakPicking true [1,6]"); // backwards compatible syntax
77  SpectrumListFactory::wrap(msd, "peakPicking false"); // backwards compatible syntax
78  SpectrumListFactory::wrap(msd, "peakPicking cwt msLevel=[1,6]");
79  SpectrumListFactory::wrap(msd, "peakPicking cwt snr=1.2 msLevel=2-");
80  SpectrumListFactory::wrap(msd, "peakPicking cwt peakSpace=0.05");
81 
82  vector<double> peakData(sl->spectrum(0)->getMZArray()->data);
83  unit_assert(peakData.size() == 1);
84  unit_assert(peakData[0] == 0);
85 
87  unit_assert_operator_equal(6, msd.allDataProcessingPtrs()[1]->processingMethods.size());
88 }
#define unit_assert_operator_equal(expected, actual)
Definition: unit.hpp:92
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument...
Definition: MSData.hpp:882
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:707
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here. Subsidiary data arrays are also both described and attached here.
Definition: MSData.hpp:823
std::vector< DataProcessingPtr > allDataProcessingPtrs() const
return dataProcessingPtrs augmented by the dataProcessingPtr() set in SpectrumList and/or Chromatogra...
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:845
#define unit_assert(x)
Definition: unit.hpp:85

◆ testWrapScanTimeRange()

void testWrapScanTimeRange ( )

Definition at line 91 of file SpectrumListFactoryTest.cpp.

References pwiz::identdata::examples::initializeTiny(), pwiz::msdata::MSData::run, pwiz::msdata::Run::spectrumListPtr, unit_assert, and pwiz::analysis::SpectrumListFactory::wrap().

Referenced by test().

92 {
93  MSData msd;
95 
97  unit_assert(sl.get());
98  unit_assert(sl->size() > 2);
99 
100  double timeHighInSeconds = 5.9 * 60; // between first and second scan
101  ostringstream oss;
102  oss << "scanTime [0," << timeHighInSeconds << "]";
103  SpectrumListFactory::wrap(msd, oss.str());
104  unit_assert(sl->size() == 2);
105  unit_assert(sl->spectrumIdentity(0).id == "scan=19");
106  unit_assert(sl->spectrumIdentity(1).id == "sample=1 period=1 cycle=23 experiment=1"); // not in scan time order (42 seconds)
107 }
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument...
Definition: MSData.hpp:882
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:707
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here. Subsidiary data arrays are also both described and attached here.
Definition: MSData.hpp:823
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:845
#define unit_assert(x)
Definition: unit.hpp:85

◆ testWrapSortScanTime()

void testWrapSortScanTime ( )

Definition at line 110 of file SpectrumListFactoryTest.cpp.

References pwiz::identdata::examples::initializeTiny(), MS_scan_start_time, pwiz::msdata::MSData::run, pwiz::msdata::Run::spectrumListPtr, unit_assert, UO_minute, UO_second, and pwiz::analysis::SpectrumListFactory::wrap().

Referenced by test().

111 {
112  MSData msd;
114 
116  unit_assert(sl.get());
117  unit_assert(sl->size() == 5);
118 
119  sl->spectrum(0)->scanList.scans[0].set(MS_scan_start_time, 35, UO_second);
120  sl->spectrum(2)->scanList.scans[0].set(MS_scan_start_time, 0.5, UO_minute);
121 
122  SpectrumListFactory::wrap(msd, "sortByScanTime");
123  unit_assert(sl->size() == 5);
124  unit_assert(sl->spectrumIdentity(0).id == "scan=21");
125  unit_assert(sl->spectrumIdentity(1).id == "scan=19");
126  unit_assert(sl->spectrumIdentity(2).id == "sample=1 period=1 cycle=23 experiment=1");
127 }
MS_scan_start_time
scan start time: The time that an analyzer started a scan, relative to the start of the MS run...
Definition: cv.hpp:148
UO_second
second: A time unit which is equal to the duration of 9 192 631 770 periods of the radiation correspo...
Definition: cv.hpp:12526
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument...
Definition: MSData.hpp:882
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:707
UO_minute
minute: A time unit which is equal to 60 seconds.
Definition: cv.hpp:12589
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here. Subsidiary data arrays are also both described and attached here.
Definition: MSData.hpp:823
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:845
#define unit_assert(x)
Definition: unit.hpp:85

◆ testWrapMZWindow()

void testWrapMZWindow ( )

Definition at line 130 of file SpectrumListFactoryTest.cpp.

References pwiz::identdata::examples::initializeTiny(), pwiz::msdata::MSData::run, pwiz::msdata::Run::spectrumListPtr, unit_assert, and pwiz::analysis::SpectrumListFactory::wrap().

Referenced by test().

131 {
132  MSData msd;
134 
136  unit_assert(sl.get() && sl->size()>2);
137  SpectrumPtr spectrum = sl->spectrum(0, true);
138  vector<MZIntensityPair> data;
139  spectrum->getMZIntensityPairs(data);
140  unit_assert(data.size() == 15);
141 
142  SpectrumListFactory::wrap(msd, "mzWindow [9.5,15]");
143 
144  spectrum = sl->spectrum(0, true);
145  spectrum->getMZIntensityPairs(data);
146  unit_assert(data.size() == 5);
147 
148  spectrum = sl->spectrum(1, true);
149  spectrum->getMZIntensityPairs(data);
150  unit_assert(data.size() == 3);
151 }
boost::shared_ptr< Spectrum > SpectrumPtr
Definition: MSData.hpp:569
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument...
Definition: MSData.hpp:882
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:707
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here. Subsidiary data arrays are also both described and attached here.
Definition: MSData.hpp:823
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:845
#define unit_assert(x)
Definition: unit.hpp:85

◆ testWrapMSLevel()

void testWrapMSLevel ( )

Definition at line 154 of file SpectrumListFactoryTest.cpp.

References pwiz::identdata::examples::initializeTiny(), pwiz::msdata::MSData::run, pwiz::msdata::Run::spectrumListPtr, unit_assert, unit_assert_operator_equal, and pwiz::analysis::SpectrumListFactory::wrap().

Referenced by test().

155 {
156  MSData msd;
158 
160  unit_assert(sl.get());
161  unit_assert_operator_equal(5, sl->size());
162 
163  SpectrumListFactory::wrap(msd, "msLevel 2");
164  unit_assert_operator_equal(2, sl->size());
165  unit_assert_operator_equal("scan=20", sl->spectrumIdentity(0).id);
166 }
#define unit_assert_operator_equal(expected, actual)
Definition: unit.hpp:92
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument...
Definition: MSData.hpp:882
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:707
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here. Subsidiary data arrays are also both described and attached here.
Definition: MSData.hpp:823
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:845
#define unit_assert(x)
Definition: unit.hpp:85

◆ testWrapChargeState()

void testWrapChargeState ( )

Definition at line 169 of file SpectrumListFactoryTest.cpp.

References pwiz::identdata::examples::initializeTiny(), pwiz::msdata::MSData::run, pwiz::msdata::Run::spectrumListPtr, unit_assert_operator_equal, and pwiz::analysis::SpectrumListFactory::wrap().

Referenced by test().

170 {
171  {
172  MSData msd;
175 
176  SpectrumListFactory::wrap(msd, "chargeState 2");
177  unit_assert_operator_equal(2, sl->size());
178  unit_assert_operator_equal("scan=20", sl->spectrumIdentity(0).id);
179 
180  SpectrumListFactory::wrap(msd, "chargeState 1");
181  unit_assert_operator_equal(0, sl->size());
182  }
183 
184  {
185  MSData msd;
188 
189  SpectrumListFactory::wrap(msd, "chargeState 0-2");
190  unit_assert_operator_equal(2, sl->size());
191  unit_assert_operator_equal("scan=20", sl->spectrumIdentity(0).id);
192  }
193 }
#define unit_assert_operator_equal(expected, actual)
Definition: unit.hpp:92
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument...
Definition: MSData.hpp:882
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:707
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here. Subsidiary data arrays are also both described and attached here.
Definition: MSData.hpp:823
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:845

◆ testWrapDefaultArrayLength()

void testWrapDefaultArrayLength ( )

Definition at line 196 of file SpectrumListFactoryTest.cpp.

References pwiz::identdata::examples::initializeTiny(), pwiz::msdata::MSData::run, pwiz::msdata::Run::spectrumListPtr, unit_assert, and pwiz::analysis::SpectrumListFactory::wrap().

Referenced by test().

197 {
198  // test that the minimum length is 1 (due to 0 being the "unset" value)
199  {
200  MSData msd;
202 
204  unit_assert(sl.get());
205  unit_assert(sl->size() == 5);
206 
207  SpectrumListFactory::wrap(msd, "defaultArrayLength 0-");
208  unit_assert(sl->size() == 4);
209  unit_assert(sl->find("scan=21") == sl->size());
210  }
211 
212  // test filtering out all spectra
213  {
214  MSData msd;
217 
218  SpectrumListFactory::wrap(msd, "defaultArrayLength 100-");
219  unit_assert(sl->size() == 0);
220  }
221 
222  // test filtering out empty spectra
223  {
224  MSData msd;
227 
228  SpectrumListFactory::wrap(msd, "defaultArrayLength 1-");
229  unit_assert(sl->size() == 4);
230  unit_assert(sl->find("scan=21") == sl->size());
231  }
232 
233  // test filtering out spectra with defaultArrayLength > 14
234  {
235  MSData msd;
238 
239  SpectrumListFactory::wrap(msd, "defaultArrayLength 15-");
240  unit_assert(sl->size() == 2);
241  unit_assert(sl->find("scan=20") == sl->size());
242  unit_assert(sl->find("scan=21") == sl->size());
243  }
244 
245  // test filtering out spectra with 0 < defaultArrayLength < 15
246  {
247  MSData msd;
250 
251  SpectrumListFactory::wrap(msd, "defaultArrayLength 1-14");
252  unit_assert(sl->size() == 2);
253  unit_assert(sl->find("scan=20") == 0);
254  }
255 }
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument...
Definition: MSData.hpp:882
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:707
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here. Subsidiary data arrays are also both described and attached here.
Definition: MSData.hpp:823
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:845
#define unit_assert(x)
Definition: unit.hpp:85

◆ testWrapActivation()

void testWrapActivation ( )

Definition at line 257 of file SpectrumListFactoryTest.cpp.

References pwiz::identdata::examples::initializeTiny(), pwiz::msdata::MSData::run, pwiz::msdata::Run::spectrumListPtr, unit_assert, unit_assert_throws, and pwiz::analysis::SpectrumListFactory::wrap().

Referenced by test().

258 {
259  // test filter by CID activation
260  {
261  MSData msd;
263  SpectrumListFactory::wrap(msd, "msLevel 2-");
264  SpectrumListFactory::wrap(msd, "activation CID");
265  unit_assert(msd.run.spectrumListPtr->size() == 1);
266  }
267  // test filter by ETD activation
268  {
269  MSData msd;
271  SpectrumListFactory::wrap(msd, "msLevel 2-");
272  SpectrumListFactory::wrap(msd, "activation ETD");
273  unit_assert(msd.run.spectrumListPtr->size() == 1);
274  }
275  // test filter by HCD activation
276  {
277  MSData msd;
279  SpectrumListFactory::wrap(msd, "msLevel 2-");
280  SpectrumListFactory::wrap(msd, "activation HCD");
281  unit_assert(msd.run.spectrumListPtr->size() == 0);
282  }
283  // test filter by IRMPD activation
284  {
285  MSData msd;
287  SpectrumListFactory::wrap(msd, "msLevel 2-");
288  SpectrumListFactory::wrap(msd, "activation IRMPD");
289  unit_assert(msd.run.spectrumListPtr->size() == 0);
290  }
291  // test invalid argument
292  {
293  MSData msd;
295 
296  unit_assert_throws(SpectrumListFactory::wrap(msd, "activation UNEXPECTED_INPUT"), runtime_error);
297  }
298 }
#define unit_assert_throws(x, exception)
Definition: unit.hpp:106
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument...
Definition: MSData.hpp:882
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here. Subsidiary data arrays are also both described and attached here.
Definition: MSData.hpp:823
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:845
#define unit_assert(x)
Definition: unit.hpp:85

◆ testWrapMassAnalyzer()

void testWrapMassAnalyzer ( )

Definition at line 300 of file SpectrumListFactoryTest.cpp.

References pwiz::identdata::examples::initializeTiny(), pwiz::msdata::MSData::run, pwiz::msdata::Run::spectrumListPtr, unit_assert, unit_assert_throws, and pwiz::analysis::SpectrumListFactory::wrap().

Referenced by test().

301 {
302  // test filter by ITMS analyzer type
303  {
304  MSData msd;
306 
307  SpectrumListFactory::wrap(msd, "analyzerType ITMS");
308  unit_assert(msd.run.spectrumListPtr->size() == 5);
309  }
310  // test filter by ITMS analyzer type (new syntax)
311  {
312  MSData msd;
314 
315  SpectrumListFactory::wrap(msd, "analyzerType it");
316  unit_assert(msd.run.spectrumListPtr->size() == 5);
317  }
318  // test filter by FTMS analyzer type
319  {
320  MSData msd;
322 
323  SpectrumListFactory::wrap(msd, "analyzer FTMS");
324  unit_assert(msd.run.spectrumListPtr->size() == 0);
325  }
326  // test filter by Orbi analyzer type
327  {
328  MSData msd;
330 
331  SpectrumListFactory::wrap(msd, "analyzer Orbi");
332  unit_assert(msd.run.spectrumListPtr->size() == 0);
333  }
334  // test filter by TOF analyzer type
335  {
336  MSData msd;
338 
339  SpectrumListFactory::wrap(msd, "analyzer TOF");
340  unit_assert(msd.run.spectrumListPtr->size() == 0);
341  }
342  // test invalid argument
343  {
344  MSData msd;
346 
347  unit_assert_throws(SpectrumListFactory::wrap(msd, "analyzer UNEXPECTED_INPUT"), runtime_error)
348  }
349 }
#define unit_assert_throws(x, exception)
Definition: unit.hpp:106
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument...
Definition: MSData.hpp:882
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here. Subsidiary data arrays are also both described and attached here.
Definition: MSData.hpp:823
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:845
#define unit_assert(x)
Definition: unit.hpp:85

◆ testWrapPolarity()

void testWrapPolarity ( )

Definition at line 351 of file SpectrumListFactoryTest.cpp.

References pwiz::identdata::examples::initializeTiny(), pwiz::msdata::MSData::run, pwiz::msdata::Run::spectrumListPtr, unit_assert, unit_assert_throws, and pwiz::analysis::SpectrumListFactory::wrap().

Referenced by test().

352 {
353  // test filter by positive polarity
354  {
355  MSData msd;
357 
359  unit_assert(sl.get());
360  unit_assert(sl->size() == 5);
361 
362  SpectrumListFactory::wrap(msd, "polarity positive");
363  unit_assert(sl->size() == 3);
364  }
365  // test filter by + polarity
366  {
367  MSData msd;
369 
371  unit_assert(sl.get());
372  unit_assert(sl->size() == 5);
373 
374  SpectrumListFactory::wrap(msd, "polarity +");
375  unit_assert(sl->size() == 3);
376  }
377  // test filter by negative polarity
378  {
379  MSData msd;
381 
383  unit_assert(sl.get());
384  unit_assert(sl->size() == 5);
385 
386  SpectrumListFactory::wrap(msd, "polarity -");
387  unit_assert(sl->size() == 2);
388  }
389  // test invalid argument
390  {
391  MSData msd;
393 
395  unit_assert(sl.get());
396  unit_assert(sl->size() == 5);
397  unit_assert_throws(SpectrumListFactory::wrap(msd, "polarity UNEXPECTED_INPUT"), runtime_error)
398  }
399 }
#define unit_assert_throws(x, exception)
Definition: unit.hpp:106
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument...
Definition: MSData.hpp:882
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:707
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here. Subsidiary data arrays are also both described and attached here.
Definition: MSData.hpp:823
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:845
#define unit_assert(x)
Definition: unit.hpp:85

◆ testWrapTitleMaker()

void testWrapTitleMaker ( )

Definition at line 401 of file SpectrumListFactoryTest.cpp.

References pwiz::identdata::examples::initializeTiny(), MS_spectrum_title, pwiz::msdata::MSData::run, pwiz::msdata::Run::spectrumListPtr, unit_assert_operator_equal, and pwiz::analysis::SpectrumListFactory::wrap().

Referenced by test().

402 {
403  MSData msd;
405 
406  {
407  SpectrumListFactory::wrap(msd, "titleMaker <Id>");
409  unit_assert_operator_equal("scan=19", sl->spectrum(0)->cvParam(MS_spectrum_title).value);
410  unit_assert_operator_equal("scan=20", sl->spectrum(1)->cvParam(MS_spectrum_title).value);
411  unit_assert_operator_equal("scan=21", sl->spectrum(2)->cvParam(MS_spectrum_title).value);
412  unit_assert_operator_equal("scan=22", sl->spectrum(3)->cvParam(MS_spectrum_title).value);
413  unit_assert_operator_equal("sample=1 period=1 cycle=23 experiment=1", sl->spectrum(4)->cvParam(MS_spectrum_title).value);
414  }
415 
416  {
417  // the outer titleMaker overrides the inner one
418  SpectrumListFactory::wrap(msd, "titleMaker <Index>; <SpectrumType>, <MsLevel>");
420  unit_assert_operator_equal("0; MS1 spectrum, 1", sl->spectrum(0)->cvParam(MS_spectrum_title).value);
421  unit_assert_operator_equal("1; MSn spectrum, 2", sl->spectrum(1)->cvParam(MS_spectrum_title).value);
422  unit_assert_operator_equal("2; MS1 spectrum, 1", sl->spectrum(2)->cvParam(MS_spectrum_title).value);
423  unit_assert_operator_equal("3; MSn spectrum, 2", sl->spectrum(3)->cvParam(MS_spectrum_title).value);
424  unit_assert_operator_equal("4; MS1 spectrum, 1", sl->spectrum(4)->cvParam(MS_spectrum_title).value);
425  }
426 
427  {
428  SpectrumListFactory::wrap(msd, "titleMaker <ScanNumber> <MsLevel> <ActivationType> <ChargeState> <PrecursorSpectrumId>");
430  unit_assert_operator_equal("19 1 ", sl->spectrum(0)->cvParam(MS_spectrum_title).value);
431  unit_assert_operator_equal("20 2 CID 2 scan=19", sl->spectrum(1)->cvParam(MS_spectrum_title).value);
432  unit_assert_operator_equal("21 1 ", sl->spectrum(2)->cvParam(MS_spectrum_title).value);
433  unit_assert_operator_equal("22 2 ETD/CID 2 scan=19", sl->spectrum(3)->cvParam(MS_spectrum_title).value);
434  unit_assert_operator_equal("5 1 ", sl->spectrum(4)->cvParam(MS_spectrum_title).value);
435  }
436 }
#define unit_assert_operator_equal(expected, actual)
Definition: unit.hpp:92
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument...
Definition: MSData.hpp:882
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:707
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here. Subsidiary data arrays are also both described and attached here.
Definition: MSData.hpp:823
MS_spectrum_title
spectrum title: A free-form text title describing a spectrum.
Definition: cv.hpp:2923
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:845

◆ intializeTinyWithThermoFilter()

void intializeTinyWithThermoFilter ( MSData msd)

Definition at line 438 of file SpectrumListFactoryTest.cpp.

References pwiz::identdata::examples::initializeTiny(), MS_filter_string, pwiz::msdata::MSData::run, and pwiz::msdata::Run::spectrumListPtr.

Referenced by testWrapThermoScanFilter().

439 {
441  // add some filter data on top of the tiny scan example.
443  for (size_t i=0; i<5; ++i)
444  {
445  SpectrumPtr spectrum = sl->spectrum(i);
446  ostringstream filterLine;
447 
448  if (i == 0) // scan=19
449  filterLine << "FTMS + p NSI SIM ms [595.0000-655.0000]";
450  else if (i == 1) // scan=20
451  filterLine << "FTMS + c NSI Full ms2 " << (i + 4) * 100 << ".0000@etd30.00 [100.0000-2000.0000]";
452  else if (i == 2) // scan=21
453  filterLine << "ITMS + c NSI Full ms2 " << (i + 4) * 100 << ".0000@cid30.00 [100.0000-2000.0000]";
454  else if (i == 3) // scan=22
455  filterLine << "FTMS + p NSI SIM ms [395.0000-1005.0000]";
456  else if (i == 4) // sample=1 period=1 cycle=23 experiment=1
457  filterLine << "ITMS + c NSI Full ms2 " << (i + 4) * 100 << ".0000@hcd30.00 [100.0000-2000.0000]";
458  spectrum->scanList.scans[0].set(MS_filter_string, filterLine.str());
459  }
460 }
boost::shared_ptr< Spectrum > SpectrumPtr
Definition: MSData.hpp:569
MS_filter_string
filter string: A string unique to Thermo instrument describing instrument settings for the scan...
Definition: cv.hpp:1990
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument...
Definition: MSData.hpp:882
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:707
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here. Subsidiary data arrays are also both described and attached here.
Definition: MSData.hpp:823
PWIZ_API_DECL void initializeTiny(IdentData &mzid)

◆ testWrapThermoScanFilter()

void testWrapThermoScanFilter ( )

Definition at line 462 of file SpectrumListFactoryTest.cpp.

References intializeTinyWithThermoFilter(), pwiz::msdata::MSData::run, pwiz::msdata::Run::spectrumListPtr, unit_assert, and pwiz::analysis::SpectrumListFactory::wrap().

Referenced by test().

463 {
464  MSData msd;
466  auto originalSL = msd.run.spectrumListPtr;
467 
468  {
469  SpectrumListFactory::wrap(msd, "thermoScanFilter contains include 395.0000-1005.0000");
471  unit_assert(sl->size() == 1);
472  unit_assert(sl->spectrumIdentity(0).id == "scan=22");
473  }
474 
475  {
476  msd.run.spectrumListPtr = originalSL;
477  SpectrumListFactory::wrap(msd, "thermoScanFilter contains exclude 395.0000-1005.0000");
479  cout << sl->size()<<endl;
480  unit_assert(sl->size() == 4);
481  unit_assert(sl->spectrumIdentity(0).id == "scan=19");
482  unit_assert(sl->spectrumIdentity(1).id == "scan=20");
483  unit_assert(sl->spectrumIdentity(2).id == "scan=21");
484  unit_assert(sl->spectrumIdentity(3).id == "sample=1 period=1 cycle=23 experiment=1");
485  }
486 
487  {
488  msd.run.spectrumListPtr = originalSL;
489  SpectrumListFactory::wrap(msd, "thermoScanFilter exact include FTMS + p NSI SIM ms [395.0000-1005.0000]");
491  unit_assert(sl->size() == 1);
492  unit_assert(sl->spectrumIdentity(0).id == "scan=22");
493  }
494 
495  {
496  msd.run.spectrumListPtr = originalSL;
497  SpectrumListFactory::wrap(msd, "thermoScanFilter exact exclude TMS + p NSI SIM ms [395.0000-1005.0000]");
498  // should not exclude anything
500  unit_assert(sl->size() == 5);
501  unit_assert(sl->spectrumIdentity(0).id == "scan=19");
502  unit_assert(sl->spectrumIdentity(1).id == "scan=20");
503  unit_assert(sl->spectrumIdentity(2).id == "scan=21");
504  unit_assert(sl->spectrumIdentity(3).id == "scan=22");
505  unit_assert(sl->spectrumIdentity(4).id == "sample=1 period=1 cycle=23 experiment=1");
506  }
507 }
void intializeTinyWithThermoFilter(MSData &msd)
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument...
Definition: MSData.hpp:882
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:707
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here. Subsidiary data arrays are also both described and attached here.
Definition: MSData.hpp:823
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:845
#define unit_assert(x)
Definition: unit.hpp:85

◆ testWrapPrecursorMzSet()

void testWrapPrecursorMzSet ( )

Definition at line 509 of file SpectrumListFactoryTest.cpp.

References pwiz::identdata::examples::initializeTiny(), pwiz::msdata::MSData::run, pwiz::msdata::Run::spectrumListPtr, unit_assert_operator_equal, and pwiz::analysis::SpectrumListFactory::wrap().

Referenced by test().

510 {
511  MSData msd;
513  auto originalSL = msd.run.spectrumListPtr;
514 
515  {
516  SpectrumListFactory::wrap(msd, "mzPrecursors [445]"); // default tolerance does not match to 445.34
518  unit_assert_operator_equal(0, sl->size());
519  }
520 
521  {
522  msd.run.spectrumListPtr = originalSL;
523  SpectrumListFactory::wrap(msd, "mzPrecursors [445] mzTol=1mz");
525  unit_assert_operator_equal(1, sl->size());
526  unit_assert_operator_equal("scan=20", sl->spectrumIdentity(0).id);
527  }
528 
529  {
530  msd.run.spectrumListPtr = originalSL;
531  SpectrumListFactory::wrap(msd, "mzPrecursors [445] mzTol=1.0 mz"); // mzTol should still parse correctly with a space
533  unit_assert_operator_equal(1, sl->size());
534  unit_assert_operator_equal("scan=20", sl->spectrumIdentity(0).id);
535  }
536 
537  {
538  msd.run.spectrumListPtr = originalSL;
539  SpectrumListFactory::wrap(msd, "mzPrecursors [445.34] mode=exclude"); // only 1 MS2 left, but MS1s aren't excluded now
541  unit_assert_operator_equal(4, sl->size());
542  unit_assert_operator_equal("scan=19", sl->spectrumIdentity(0).id);
543  unit_assert_operator_equal("scan=21", sl->spectrumIdentity(1).id);
544  unit_assert_operator_equal("scan=22", sl->spectrumIdentity(2).id);
545  unit_assert_operator_equal("sample=1 period=1 cycle=23 experiment=1", sl->spectrumIdentity(3).id);
546  }
547 
548  {
549  msd.run.spectrumListPtr = originalSL;
550  SpectrumListFactory::wrap(msd, "mzPrecursors [0,445.34]"); // bring back the MS1s explicitly
552  unit_assert_operator_equal(4, sl->size());
553  unit_assert_operator_equal("scan=19", sl->spectrumIdentity(0).id);
554  unit_assert_operator_equal("scan=20", sl->spectrumIdentity(1).id);
555  unit_assert_operator_equal("scan=21", sl->spectrumIdentity(2).id);
556  unit_assert_operator_equal("sample=1 period=1 cycle=23 experiment=1", sl->spectrumIdentity(3).id);
557  }
558 }
#define unit_assert_operator_equal(expected, actual)
Definition: unit.hpp:92
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument...
Definition: MSData.hpp:882
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:707
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here. Subsidiary data arrays are also both described and attached here.
Definition: MSData.hpp:823
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:845

◆ testWrapMZPresent()

void testWrapMZPresent ( )

Definition at line 560 of file SpectrumListFactoryTest.cpp.

References pwiz::identdata::examples::initializeTiny(), pwiz::msdata::MSData::run, pwiz::msdata::Run::spectrumListPtr, unit_assert_operator_equal, and pwiz::analysis::SpectrumListFactory::wrap().

Referenced by test().

561 {
562  MSData msd;
564  auto originalSL = msd.run.spectrumListPtr;
565 
566  // tiny spectra have simple m/z lists:
567  // s19: 0,1,2,...,15 15,14,13,...,0
568  // s20: 0,2,4,6,...,20 20,18,16,...,0
569  // s21: no data points
570  // s22: 0,2,4,6,...,20 20,18,16,...,0
571  // s23: 0,1,2,...,15 15,14,13,...,0
572 
573  {
574  SpectrumListFactory::wrap(msd, "mzPresent [1.6] type=count threshold=100 orientation=most-intense");
576  unit_assert_operator_equal(4, sl->size());
577  unit_assert_operator_equal("scan=19", sl->spectrumIdentity(0).id);
578  unit_assert_operator_equal("scan=20", sl->spectrumIdentity(1).id);;
579  unit_assert_operator_equal("scan=22", sl->spectrumIdentity(2).id);
580  unit_assert_operator_equal("sample=1 period=1 cycle=23 experiment=1", sl->spectrumIdentity(3).id);
581  }
582 
583  {
584  msd.run.spectrumListPtr = originalSL;
585  SpectrumListFactory::wrap(msd, "mzPresent [1.6] mzTol=1 ppm"); // mzTol should still parse correctly with a space; with this tight tolereance no spectra will match
587  unit_assert_operator_equal(0, sl->size());
588  }
589 
590  {
591  msd.run.spectrumListPtr = originalSL;
592  SpectrumListFactory::wrap(msd, "mzPresent [0]");
594  unit_assert_operator_equal(4, sl->size());
595  }
596 
597  {
598  msd.run.spectrumListPtr = originalSL;
599  SpectrumListFactory::wrap(msd, "mzPresent [0] type=absolute threshold=17 orientation=most-intense mode=include");
601  unit_assert_operator_equal(2, sl->size());
602  unit_assert_operator_equal("scan=20", sl->spectrumIdentity(0).id);
603  unit_assert_operator_equal("scan=22", sl->spectrumIdentity(1).id);
604  }
605 
606  {
607  msd.run.spectrumListPtr = originalSL;
608  SpectrumListFactory::wrap(msd, "mzPresent [0] type=absolute threshold=17 orientation=most-intense mode=exclude");
610  unit_assert_operator_equal(3, sl->size());
611  unit_assert_operator_equal("scan=19", sl->spectrumIdentity(0).id);
612  unit_assert_operator_equal("scan=21", sl->spectrumIdentity(1).id);
613  unit_assert_operator_equal("sample=1 period=1 cycle=23 experiment=1", sl->spectrumIdentity(2).id);
614  }
615 }
#define unit_assert_operator_equal(expected, actual)
Definition: unit.hpp:92
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument...
Definition: MSData.hpp:882
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:707
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here. Subsidiary data arrays are also both described and attached here.
Definition: MSData.hpp:823
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:845

◆ test()

void test ( )

Definition at line 618 of file SpectrumListFactoryTest.cpp.

References testUsage(), testWrap(), testWrapActivation(), testWrapChargeState(), testWrapDefaultArrayLength(), testWrapMassAnalyzer(), testWrapMSLevel(), testWrapMZPresent(), testWrapMZWindow(), testWrapPolarity(), testWrapPrecursorMzSet(), testWrapScanTimeRange(), testWrapSortScanTime(), testWrapThermoScanFilter(), and testWrapTitleMaker().

Referenced by main().

619 {
620  testUsage();
621  testWrap();
625  testWrapMSLevel();
635 }
void testWrapScanTimeRange()
void testWrapMassAnalyzer()
void testWrapTitleMaker()
void testWrapMZPresent()
void testWrapActivation()
void testWrapDefaultArrayLength()
void testUsage()
void testWrapThermoScanFilter()
void testWrap()
void testWrapMZWindow()
void testWrapMSLevel()
void testWrapPrecursorMzSet()
void testWrapChargeState()
void testWrapSortScanTime()
void testWrapPolarity()

◆ main()

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

Definition at line 638 of file SpectrumListFactoryTest.cpp.

References os_, test(), TEST_EPILOG, TEST_FAILED, and TEST_PROLOG.

639 {
640  TEST_PROLOG(argc, argv)
641 
642  try
643  {
644  if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
645  test();
646  }
647  catch (exception& e)
648  {
649  TEST_FAILED(e.what())
650  }
651  catch (...)
652  {
653  TEST_FAILED("Caught unknown exception.")
654  }
655 
657 }
#define TEST_EPILOG
Definition: unit.hpp:182
ostream * os_
#define TEST_FAILED(x)
Definition: unit.hpp:176
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:174

Variable Documentation

◆ os_

ostream* os_ = 0

Definition at line 36 of file SpectrumListFactoryTest.cpp.

Referenced by main(), and testUsage().