ProteoWizard
SpectrumList_FilterTest.cpp
Go to the documentation of this file.
1 //
2 // $Id: SpectrumList_FilterTest.cpp 10650 2017-03-27 21:23:14Z chambm $
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 
24 #include "SpectrumList_Filter.hpp"
30 #include <cstring>
31 
32 
33 using namespace pwiz;
34 using namespace pwiz::msdata;
35 using namespace pwiz::analysis;
36 using namespace pwiz::util;
37 using boost::logic::tribool;
38 
39 
40 ostream* os_ = 0;
41 
42 
43 void 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<10; ++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  bool isMS1 = i%3==0;
81  spectrum->set(MS_ms_level, isMS1 ? 1 : 2);
82  spectrum->set(isMS1 ? MS_MS1_spectrum : MS_MSn_spectrum);
83 
84  // outfit the spectra with mass analyzer definitions to test the massAnalyzer filter
85  spectrum->scanList.scans.push_back(Scan());
86 
87  spectrum->scanList.scans[0].instrumentConfigurationPtr = InstrumentConfigurationPtr(new InstrumentConfiguration());
88  InstrumentConfigurationPtr p = spectrum->scanList.scans[0].instrumentConfigurationPtr;
89  if (i%3 == 0)
90  {
91  p->componentList.push_back(Component(MS_orbitrap, 0/*order*/));
92  }
93  else
94  {
95  if (i%2)
96  p->componentList.push_back(Component(MS_orbitrap, 0/*order*/));
97  else
98  p->componentList.push_back(Component(MS_radial_ejection_linear_ion_trap, 0/*order*/));
99  }
100 
101  // add thermo scan filter lines to the MS1 spectra
102  // MS1
103  if (i == 0 || i == 6) // narrow window MS1
104  {
105  spectrum->scanList.scans[0].set(MS_filter_string, "FTMS + p NSI SIM ms [595.0000-655.0000]");
106  }
107  else if (i == 3 || i == 9) // wide window MS1
108  {
109  spectrum->scanList.scans[0].set(MS_filter_string, "FTMS + p NSI SIM ms [395.0000-1005.0000]");
110  }
111 
112  if (i%3 != 0)
113  spectrum->precursors.push_back(Precursor((i+4)*100, 3));
114 
115  // add precursors, activation types, and thermo scan filter lines to the MS2 spectra
116  ostringstream filterLine;
117  if (i==1 || i ==5) // ETD
118  {
119  spectrum->precursors[0].activation.set(MS_electron_transfer_dissociation);
120  filterLine << "FTMS + c NSI Full ms2 " << (i + 4) * 100 << ".0000@etd30.00 [100.0000-2000.0000]";
121  }
122  else if (i==2) // CID
123  {
124  spectrum->precursors[0].activation.set(MS_collision_induced_dissociation);
125  filterLine << "ITMS + c NSI Full ms2 " << (i + 4) * 100 << ".0000@cid30.00 [100.0000-2000.0000]";
126  }
127  else if (i==4) // HCD
128  {
129  spectrum->precursors[0].activation.set(MS_HCD);
130  filterLine << "ITMS + c NSI Full ms2 " << (i + 4) * 100 << ".0000@hcd30.00 [100.0000-2000.0000]";
131  }
132  else if (i==8) // IRMPD
133  {
134  spectrum->precursors[0].activation.set(MS_IRMPD);
135  filterLine << "ITMS + c NSI Full ms2 " << (i + 4) * 100 << ".0000@irmpd30.00 [100.0000-2000.0000]";
136  }
137  else if (i==7) // ETD + SA
138  {
139  spectrum->precursors[0].activation.set(MS_electron_transfer_dissociation);
140  spectrum->precursors[0].activation.set(MS_collision_induced_dissociation);
141  filterLine << "FTMS + c NSI Full ms2 " << (i + 4) * 100 << ".0000@irmpd30.00 [100.0000-2000.0000]";
142  }
143 
144  spectrum->scanList.scans.push_back(Scan());
145  spectrum->scanList.scans[0].set(MS_preset_scan_configuration, i%4);
146  spectrum->scanList.scans[0].set(MS_scan_start_time, 420+i, UO_second);
147  if (i % 3 != 0)
148  spectrum->scanList.scans[0].set(MS_filter_string, filterLine.str());
149  sl->spectra.push_back(spectrum);
150  }
151 
152  if (os_)
153  {
154  *os_ << "original spectrum list:\n";
155  printSpectrumList(*sl, *os_);
156  *os_ << endl;
157  }
158 
159  return sl;
160 }
161 
162 
164 {
165  virtual tribool accept(const SpectrumIdentity& spectrumIdentity) const
166  {
167  return spectrumIdentity.index%2 == 0;
168  }
169 };
170 
171 
173 {
174  if (os_) *os_ << "testEven:\n";
175 
177 
178  if (os_)
179  {
180  printSpectrumList(filter, *os_);
181  *os_ << endl;
182  }
183 
184  unit_assert(filter.size() == 5);
185 
186  for (size_t i=0, end=filter.size(); i<end; i++)
187  {
188  const SpectrumIdentity& id = filter.spectrumIdentity(i);
189  unit_assert(id.index == i);
190  unit_assert(id.id == "scan=" + lexical_cast<string>(100+i*2));
191 
192  SpectrumPtr spectrum = filter.spectrum(i);
193  unit_assert(spectrum->index == i);
194  unit_assert(spectrum->id == "scan=" + lexical_cast<string>(100+i*2));
195  }
196 }
197 
198 
200 {
201  virtual tribool accept(const SpectrumIdentity& spectrumIdentity) const
202  {
203  if (spectrumIdentity.index%2 != 0) return false;
204  return boost::logic::indeterminate;
205  }
206 
207  virtual tribool accept(const Spectrum& spectrum) const
208  {
209  CVParam param = spectrum.cvParamChild(MS_spectrum_type);
210  if (param.cvid == CVID_Unknown) return boost::logic::indeterminate;
211  if (!cvIsA(param.cvid, MS_mass_spectrum))
212  return true; // MS level filter doesn't affect non-MS spectra
213 
214  param = spectrum.cvParam(MS_ms_level);
215  if (param.cvid == CVID_Unknown) return boost::logic::indeterminate;
216 
217  return (param.valueAs<int>() == 2);
218  }
219 };
220 
221 
223 {
224  if (os_) *os_ << "testEvenMS2:\n";
225 
227 
228  if (os_)
229  {
230  printSpectrumList(filter, *os_);
231  *os_ << endl;
232  }
233 
234  unit_assert(filter.size() == 3);
235  unit_assert(filter.spectrumIdentity(0).id == "scan=102");
236  unit_assert(filter.spectrumIdentity(1).id == "scan=104");
237  unit_assert(filter.spectrumIdentity(2).id == "scan=108");
238 }
239 
240 
242 {
243  mutable bool pastMaxIndex;
244 
245  SelectedIndexPredicate() : pastMaxIndex(false) {}
246 
247  virtual tribool accept(const SpectrumIdentity& spectrumIdentity) const
248  {
249  if (spectrumIdentity.index>5) pastMaxIndex = true;
250 
251  return (spectrumIdentity.index==1 ||
252  spectrumIdentity.index==3 ||
253  spectrumIdentity.index==5);
254  }
255 
256  virtual bool done() const
257  {
258  return pastMaxIndex;
259  }
260 };
261 
262 
264 {
265  if (os_) *os_ << "testSelectedIndices:\n";
266 
268 
269  if (os_)
270  {
271  printSpectrumList(filter, *os_);
272  *os_ << endl;
273  }
274 
275  unit_assert(filter.size() == 3);
276  unit_assert(filter.spectrumIdentity(0).id == "scan=101");
277  unit_assert(filter.spectrumIdentity(1).id == "scan=103");
278  unit_assert(filter.spectrumIdentity(2).id == "scan=105");
279 }
280 
281 
283 {
284  HasBinaryDataPredicate(DetailLevel suggestedDetailLevel) : detailLevel_(suggestedDetailLevel) {}
285 
287  virtual DetailLevel suggestedDetailLevel() const {return detailLevel_;}
288 
289  virtual tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const
290  {
291  return boost::logic::indeterminate;
292  }
293 
294  virtual tribool accept(const Spectrum& spectrum) const
295  {
296  if (spectrum.binaryDataArrayPtrs.empty())
297  return boost::logic::indeterminate;
298  return !spectrum.binaryDataArrayPtrs[0]->data.empty();
299  }
300 };
301 
302 
304 {
305  if (os_) *os_ << "testHasBinaryData:\n";
306 
307  MSData msd;
309 
310  shared_ptr<stringstream> ss(new stringstream);
311  Serializer_mzML serializer;
312  serializer.write(*ss, msd);
313 
314  MSData msd2;
315  serializer.read(ss, msd2);
316 
317  sl = msd2.run.spectrumListPtr;
318 
319  {
321  unit_assert(filter.empty());
322  }
323 
324  {
326 
327  if (os_)
328  {
329  printSpectrumList(filter, *os_);
330  *os_ << endl;
331  }
332 
333  unit_assert_operator_equal(4, filter.size());
334  }
335 }
336 
337 
339 {
340  if (os_) *os_ << "testIndexSet:\n";
341 
342  IntegerSet indexSet;
343  indexSet.insert(3,5);
344  indexSet.insert(7);
345  indexSet.insert(9);
346 
348 
349  if (os_)
350  {
351  printSpectrumList(filter, *os_);
352  *os_ << endl;
353  }
354 
355  unit_assert(filter.size() == 5);
356  unit_assert(filter.spectrumIdentity(0).id == "scan=103");
357  unit_assert(filter.spectrumIdentity(1).id == "scan=104");
358  unit_assert(filter.spectrumIdentity(2).id == "scan=105");
359  unit_assert(filter.spectrumIdentity(3).id == "scan=107");
360  unit_assert(filter.spectrumIdentity(4).id == "scan=109");
361 }
362 
363 
365 {
366  if (os_) *os_ << "testScanNumberSet:\n";
367 
368  IntegerSet scanNumberSet;
369  scanNumberSet.insert(102,104);
370  scanNumberSet.insert(107);
371 
373 
374  if (os_)
375  {
376  printSpectrumList(filter, *os_);
377  *os_ << endl;
378  }
379 
380  unit_assert(filter.size() == 4);
381  unit_assert(filter.spectrumIdentity(0).id == "scan=102");
382  unit_assert(filter.spectrumIdentity(1).id == "scan=103");
383  unit_assert(filter.spectrumIdentity(2).id == "scan=104");
384  unit_assert(filter.spectrumIdentity(3).id == "scan=107");
385 }
386 
387 
389 {
390  if (os_) *os_ << "testScanEventSet:\n";
391 
392  IntegerSet scanEventSet;
393  scanEventSet.insert(0,0);
394  scanEventSet.insert(2,3);
395 
397 
398  if (os_)
399  {
400  printSpectrumList(filter, *os_);
401  *os_ << endl;
402  }
403 
404  unit_assert(filter.size() == 7);
405  unit_assert(filter.spectrumIdentity(0).id == "scan=100");
406  unit_assert(filter.spectrumIdentity(1).id == "scan=102");
407  unit_assert(filter.spectrumIdentity(2).id == "scan=103");
408  unit_assert(filter.spectrumIdentity(3).id == "scan=104");
409  unit_assert(filter.spectrumIdentity(4).id == "scan=106");
410  unit_assert(filter.spectrumIdentity(5).id == "scan=107");
411  unit_assert(filter.spectrumIdentity(6).id == "scan=108");
412 }
413 
414 
416 {
417  if (os_) *os_ << "testScanTimeRange:\n";
418 
419  const double low = 422.5;
420  const double high = 427.5;
421 
423 
424  if (os_)
425  {
426  printSpectrumList(filter, *os_);
427  *os_ << endl;
428  }
429 
430  unit_assert(filter.size() == 5);
431  unit_assert(filter.spectrumIdentity(0).id == "scan=103");
432  unit_assert(filter.spectrumIdentity(1).id == "scan=104");
433  unit_assert(filter.spectrumIdentity(2).id == "scan=105");
434  unit_assert(filter.spectrumIdentity(3).id == "scan=106");
435  unit_assert(filter.spectrumIdentity(4).id == "scan=107");
436 }
437 
438 
440 {
441  if (os_) *os_ << "testMSLevelSet:\n";
442 
443  IntegerSet msLevelSet;
444  msLevelSet.insert(1);
445 
447 
448  if (os_)
449  {
450  printSpectrumList(filter, *os_);
451  *os_ << endl;
452  }
453 
454  unit_assert(filter.size() == 4);
455  unit_assert(filter.spectrumIdentity(0).id == "scan=100");
456  unit_assert(filter.spectrumIdentity(1).id == "scan=103");
457  unit_assert(filter.spectrumIdentity(2).id == "scan=106");
458  unit_assert(filter.spectrumIdentity(3).id == "scan=109");
459 
460  IntegerSet msLevelSet2;
461  msLevelSet2.insert(2);
462 
464 
465  if (os_)
466  {
467  printSpectrumList(filter2, *os_);
468  *os_ << endl;
469  }
470 
471  unit_assert(filter2.size() == 6);
472  unit_assert(filter2.spectrumIdentity(0).id == "scan=101");
473  unit_assert(filter2.spectrumIdentity(1).id == "scan=102");
474  unit_assert(filter2.spectrumIdentity(2).id == "scan=104");
475  unit_assert(filter2.spectrumIdentity(3).id == "scan=105");
476  unit_assert(filter2.spectrumIdentity(4).id == "scan=107");
477  unit_assert(filter2.spectrumIdentity(5).id == "scan=108");
478 }
479 
481 {
482  if (os_) *os_ << "testMS2Activation:\n";
483 
485 
486  set<CVID> cvIDs;
487  // CID
488  cvIDs.insert(MS_electron_transfer_dissociation);
489  cvIDs.insert(MS_HCD);
490  cvIDs.insert(MS_IRMPD);
491  SpectrumList_Filter filter(ms2filter,
493 
494  if (os_)
495  {
496  printSpectrumList(filter, *os_);
497  *os_ << endl;
498  }
499 
500  unit_assert(filter.size() == 1);
501  unit_assert(filter.spectrumIdentity(0).id == "scan=102");
502 
503  // ETD + SA
504  cvIDs.clear();
505  cvIDs.insert(MS_electron_transfer_dissociation);
506  cvIDs.insert(MS_collision_induced_dissociation);
507  SpectrumList_Filter filter1(ms2filter,
509  if (os_)
510  {
511  printSpectrumList(filter1, *os_);
512  *os_ << endl;
513  }
514 
515  unit_assert(filter1.size() == 1);
516  unit_assert(filter1.spectrumIdentity(0).id == "scan=107");
517 
518  // ETD
519  cvIDs.clear();
520  cvIDs.insert(MS_electron_transfer_dissociation);
521  SpectrumList_Filter filter2(ms2filter,
523  if (os_)
524  {
525  printSpectrumList(filter2, *os_);
526  *os_ << endl;
527  }
528 
529  unit_assert(filter2.size() == 3);
530  unit_assert(filter2.spectrumIdentity(0).id == "scan=101");
531  unit_assert(filter2.spectrumIdentity(1).id == "scan=105");
532  unit_assert(filter2.spectrumIdentity(2).id == "scan=107");
533 
534  // HCD
535  cvIDs.clear();
536  cvIDs.insert(MS_HCD);
537  SpectrumList_Filter filter3(ms2filter,
539  if (os_)
540  {
541  printSpectrumList(filter3, *os_);
542  *os_ << endl;
543  }
544 
545  unit_assert(filter3.size() == 1);
546  unit_assert(filter3.spectrumIdentity(0).id == "scan=104");
547 
548  // IRMPD
549  cvIDs.clear();
550  cvIDs.insert(MS_IRMPD);
551  SpectrumList_Filter filter4(ms2filter,
553  if (os_)
554  {
555  printSpectrumList(filter4, *os_);
556  *os_ << endl;
557  }
558 
559  unit_assert(filter4.size() == 1);
560  unit_assert(filter4.spectrumIdentity(0).id == "scan=108");
561 
562 }
563 
565 {
566  if (os_) *os_ << "testMassAnalyzerFilter:\n";
567 
568  set<CVID> cvIDs;
569  // msconvert mass analyzer filter FTMS option
570  cvIDs.insert(MS_orbitrap);
574 
575  if (os_)
576  {
577  printSpectrumList(filter, *os_);
578  *os_ << endl;
579  }
580 
581  unit_assert(filter.size() == 7);
582  unit_assert(filter.spectrumIdentity(0).id == "scan=100");
583 
584  cvIDs.clear();
585  // msconvert mass analyzer filter ITMS option
586  cvIDs.insert(MS_ion_trap);
587 
588  SpectrumList_Filter filter1(sl,
590 
591  if (os_)
592  {
593  printSpectrumList(filter1, *os_);
594  *os_ << endl;
595  }
596 
597  unit_assert(filter1.size() == 3);
598  unit_assert(filter1.spectrumIdentity(0).id == "scan=102");
599 }
600 
602 {
603  if (os_) *os_ << "testMZPresentFilter:\n";
604 
605  // test mzpresent on MS level 2 (include test)
607  chemistry::MZTolerance mzt(3.0);
608  std::set<double> mzSet;
609  mzSet.insert(200.0);
610  mzSet.insert(300.0);
611  mzSet.insert(400.0);
612  double threshold = 10;
613  IntegerSet msLevels(1, INT_MAX);
614  ThresholdFilter tf(ThresholdFilter::ThresholdingBy_Count, threshold, ThresholdFilter::Orientation_MostIntense, msLevels);
615  SpectrumList_Filter filter(ms2filter, SpectrumList_FilterPredicate_MzPresent(mzt, mzSet, tf, SpectrumList_Filter::Predicate::FilterMode_Include));
616 
617  if (os_)
618  {
619  printSpectrumList(filter, *os_);
620  *os_ << endl;
621  }
622  unit_assert_operator_equal(4, filter.size());
623  unit_assert_operator_equal("scan=102", filter.spectrumIdentity(0).id);
624  unit_assert_operator_equal("scan=104", filter.spectrumIdentity(1).id);
625  unit_assert_operator_equal("scan=105", filter.spectrumIdentity(2).id);
626  unit_assert_operator_equal("scan=107", filter.spectrumIdentity(3).id);
627 
628  // test mz present on MS level 1 (exclude test)
630  chemistry::MZTolerance mzt1(3.0);
631  std::set<double> mzSet1;
632  mzSet1.insert(200.0);
633  mzSet1.insert(300.0);
634  double threshold1 = 5;
635  ThresholdFilter tf1(ThresholdFilter::ThresholdingBy_Count, threshold1, ThresholdFilter::Orientation_MostIntense, msLevels);
636  SpectrumList_Filter filter1(ms1filter, SpectrumList_FilterPredicate_MzPresent(mzt1, mzSet1, tf1, SpectrumList_Filter::Predicate::FilterMode_Exclude));
637 
638  if (os_)
639  {
640  printSpectrumList(filter1, *os_);
641  *os_ << endl;
642  }
643  unit_assert_operator_equal(3, filter1.size());
644  unit_assert_operator_equal("scan=100", filter1.spectrumIdentity(0).id);
645  unit_assert_operator_equal("scan=106", filter1.spectrumIdentity(1).id);
646  unit_assert_operator_equal("scan=109", filter1.spectrumIdentity(2).id);
647 }
648 
650 {
651  if (os_) *os_ << "testThermoFilterFilter:\n";
652 
653  // test for query of "395.0000-1005.0000" using contains (include)
654  string queryString = "395.0000-1005.0000";
655  SpectrumList_Filter filter1(sl, SpectrumList_FilterPredicate_ThermoScanFilter(queryString, false, false));
656  if (os_)
657  {
658  *os_ << "Including all spectra that contain " << queryString << endl;
659  printSpectrumList(filter1, *os_);
660  *os_ << endl;
661  }
662  unit_assert(filter1.size() == 2);
663  unit_assert(filter1.spectrumIdentity(0).id == "scan=103");
664  unit_assert(filter1.spectrumIdentity(1).id == "scan=109");
665 
666  // test for query of "395.0000-1005.0000" using contains (exclude)
667  SpectrumList_Filter filter2(sl, SpectrumList_FilterPredicate_ThermoScanFilter(queryString, false, true));
668  if (os_)
669  {
670  *os_ << "Excluding all spectra that contain " << queryString << endl;
671  printSpectrumList(filter2, *os_);
672  *os_ << endl;
673  }
674  unit_assert(filter2.size() == 8);
675  unit_assert(filter2.spectrumIdentity(0).id == "scan=100");
676  unit_assert(filter2.spectrumIdentity(1).id == "scan=101");
677  unit_assert(filter2.spectrumIdentity(2).id == "scan=102");
678  unit_assert(filter2.spectrumIdentity(3).id == "scan=104");
679  unit_assert(filter2.spectrumIdentity(4).id == "scan=105");
680  unit_assert(filter2.spectrumIdentity(5).id == "scan=106");
681  unit_assert(filter2.spectrumIdentity(6).id == "scan=107");
682  unit_assert(filter2.spectrumIdentity(7).id == "scan=108");
683 
684  // test for query of "ms2" using contains (exclude)
685  queryString = "ms2";
686  SpectrumList_Filter filter3(sl, SpectrumList_FilterPredicate_ThermoScanFilter(queryString, false, true));
687  if (os_)
688  {
689  *os_ << "Excluding all spectra that contain " << queryString << endl;
690  printSpectrumList(filter3, *os_);
691  *os_ << endl;
692  }
693  unit_assert(filter3.size() == 4);
694  unit_assert(filter3.spectrumIdentity(0).id == "scan=100");
695  unit_assert(filter3.spectrumIdentity(1).id == "scan=103");
696  unit_assert(filter3.spectrumIdentity(2).id == "scan=106");
697  unit_assert(filter3.spectrumIdentity(3).id == "scan=109");
698 
699  // test for exact query of "FTMS + p NSI SIM ms [395.0000-1005.0000]" (include)
700  queryString = "FTMS + p NSI SIM ms [395.0000-1005.0000]";
701  SpectrumList_Filter filter4(sl, SpectrumList_FilterPredicate_ThermoScanFilter(queryString, true, false));
702  if (os_)
703  {
704  *os_ << "Including all spectra that exactly match " << queryString << endl;
705  printSpectrumList(filter4, *os_);
706  *os_ << endl;
707  }
708  unit_assert(filter4.size() == 2);
709  unit_assert(filter4.spectrumIdentity(0).id == "scan=103");
710  unit_assert(filter4.spectrumIdentity(1).id == "scan=109");
711 
712  // test for exact query of "FTMS + p NSI SIM ms [395.0000-1005.0000]" (exclude)
713  queryString = "FTMS + p NSI SIM ms [395.0000-1005.0000]";
714  SpectrumList_Filter filter5(sl, SpectrumList_FilterPredicate_ThermoScanFilter(queryString, true, true));
715  if (os_)
716  {
717  *os_ << "Excluding all spectra that exactly match " << queryString << endl;
718  printSpectrumList(filter5, *os_);
719  *os_ << endl;
720  }
721  unit_assert(filter5.size() == 8);
722  unit_assert(filter5.spectrumIdentity(0).id == "scan=100");
723  unit_assert(filter5.spectrumIdentity(1).id == "scan=101");
724  unit_assert(filter5.spectrumIdentity(2).id == "scan=102");
725  unit_assert(filter5.spectrumIdentity(3).id == "scan=104");
726  unit_assert(filter5.spectrumIdentity(4).id == "scan=105");
727  unit_assert(filter5.spectrumIdentity(5).id == "scan=106");
728  unit_assert(filter5.spectrumIdentity(6).id == "scan=107");
729  unit_assert(filter5.spectrumIdentity(7).id == "scan=108");
730 }
731 
732 void test()
733 {
735  testEven(sl);
736  testEvenMS2(sl);
738  testHasBinaryData(sl);
739  testIndexSet(sl);
740  testScanNumberSet(sl);
741  testScanEventSet(sl);
742  testScanTimeRange(sl);
743  testMSLevelSet(sl);
744  testMS2Activation(sl);
748 }
749 
750 
751 int main(int argc, char* argv[])
752 {
753  TEST_PROLOG(argc, argv)
754 
755  try
756  {
757  if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
758  test();
759  }
760  catch (exception& e)
761  {
762  TEST_FAILED(e.what())
763  }
764  catch (...)
765  {
766  TEST_FAILED("Caught unknown exception.")
767  }
768 
770 }
771 
772 
void testThermoFilterFilter(SpectrumListPtr sl)
virtual tribool accept(const SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...
void testEvenMS2(SpectrumListPtr sl)
MS_MSn_spectrum
MSn spectrum: MSn refers to multi-stage MS2 experiments designed to record product ion spectra where ...
Definition: cv.hpp:2212
CVParam cvParam(CVID cvid) const
finds cvid in the container:
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:1291
MSData <-> mzML stream serialization.
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&#39;s SpectrumList...
a virtual container of integers, accessible via an iterator interface, stored as union of intervals ...
Definition: IntegerSet.hpp:37
The method of precursor ion selection and activation.
Definition: MSData.hpp:310
std::vector< BinaryDataArrayPtr > binaryDataArrayPtrs
list of binary data arrays.
Definition: MSData.hpp:525
A component of an instrument corresponding to a source (i.e. ion source), an analyzer (i...
Definition: MSData.hpp:130
void testScanNumberSet(SpectrumListPtr sl)
virtual msdata::SpectrumPtr spectrum(size_t index, bool getBinaryData=false) const
retrieve a spectrum by index
boost::shared_ptr< Spectrum > SpectrumPtr
Definition: MSData.hpp:569
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...
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
ostream * os_
void testMSLevelSet(SpectrumListPtr sl)
virtual tribool accept(const msdata::SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...
#define TEST_EPILOG
Definition: unit.hpp:182
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:373
virtual size_t size() const
returns the number of spectra
SpectrumListPtr createSpectrumList()
MS_collision_induced_dissociation
collision-induced dissociation: The dissociation of an ion after collisional excitation. The term collisional-activated dissociation is not recommended.
Definition: cv.hpp:586
virtual SpectrumPtr spectrum(size_t index, bool getBinaryData=false) const =0
retrieve a spectrum by index
PWIZ_API_DECL void initializeTiny(MSData &msd)
virtual size_t size() const =0
returns the number of spectra
void testScanTimeRange(SpectrumListPtr sl)
MS_ms_level
ms level: Stages of ms achieved in a multi stage mass spectrometry experiment.
Definition: cv.hpp:1987
float lexical_cast(const std::string &str)
Interface for accessing spectra, which may be stored in memory or backed by a data file (RAW...
Definition: MSData.hpp:656
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
client-implemented filter predicate – called during construction of SpectrumList_Filter to create th...
void testMS2Activation(SpectrumListPtr sl)
MS_filter_string
filter string: A string unique to Thermo instrument describing instrument settings for the scan...
Definition: cv.hpp:1990
virtual tribool accept(const SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...
MS_electron_transfer_dissociation
electron transfer dissociation: A process to fragment ions in a mass spectrometer by inducing fragmen...
Definition: cv.hpp:2296
void testScanEventSet(SpectrumListPtr sl)
std::string id
a unique identifier for this spectrum. It should be expected that external files may use this identif...
Definition: MSData.hpp:475
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:397
MS_IRMPD
IRMPD (infrared multiphoton dissociation): Multiphoton ionization where the reactant ion dissociates ...
Definition: cv.hpp:1117
The data point type of a mass spectrum.
Definition: MSData.hpp:421
#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
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:2197
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:707
void testSelectedIndices(SpectrumListPtr sl)
virtual DetailLevel suggestedDetailLevel() const
can be overridden in subclasses that know they will need a certain detail level; it must be overridde...
size_t index
the zero-based, consecutive index of the spectrum in the SpectrumList.
Definition: MSData.hpp:472
virtual tribool accept(const Spectrum &spectrum) const
return true iff Spectrum is accepted
virtual bool done() const
return true iff done accepting proteins; this allows early termination of the iteration through the o...
MS_spectrum_type
spectrum type: Spectrum type.
Definition: cv.hpp:2134
MS_preset_scan_configuration
preset scan configuration: A user-defined scan configuration that specifies the instrumental settings...
Definition: cv.hpp:2359
void testMZPresentFilter(SpectrumListPtr sl)
Description of a particular hardware configuration of a mass spectrometer. Each configuration MUST ha...
Definition: MSData.hpp:228
boost::shared_ptr< InstrumentConfiguration > InstrumentConfigurationPtr
Definition: MSData.hpp:249
void testHasBinaryData(SpectrumListPtr sl)
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
virtual bool empty() const
returns true iff (size() == 0) and (dataProcessingPtr.get() == NULL)
Identifying information for a spectrum.
Definition: MSData.hpp:469
void printSpectrumList(const SpectrumList &sl, ostream &os)
#define TEST_FAILED(x)
Definition: unit.hpp:176
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:580
CVID_Unknown
Definition: cv.hpp:97
virtual tribool accept(const SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...
void testMassAnalyzerFilter(SpectrumListPtr sl)
struct for expressing m/z tolerance in either amu or ppm
Definition: MZTolerance.hpp:38
MS_ion_trap
ion trap: A device for spatially confining ions using electric and magnetic fields alone or in combin...
Definition: cv.hpp:1126
HasBinaryDataPredicate(DetailLevel suggestedDetailLevel)
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:174
boost::shared_ptr< SpectrumListSimple > SpectrumListSimplePtr
Definition: MSData.hpp:727
SpectrumList filter, for creating Spectrum sub-lists.
The structure that captures the generation of a peak list (including the underlying acquisitions) ...
Definition: MSData.hpp:504
virtual tribool accept(const Spectrum &spectrum) const
return true iff Spectrum is accepted
CVParam cvParamChild(CVID cvid) const
finds child of cvid in the container:
value_type valueAs() const
templated value access with type conversion
Definition: ParamTypes.hpp:112
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:845
virtual const msdata::SpectrumIdentity & spectrumIdentity(size_t index) const
access to a spectrum index
void insert(Interval interval)
insert an interval of integers into the virtual container
Simple writeable in-memory implementation of SpectrumList.
Definition: MSData.hpp:712
#define unit_assert(x)
Definition: unit.hpp:85
MS_orbitrap
orbitrap: An ion trapping device that consists of an outer barrel-like electrode and a coaxial inner ...
Definition: cv.hpp:1900
int main(int argc, char *argv[])
void testEven(SpectrumListPtr sl)
PWIZ_API_DECL bool cvIsA(CVID child, CVID parent)
returns true iff child IsA parent in the CV
MS_HCD
HCD (beam-type collision-induced dissociation): A collision-induced dissociation process that occurs ...
Definition: cv.hpp:1690
represents a tag-value pair, where the tag comes from the controlled vocabulary
Definition: ParamTypes.hpp:44
void filter(const TContainer &data, const TContainer &filter, TContainer &result, bool circular=false, uint32_t sides=2)
Applies linear convolution (filtering) to a univariate time series.
Definition: filter.hpp:112
void testIndexSet(SpectrumListPtr sl)