ProteoWizard
SpectrumList_FilterTest.cpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Darren Kessner <darren@proteowizard.org>
6//
7// Copyright 2008 Spielberg Family Center for Applied Proteomics
8// Cedars-Sinai Medical Center, Los Angeles, California 90048
9//
10// Licensed under the Apache License, Version 2.0 (the "License");
11// you may not use this file except in compliance with the License.
12// You may obtain a copy of the License at
13//
14// http://www.apache.org/licenses/LICENSE-2.0
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS,
18// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19// See the License for the specific language governing permissions and
20// limitations under the License.
21//
22
23
30#include <cstring>
31
32
33using namespace pwiz;
34using namespace pwiz::msdata;
35using namespace pwiz::analysis;
36using namespace pwiz::util;
37using boost::logic::tribool;
38
39
40ostream* os_ = 0;
41
42
43void printSpectrumList(const SpectrumList& sl, ostream& os)
44{
45 os << "size: " << sl.size() << endl;
46
47 for (size_t i=0, end=sl.size(); i<end; i++)
48 {
49 SpectrumPtr spectrum = sl.spectrum(i, false);
50 os << spectrum->index << " "
51 << spectrum->id << " "
52 << "ms" << spectrum->cvParam(MS_ms_level).value << " "
53 << "scanEvent:" << spectrum->scanList.scans[0].cvParam(MS_preset_scan_configuration).value << " "
54 << "scanTime:" << spectrum->scanList.scans[0].cvParam(MS_scan_start_time).timeInSeconds() << " "
55 << "scanFilter:" << spectrum->scanList.scans[0].cvParam(MS_filter_string).value << " "
56 << endl;
57 }
58}
59
60
62{
64
65 for (size_t i=0; i<11; ++i)
66 {
67 SpectrumPtr spectrum(new Spectrum);
68 spectrum->index = i;
69 spectrum->id = "scan=" + lexical_cast<string>(100+i);
70 spectrum->setMZIntensityPairs(vector<MZIntensityPair>(i), MS_number_of_detector_counts);
71
72 // add mz/intensity to the spectra for mzPresent filter
73 vector<MZIntensityPair> mzint(i*2);
74 for (size_t j=1.0; j<i*2; ++j)
75 {
76 mzint.insert(mzint.end(), MZIntensityPair(j*100, j*j));
77 }
78 spectrum->setMZIntensityPairs(mzint, MS_number_of_detector_counts);
79
80 if (i == 10)
81 {
82 spectrum->set(MS_emission_spectrum);
83 sl->spectra.push_back(spectrum);
84 continue;
85 }
86
87 bool isMS1 = i%3==0;
88 spectrum->set(MS_ms_level, isMS1 ? 1 : 2);
89 spectrum->set(isMS1 ? MS_MS1_spectrum : MS_MSn_spectrum);
90
91 // outfit the spectra with mass analyzer definitions to test the massAnalyzer filter
92 spectrum->scanList.scans.push_back(Scan());
93
94 spectrum->scanList.scans[0].instrumentConfigurationPtr = InstrumentConfigurationPtr(new InstrumentConfiguration());
95 InstrumentConfigurationPtr p = spectrum->scanList.scans[0].instrumentConfigurationPtr;
96 if (i%3 == 0)
97 {
98 p->componentList.push_back(Component(MS_orbitrap, 0/*order*/));
99 }
100 else
101 {
102 if (i % 2)
103 {
104 p->componentList.push_back(Component(MS_quadrupole, 0/*order*/));
105 p->componentList.push_back(Component(MS_orbitrap, 1/*order*/));
106 }
107 else
108 p->componentList.push_back(Component(MS_radial_ejection_linear_ion_trap, 0/*order*/));
109 }
110
111 // add thermo scan filter lines to the MS1 spectra
112 // MS1
113 if (i == 0 || i == 6) // narrow window MS1
114 {
115 spectrum->scanList.scans[0].set(MS_filter_string, "FTMS + p NSI SIM ms [595.0000-655.0000]");
116 }
117 else if (i == 3 || i == 9) // wide window MS1
118 {
119 spectrum->scanList.scans[0].set(MS_filter_string, "FTMS + p NSI SIM ms [395.0000-1005.0000]");
120 }
121
122 if (i%3 != 0)
123 spectrum->precursors.push_back(Precursor((i+4)*100, 3));
124
125 // add precursors, activation types, and thermo scan filter lines to the MS2 spectra
126 ostringstream filterLine;
127 if (i==1 || i ==5) // ETD
128 {
129 spectrum->precursors[0].activation.set(MS_electron_transfer_dissociation);
130 filterLine << "FTMS + c NSI Full ms2 " << (i + 4) * 100 << ".0000@etd30.00 [100.0000-2000.0000]";
131 }
132 else if (i==2) // CID
133 {
134 spectrum->precursors[0].activation.set(MS_collision_induced_dissociation);
135 filterLine << "ITMS + c NSI Full ms2 " << (i + 4) * 100 << ".0000@cid30.00 [100.0000-2000.0000]";
136 }
137 else if (i==4) // HCD
138 {
139 spectrum->precursors[0].activation.set(MS_HCD);
140 filterLine << "ITMS + c NSI Full ms2 " << (i + 4) * 100 << ".0000@hcd30.00 [100.0000-2000.0000]";
141 }
142 else if (i==8) // IRMPD
143 {
144 spectrum->precursors[0].activation.set(MS_IRMPD);
145 filterLine << "ITMS + c NSI Full ms2 " << (i + 4) * 100 << ".0000@irmpd30.00 [100.0000-2000.0000]";
146 }
147 else if (i==7) // ETD + SA
148 {
149 spectrum->precursors[0].activation.set(MS_electron_transfer_dissociation);
150 spectrum->precursors[0].activation.set(MS_collision_induced_dissociation);
151 filterLine << "FTMS + c NSI Full ms2 " << (i + 4) * 100 << ".0000@irmpd30.00 [100.0000-2000.0000]";
152 }
153
154 spectrum->scanList.scans.push_back(Scan());
155 spectrum->scanList.scans[0].set(MS_preset_scan_configuration, i%4);
156 spectrum->scanList.scans[0].set(MS_scan_start_time, 420+i, UO_second);
157 if (i % 3 != 0)
158 spectrum->scanList.scans[0].set(MS_filter_string, filterLine.str());
159 sl->spectra.push_back(spectrum);
160 }
161
162 if (os_)
163 {
164 *os_ << "original spectrum list:\n";
165 printSpectrumList(*sl, *os_);
166 *os_ << endl;
167 }
168
169 return sl;
170}
171
172
174{
175 virtual tribool accept(const SpectrumIdentity& spectrumIdentity) const
176 {
177 return spectrumIdentity.index%2 == 0;
178 }
179
180 virtual string describe() const { return ""; }
181};
182
183
185{
186 if (os_) *os_ << "testEven:\n";
187
189
190 if (os_)
191 {
192 printSpectrumList(filter, *os_);
193 *os_ << endl;
194 }
195
196 unit_assert(filter.size() == 6);
197
198 for (size_t i=0, end=filter.size(); i<end; i++)
199 {
200 const SpectrumIdentity& id = filter.spectrumIdentity(i);
201 unit_assert(id.index == i);
202 unit_assert(id.id == "scan=" + lexical_cast<string>(100+i*2));
203
204 SpectrumPtr spectrum = filter.spectrum(i);
205 unit_assert(spectrum->index == i);
206 unit_assert(spectrum->id == "scan=" + lexical_cast<string>(100+i*2));
207 }
208}
209
210
212{
213 virtual tribool accept(const SpectrumIdentity& spectrumIdentity) const
214 {
215 if (spectrumIdentity.index%2 != 0) return false;
216 return boost::logic::indeterminate;
217 }
218
219 virtual tribool accept(const Spectrum& spectrum) const
220 {
221 CVParam param = spectrum.cvParamChild(MS_spectrum_type);
222 if (param.cvid == CVID_Unknown) return boost::logic::indeterminate;
223 if (!cvIsA(param.cvid, MS_mass_spectrum))
224 return false;
225
226 param = spectrum.cvParam(MS_ms_level);
227 if (param.cvid == CVID_Unknown) return boost::logic::indeterminate;
228
229 return (param.valueAs<int>() == 2);
230 }
231
232 virtual string describe() const { return ""; }
233};
234
235
237{
238 if (os_) *os_ << "testEvenMS2:\n";
239
241
242 if (os_)
243 {
244 printSpectrumList(filter, *os_);
245 *os_ << endl;
246 }
247
248 unit_assert(filter.size() == 3);
249 unit_assert(filter.spectrumIdentity(0).id == "scan=102");
250 unit_assert(filter.spectrumIdentity(1).id == "scan=104");
251 unit_assert(filter.spectrumIdentity(2).id == "scan=108");
252}
253
254
256{
257 mutable bool pastMaxIndex;
258
260
261 virtual tribool accept(const SpectrumIdentity& spectrumIdentity) const
262 {
263 if (spectrumIdentity.index>5) pastMaxIndex = true;
264
265 return (spectrumIdentity.index==1 ||
266 spectrumIdentity.index==3 ||
267 spectrumIdentity.index==5);
268 }
269
270 virtual bool done() const
271 {
272 return pastMaxIndex;
273 }
274
275 virtual string describe() const { return ""; }
276};
277
278
280{
281 if (os_) *os_ << "testSelectedIndices:\n";
282
284
285 if (os_)
286 {
287 printSpectrumList(filter, *os_);
288 *os_ << endl;
289 }
290
291 unit_assert(filter.size() == 3);
292 unit_assert(filter.spectrumIdentity(0).id == "scan=101");
293 unit_assert(filter.spectrumIdentity(1).id == "scan=103");
294 unit_assert(filter.spectrumIdentity(2).id == "scan=105");
295}
296
297
299{
301
304
305 virtual tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const
306 {
307 return boost::logic::indeterminate;
308 }
309
310 virtual tribool accept(const Spectrum& spectrum) const
311 {
312 if (spectrum.binaryDataArrayPtrs.empty())
313 return boost::logic::indeterminate;
314 return !spectrum.binaryDataArrayPtrs[0]->data.empty();
315 }
316
317 virtual string describe() const { return ""; }
318};
319
320
322{
323 if (os_) *os_ << "testHasBinaryData:\n";
324
325 MSData msd;
327
328 shared_ptr<stringstream> ss(new stringstream);
329 Serializer_mzML serializer;
330 serializer.write(*ss, msd);
331
332 MSData msd2;
333 serializer.read(ss, msd2);
334
335 sl = msd2.run.spectrumListPtr;
336
337 {
339 unit_assert(filter.empty());
340 }
341
342 {
344
345 if (os_)
346 {
347 printSpectrumList(filter, *os_);
348 *os_ << endl;
349 }
350
351 unit_assert_operator_equal(4, filter.size());
352 }
353}
354
355
357{
358 if (os_) *os_ << "testIndexSet:\n";
359
360 IntegerSet indexSet;
361 indexSet.insert(3,5);
362 indexSet.insert(7);
363 indexSet.insert(9);
364
366
367 if (os_)
368 {
369 printSpectrumList(filter, *os_);
370 *os_ << endl;
371 }
372
373 unit_assert(filter.size() == 5);
374 unit_assert(filter.spectrumIdentity(0).id == "scan=103");
375 unit_assert(filter.spectrumIdentity(1).id == "scan=104");
376 unit_assert(filter.spectrumIdentity(2).id == "scan=105");
377 unit_assert(filter.spectrumIdentity(3).id == "scan=107");
378 unit_assert(filter.spectrumIdentity(4).id == "scan=109");
379}
380
381
383{
384 if (os_) *os_ << "testScanNumberSet:\n";
385
386 IntegerSet scanNumberSet;
387 scanNumberSet.insert(102,104);
388 scanNumberSet.insert(107);
389
391
392 if (os_)
393 {
394 printSpectrumList(filter, *os_);
395 *os_ << endl;
396 }
397
398 unit_assert(filter.size() == 4);
399 unit_assert(filter.spectrumIdentity(0).id == "scan=102");
400 unit_assert(filter.spectrumIdentity(1).id == "scan=103");
401 unit_assert(filter.spectrumIdentity(2).id == "scan=104");
402 unit_assert(filter.spectrumIdentity(3).id == "scan=107");
403}
404
405
407{
408 if (os_) *os_ << "testScanEventSet:\n";
409
410 IntegerSet scanEventSet;
411 scanEventSet.insert(0,0);
412 scanEventSet.insert(2,3);
413
415
416 if (os_)
417 {
418 printSpectrumList(filter, *os_);
419 *os_ << endl;
420 }
421
422 unit_assert(filter.size() == 7);
423 unit_assert(filter.spectrumIdentity(0).id == "scan=100");
424 unit_assert(filter.spectrumIdentity(1).id == "scan=102");
425 unit_assert(filter.spectrumIdentity(2).id == "scan=103");
426 unit_assert(filter.spectrumIdentity(3).id == "scan=104");
427 unit_assert(filter.spectrumIdentity(4).id == "scan=106");
428 unit_assert(filter.spectrumIdentity(5).id == "scan=107");
429 unit_assert(filter.spectrumIdentity(6).id == "scan=108");
430}
431
432
434{
435 if (os_) *os_ << "testScanTimeRange:\n";
436
437 const double low = 422.5;
438 const double high = 427.5;
439
441
442 if (os_)
443 {
444 printSpectrumList(filter, *os_);
445 *os_ << endl;
446 }
447
448 unit_assert(filter.size() == 5);
449 unit_assert(filter.spectrumIdentity(0).id == "scan=103");
450 unit_assert(filter.spectrumIdentity(1).id == "scan=104");
451 unit_assert(filter.spectrumIdentity(2).id == "scan=105");
452 unit_assert(filter.spectrumIdentity(3).id == "scan=106");
453 unit_assert(filter.spectrumIdentity(4).id == "scan=107");
454}
455
456
458{
459 if (os_) *os_ << "testMSLevelSet:\n";
460
461 {
462 IntegerSet msLevelSet;
463 msLevelSet.insert(1);
464
466
467 if (os_)
468 {
469 printSpectrumList(filter, *os_);
470 *os_ << endl;
471 }
472
473 unit_assert(filter.size() == 4);
474 unit_assert(filter.spectrumIdentity(0).id == "scan=100");
475 unit_assert(filter.spectrumIdentity(1).id == "scan=103");
476 unit_assert(filter.spectrumIdentity(2).id == "scan=106");
477 unit_assert(filter.spectrumIdentity(3).id == "scan=109");
478 }
479
480 {
481 IntegerSet msLevelSet;
482 msLevelSet.insert(2);
483
485
486 if (os_)
487 {
488 printSpectrumList(filter, *os_);
489 *os_ << endl;
490 }
491
492 unit_assert(filter.size() == 6);
493 unit_assert(filter.spectrumIdentity(0).id == "scan=101");
494 unit_assert(filter.spectrumIdentity(1).id == "scan=102");
495 unit_assert(filter.spectrumIdentity(2).id == "scan=104");
496 unit_assert(filter.spectrumIdentity(3).id == "scan=105");
497 unit_assert(filter.spectrumIdentity(4).id == "scan=107");
498 unit_assert(filter.spectrumIdentity(5).id == "scan=108");
499 }
500
501 {
502 IntegerSet msLevelSet;
503 msLevelSet.insert(0);
504
506
507 if (os_)
508 {
509 printSpectrumList(filter, *os_);
510 *os_ << endl;
511 }
512
513 unit_assert_operator_equal(1, filter.size());
514 unit_assert(filter.spectrumIdentity(0).id == "scan=110");
515 }
516}
517
519{
520 if (os_) *os_ << "testMS2Activation:\n";
521
523
524 set<CVID> cvIDs;
525 // CID
527 cvIDs.insert(MS_HCD);
528 cvIDs.insert(MS_IRMPD);
529 SpectrumList_Filter filter(ms2filter,
531
532 if (os_)
533 {
534 printSpectrumList(filter, *os_);
535 *os_ << endl;
536 }
537
538 unit_assert(filter.size() == 1);
539 unit_assert(filter.spectrumIdentity(0).id == "scan=102");
540
541 // ETD + SA
542 cvIDs.clear();
545 SpectrumList_Filter filter1(ms2filter,
547 if (os_)
548 {
549 printSpectrumList(filter1, *os_);
550 *os_ << endl;
551 }
552
553 unit_assert(filter1.size() == 1);
554 unit_assert(filter1.spectrumIdentity(0).id == "scan=107");
555
556 // ETD
557 cvIDs.clear();
559 SpectrumList_Filter filter2(ms2filter,
561 if (os_)
562 {
563 printSpectrumList(filter2, *os_);
564 *os_ << endl;
565 }
566
567 unit_assert(filter2.size() == 3);
568 unit_assert(filter2.spectrumIdentity(0).id == "scan=101");
569 unit_assert(filter2.spectrumIdentity(1).id == "scan=105");
570 unit_assert(filter2.spectrumIdentity(2).id == "scan=107");
571
572 // HCD
573 cvIDs.clear();
574 cvIDs.insert(MS_HCD);
575 SpectrumList_Filter filter3(ms2filter,
577 if (os_)
578 {
579 printSpectrumList(filter3, *os_);
580 *os_ << endl;
581 }
582
583 unit_assert(filter3.size() == 1);
584 unit_assert(filter3.spectrumIdentity(0).id == "scan=104");
585
586 // IRMPD
587 cvIDs.clear();
588 cvIDs.insert(MS_IRMPD);
589 SpectrumList_Filter filter4(ms2filter,
591 if (os_)
592 {
593 printSpectrumList(filter4, *os_);
594 *os_ << endl;
595 }
596
597 unit_assert(filter4.size() == 1);
598 unit_assert(filter4.spectrumIdentity(0).id == "scan=108");
599
600}
601
603{
604 if (os_) *os_ << "testMassAnalyzerFilter:\n";
605
606 set<CVID> cvIDs;
607 // msconvert mass analyzer filter FTMS option
608 cvIDs.insert(MS_orbitrap);
610 SpectrumList_Filter filter(sl,
612
613 if (os_)
614 {
615 printSpectrumList(filter, *os_);
616 *os_ << endl;
617 }
618
619 unit_assert(filter.size() == 7);
620 unit_assert(filter.spectrumIdentity(0).id == "scan=100");
621
622 cvIDs.clear();
623 // msconvert mass analyzer filter ITMS option
624 cvIDs.insert(MS_ion_trap);
625
626 SpectrumList_Filter filter1(sl,
628
629 if (os_)
630 {
631 printSpectrumList(filter1, *os_);
632 *os_ << endl;
633 }
634
635 unit_assert(filter1.size() == 3);
636 unit_assert(filter1.spectrumIdentity(0).id == "scan=102");
637}
638
640{
641 if (os_) *os_ << "testMZPresentFilter:\n";
642
643 // test mzpresent on MS level 2 (include test)
645 chemistry::MZTolerance mzt(3.0);
646 std::set<double> mzSet;
647 mzSet.insert(200.0);
648 mzSet.insert(300.0);
649 mzSet.insert(400.0);
650 double threshold = 10;
651 IntegerSet msLevels(1, INT_MAX);
654
655 if (os_)
656 {
657 printSpectrumList(filter, *os_);
658 *os_ << endl;
659 }
660 unit_assert_operator_equal(4, filter.size());
661 unit_assert_operator_equal("scan=102", filter.spectrumIdentity(0).id);
662 unit_assert_operator_equal("scan=104", filter.spectrumIdentity(1).id);
663 unit_assert_operator_equal("scan=105", filter.spectrumIdentity(2).id);
664 unit_assert_operator_equal("scan=107", filter.spectrumIdentity(3).id);
665
666 // test mz present on MS level 1 (exclude test)
668 chemistry::MZTolerance mzt1(3.0);
669 std::set<double> mzSet1;
670 mzSet1.insert(200.0);
671 mzSet1.insert(300.0);
672 double threshold1 = 5;
675
676 if (os_)
677 {
678 printSpectrumList(filter1, *os_);
679 *os_ << endl;
680 }
681 unit_assert_operator_equal(3, filter1.size());
682 unit_assert_operator_equal("scan=100", filter1.spectrumIdentity(0).id);
683 unit_assert_operator_equal("scan=106", filter1.spectrumIdentity(1).id);
684 unit_assert_operator_equal("scan=109", filter1.spectrumIdentity(2).id);
685}
686
688{
689 if (os_) *os_ << "testThermoFilterFilter:\n";
690
691 // test for query of "395.0000-1005.0000" using contains (include)
692 string queryString = "395.0000-1005.0000";
693 SpectrumList_Filter filter1(sl, SpectrumList_FilterPredicate_ThermoScanFilter(queryString, false, false));
694 if (os_)
695 {
696 *os_ << "Including all spectra that contain " << queryString << endl;
697 printSpectrumList(filter1, *os_);
698 *os_ << endl;
699 }
700 unit_assert(filter1.size() == 2);
701 unit_assert(filter1.spectrumIdentity(0).id == "scan=103");
702 unit_assert(filter1.spectrumIdentity(1).id == "scan=109");
703
704 // test for query of "395.0000-1005.0000" using contains (exclude)
705 SpectrumList_Filter filter2(sl, SpectrumList_FilterPredicate_ThermoScanFilter(queryString, false, true));
706 if (os_)
707 {
708 *os_ << "Excluding all spectra that contain " << queryString << endl;
709 printSpectrumList(filter2, *os_);
710 *os_ << endl;
711 }
712 unit_assert(filter2.size() == 8);
713 unit_assert(filter2.spectrumIdentity(0).id == "scan=100");
714 unit_assert(filter2.spectrumIdentity(1).id == "scan=101");
715 unit_assert(filter2.spectrumIdentity(2).id == "scan=102");
716 unit_assert(filter2.spectrumIdentity(3).id == "scan=104");
717 unit_assert(filter2.spectrumIdentity(4).id == "scan=105");
718 unit_assert(filter2.spectrumIdentity(5).id == "scan=106");
719 unit_assert(filter2.spectrumIdentity(6).id == "scan=107");
720 unit_assert(filter2.spectrumIdentity(7).id == "scan=108");
721
722 // test for query of "ms2" using contains (exclude)
723 queryString = "ms2";
724 SpectrumList_Filter filter3(sl, SpectrumList_FilterPredicate_ThermoScanFilter(queryString, false, true));
725 if (os_)
726 {
727 *os_ << "Excluding all spectra that contain " << queryString << endl;
728 printSpectrumList(filter3, *os_);
729 *os_ << endl;
730 }
731 unit_assert(filter3.size() == 4);
732 unit_assert(filter3.spectrumIdentity(0).id == "scan=100");
733 unit_assert(filter3.spectrumIdentity(1).id == "scan=103");
734 unit_assert(filter3.spectrumIdentity(2).id == "scan=106");
735 unit_assert(filter3.spectrumIdentity(3).id == "scan=109");
736
737 // test for exact query of "FTMS + p NSI SIM ms [395.0000-1005.0000]" (include)
738 queryString = "FTMS + p NSI SIM ms [395.0000-1005.0000]";
739 SpectrumList_Filter filter4(sl, SpectrumList_FilterPredicate_ThermoScanFilter(queryString, true, false));
740 if (os_)
741 {
742 *os_ << "Including all spectra that exactly match " << queryString << endl;
743 printSpectrumList(filter4, *os_);
744 *os_ << endl;
745 }
746 unit_assert(filter4.size() == 2);
747 unit_assert(filter4.spectrumIdentity(0).id == "scan=103");
748 unit_assert(filter4.spectrumIdentity(1).id == "scan=109");
749
750 // test for exact query of "FTMS + p NSI SIM ms [395.0000-1005.0000]" (exclude)
751 queryString = "FTMS + p NSI SIM ms [395.0000-1005.0000]";
752 SpectrumList_Filter filter5(sl, SpectrumList_FilterPredicate_ThermoScanFilter(queryString, true, true));
753 if (os_)
754 {
755 *os_ << "Excluding all spectra that exactly match " << queryString << endl;
756 printSpectrumList(filter5, *os_);
757 *os_ << endl;
758 }
759 unit_assert(filter5.size() == 8);
760 unit_assert(filter5.spectrumIdentity(0).id == "scan=100");
761 unit_assert(filter5.spectrumIdentity(1).id == "scan=101");
762 unit_assert(filter5.spectrumIdentity(2).id == "scan=102");
763 unit_assert(filter5.spectrumIdentity(3).id == "scan=104");
764 unit_assert(filter5.spectrumIdentity(4).id == "scan=105");
765 unit_assert(filter5.spectrumIdentity(5).id == "scan=106");
766 unit_assert(filter5.spectrumIdentity(6).id == "scan=107");
767 unit_assert(filter5.spectrumIdentity(7).id == "scan=108");
768}
769
787
788
789int main(int argc, char* argv[])
790{
791 TEST_PROLOG(argc, argv)
792
793 try
794 {
795 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
796 test();
797 }
798 catch (exception& e)
799 {
800 TEST_FAILED(e.what())
801 }
802 catch (...)
803 {
804 TEST_FAILED("Caught unknown exception.")
805 }
806
808}
809
810
void testScanEventSet(SpectrumListPtr sl)
int main(int argc, char *argv[])
void testMSLevelSet(SpectrumListPtr sl)
void testHasBinaryData(SpectrumListPtr sl)
void testMZPresentFilter(SpectrumListPtr sl)
void testEvenMS2(SpectrumListPtr sl)
void testScanNumberSet(SpectrumListPtr sl)
void testEven(SpectrumListPtr sl)
void testMassAnalyzerFilter(SpectrumListPtr sl)
void testThermoFilterFilter(SpectrumListPtr sl)
void testScanTimeRange(SpectrumListPtr sl)
void printSpectrumList(const SpectrumList &sl, ostream &os)
void testMS2Activation(SpectrumListPtr sl)
ostream * os_
SpectrumListPtr createSpectrumList()
void testIndexSet(SpectrumListPtr sl)
void testSelectedIndices(SpectrumListPtr sl)
SpectrumList filter, for creating Spectrum sub-lists.
virtual const msdata::SpectrumIdentity & spectrumIdentity(size_t index) const
access to a spectrum index
virtual size_t size() const
returns the number of spectra
MSData <-> mzML stream serialization.
void write(std::ostream &os, const MSData &msd, const pwiz::util::IterationListenerRegistry *iterationListenerRegistry=0) const
write MSData object to ostream as mzML; iterationListenerRegistry may be used to receive progress upd...
void read(boost::shared_ptr< std::istream > is, MSData &msd) const
read in MSData object from an mzML istream note: istream may be managed by MSData's SpectrumList,...
Interface for accessing spectra, which may be stored in memory or backed by a data file (RAW,...
Definition MSData.hpp:661
virtual size_t size() const =0
returns the number of spectra
virtual SpectrumPtr spectrum(size_t index, bool getBinaryData=false) const =0
retrieve a spectrum by index
a virtual container of integers, accessible via an iterator interface, stored as union of intervals
void insert(Interval interval)
insert an interval of integers into the virtual container
MS_spectrum_type
spectrum type: Spectrum type.
Definition cv.hpp:2286
MS_MS1_spectrum
MS1 spectrum: Mass spectrum created by a single-stage MS experiment or the first stage of a multi-sta...
Definition cv.hpp:2349
MS_HCD
HCD (beam-type collision-induced dissociation): A collision-induced dissociation process that occurs ...
Definition cv.hpp:1842
MS_collision_induced_dissociation
collision-induced dissociation: The dissociation of an ion after collisional excitation....
Definition cv.hpp:747
MS_fourier_transform_ion_cyclotron_resonance_mass_spectrometer
fourier transform ion cyclotron resonance mass spectrometer: A mass spectrometer based on the princip...
Definition cv.hpp:534
MS_quadrupole
quadrupole: A mass spectrometer that consists of four parallel rods whose centers form the corners of...
Definition cv.hpp:543
MS_ms_level
ms level: Stages of ms achieved in a multi stage mass spectrometry experiment.
Definition cv.hpp:2139
MS_orbitrap
orbitrap: An ion trapping device that consists of an outer barrel-like electrode and a coaxial inner ...
Definition cv.hpp:2052
MS_IRMPD
IRMPD (infrared multiphoton dissociation): Multiphoton ionization where the reactant ion dissociates ...
Definition cv.hpp:1269
MS_MSn_spectrum
MSn spectrum: MSn refers to multi-stage MS2 experiments designed to record product ion spectra where ...
Definition cv.hpp:2364
MS_mass_spectrum
mass spectrum: A plot of the relative abundance of a beam or other collection of ions as a function o...
Definition cv.hpp:1443
CVID_Unknown
Definition cv.hpp:114
MS_radial_ejection_linear_ion_trap
radial ejection linear ion trap: A linear ion trap mass spectrometer where ions are ejected along the...
Definition cv.hpp:558
MS_filter_string
filter string: A string unique to Thermo instrument describing instrument settings for the scan.
Definition cv.hpp:2142
MS_preset_scan_configuration
preset scan configuration: A user-defined scan configuration that specifies the instrumental settings...
Definition cv.hpp:2511
MS_emission_spectrum
emission spectrum: A plot of the relative intensity of electromagnetic radiation emitted by atoms or ...
Definition cv.hpp:3111
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:309
MS_ion_trap
ion trap: A device for spatially confining ions using electric and magnetic fields alone or in combin...
Definition cv.hpp:1278
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
MS_electron_transfer_dissociation
electron transfer dissociation: A process to fragment ions in a mass spectrometer by inducing fragmen...
Definition cv.hpp:2448
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:13833
PWIZ_API_DECL bool cvIsA(CVID child, CVID parent)
returns true iff child IsA parent in the CV
PWIZ_API_DECL void initializeTiny(MSData &msd)
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition MSData.hpp:711
boost::shared_ptr< Spectrum > SpectrumPtr
Definition MSData.hpp:573
boost::shared_ptr< InstrumentConfiguration > InstrumentConfigurationPtr
Definition MSData.hpp:250
boost::shared_ptr< SpectrumListSimple > SpectrumListSimplePtr
Definition MSData.hpp:731
@ DetailLevel_FullData
Definition MSData.hpp:635
@ DetailLevel_FullMetadata
Definition MSData.hpp:634
virtual tribool accept(const SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...
virtual string describe() const
return a string describing how the predicate filters
virtual tribool accept(const Spectrum &spectrum) const
return true iff Spectrum is accepted
virtual string describe() const
return a string describing how the predicate filters
virtual tribool accept(const SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...
virtual tribool accept(const Spectrum &spectrum) const
return true iff Spectrum is accepted
virtual DetailLevel suggestedDetailLevel() const
can be overridden in subclasses that know they will need a certain detail level; it must be overridde...
virtual string describe() const
return a string describing how the predicate filters
HasBinaryDataPredicate(DetailLevel suggestedDetailLevel)
virtual tribool accept(const msdata::SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...
virtual string describe() const
return a string describing how the predicate filters
virtual tribool accept(const SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...
virtual bool done() const
return true iff done accepting chromatograms; this allows early termination of the iteration through ...
client-implemented filter predicate – called during construction of SpectrumList_Filter to create the...
@ ThresholdingBy_Count
keep the <threshold> [most|least] intense data points
struct for expressing m/z tolerance in either amu or ppm
represents a tag-value pair, where the tag comes from the controlled vocabulary
value_type valueAs() const
templated value access with type conversion
CVParam cvParam(CVID cvid) const
finds cvid in the container:
CVParam cvParamChild(CVID cvid) const
finds child of cvid in the container:
A component of an instrument corresponding to a source (i.e. ion source), an analyzer (i....
Definition MSData.hpp:132
Description of a particular hardware configuration of a mass spectrometer. Each configuration MUST ha...
Definition MSData.hpp:230
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
The data point type of a mass spectrum.
Definition MSData.hpp:423
The method of precursor ion selection and activation.
Definition MSData.hpp:312
SpectrumListPtr spectrumListPtr
all mass spectra and the acquisitions underlying them are described and attached here....
Definition MSData.hpp:827
The structure that captures the generation of a peak list (including the underlying acquisitions)
Definition MSData.hpp:506
std::vector< BinaryDataArrayPtr > binaryDataArrayPtrs
list of binary data arrays.
Definition MSData.hpp:526
Identifying information for a spectrum.
Definition MSData.hpp:471
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
Simple writeable in-memory implementation of SpectrumList.
Definition MSData.hpp:717
#define unit_assert(x)
Definition unit.hpp:85
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define unit_assert_operator_equal(expected, actual)
Definition unit.hpp:92
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175