ProteoWizard
SpectrumList_Filter.hpp
Go to the documentation of this file.
1 //
2 // $Id: SpectrumList_Filter.hpp 4090 2012-11-07 23:42:04Z 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 #ifndef _SPECTRUMLIST_FILTER_HPP_
25 #define _SPECTRUMLIST_FILTER_HPP_
26 
27 
31 #include "boost/logic/tribool.hpp"
32 
33 #include <set>
34 
35 namespace pwiz {
36 namespace analysis {
37 
38 
39 /// SpectrumList filter, for creating Spectrum sub-lists
41 {
42  public:
43 
44  /// client-implemented filter predicate -- called during construction of
45  /// SpectrumList_Filter to create the filtered list of spectra
47  {
48  /// can be overridden in subclasses that know they will need a certain detail level;
49  /// it must be overridden to return DetailLevel_FullData if binary data is needed
51 
52  /// return values:
53  /// true: accept the Spectrum
54  /// false: reject the Spectrum
55  /// indeterminate: need to see the full Spectrum object to decide
56  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const = 0;
57 
58  /// return true iff Spectrum is accepted
59  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const {return false;}
60 
61  /// return true iff done accepting spectra;
62  /// this allows early termination of the iteration through the original
63  /// SpectrumList, possibly using assumptions about the order of the
64  /// iteration (e.g. index is increasing, nativeID interpreted as scan number is
65  /// increasing, ...)
66  virtual bool done() const {return false;}
67 
68  virtual ~Predicate() {}
69  };
70 
71  SpectrumList_Filter(const msdata::SpectrumListPtr original, const Predicate& predicate);
72 
73  /// \name SpectrumList interface
74  //@{
75  virtual size_t size() const;
76  virtual const msdata::SpectrumIdentity& spectrumIdentity(size_t index) const;
77  virtual msdata::SpectrumPtr spectrum(size_t index, bool getBinaryData = false) const;
78  virtual msdata::SpectrumPtr spectrum(size_t index, msdata::DetailLevel detailLevel) const;
79  //@}
80 
81  private:
82  struct Impl;
83  boost::shared_ptr<Impl> impl_;
86 };
87 
88 
90 {
91  public:
93  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const;
94  virtual bool done() const;
95 
96  private:
98  mutable bool eos_;
99 };
100 
101 
103 {
104  public:
106  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const;
107  virtual bool done() const;
108 
109  private:
111  mutable bool eos_;
112 };
113 
114 
116 {
117  public:
119  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const {return boost::logic::indeterminate;}
120  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
121 
122  private:
124 };
125 
126 
128 {
129  public:
130  SpectrumList_FilterPredicate_ScanTimeRange(double scanTimeLow, double scanTimeHigh);
131  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const;
132  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
133 
134  private:
135  double scanTimeLow_;
137 };
138 
139 
141 {
142  public:
144  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const {return boost::logic::indeterminate;}
145  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
146 
147  private:
149 };
150 
151 
153 {
154  public:
155  SpectrumList_FilterPredicate_PrecursorMzSet(const std::set<double>& precursorMzSet);
156  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const {return boost::logic::indeterminate;}
157  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
158 
159  private:
160  std::set<double> precursorMzSet_;
161 
162  double getPrecursorMz(const msdata::Spectrum& spectrum) const;
163 };
164 
165 
167 {
168  public:
170  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const {return boost::logic::indeterminate;}
171  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
172 
173  private:
175 };
176 
177 
179 {
180  public:
181  SpectrumList_FilterPredicate_ActivationType(const std::set<pwiz::cv::CVID> filterItem, bool hasNoneOf_ = false);
182  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const {return boost::logic::indeterminate;}
183  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
184 
185  private:
186  std::set<pwiz::cv::CVID> cvFilterItems;
187  bool hasNoneOf;
188 };
189 
190 
192 {
193  public:
194  SpectrumList_FilterPredicate_AnalyzerType(const std::set<pwiz::cv::CVID> filterItem);
195  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const {return boost::logic::indeterminate;}
196  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
197 
198  private:
199  std::set<pwiz::cv::CVID> cvFilterItems;
200 };
201 
202 
204 {
205  public:
206  SpectrumList_FilterPredicate_Polarity(pwiz::cv::CVID polarity);
207  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const {return boost::logic::indeterminate;}
208  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
209 
210  private:
211  pwiz::cv::CVID polarity;
212 
213 };
214 
215 } // namespace analysis
216 } // namespace pwiz
217 
218 
219 #endif // _SPECTRUMLIST_FILTER_HPP_
220