ProteoWizard
SpectrumList_Filter.hpp
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 
24 #ifndef _SPECTRUMLIST_FILTER_HPP_
25 #define _SPECTRUMLIST_FILTER_HPP_
26 
27 
34 #include "boost/logic/tribool.hpp"
35 
36 #include <set>
37 #include <string>
38 
39 namespace pwiz {
40 namespace analysis {
41 
42 
43 /// SpectrumList filter, for creating Spectrum sub-lists
45 {
46  public:
47 
48  /// client-implemented filter predicate -- called during construction of
49  /// SpectrumList_Filter to create the filtered list of spectra
51  {
52  /// controls whether spectra that pass the predicate are included or excluded from the result
54  {
56  FilterMode_Exclude
57  };
58 
59  /// can be overridden in subclasses that know they will need a certain detail level;
60  /// it must be overridden to return DetailLevel_FullData if binary data is needed
62 
63  /// return values:
64  /// true: accept the Spectrum
65  /// false: reject the Spectrum
66  /// indeterminate: need to see the full Spectrum object to decide
67  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const = 0;
68 
69  /// return true iff Spectrum is accepted
70  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const {return false;}
71 
72  /// return true iff done accepting spectra;
73  /// this allows early termination of the iteration through the original
74  /// SpectrumList, possibly using assumptions about the order of the
75  /// iteration (e.g. index is increasing, nativeID interpreted as scan number is
76  /// increasing, ...)
77  virtual bool done() const {return false;}
78 
79  /// return a string describing how the predicate filters
80  virtual std::string describe() const = 0;
81 
82  virtual ~Predicate() {}
83  };
84 
86 
87  /// \name SpectrumList interface
88  //@{
89  virtual size_t size() const;
90  virtual const msdata::SpectrumIdentity& spectrumIdentity(size_t index) const;
91  virtual msdata::SpectrumPtr spectrum(size_t index, bool getBinaryData = false) const;
92  virtual msdata::SpectrumPtr spectrum(size_t index, msdata::DetailLevel detailLevel) const;
93  //@}
94 
95  private:
96  struct Impl;
97  boost::shared_ptr<Impl> impl_;
100 };
101 
102 
103 PWIZ_API_DECL std::ostream& operator<<(std::ostream& os, const SpectrumList_Filter::Predicate::FilterMode& mode);
104 PWIZ_API_DECL std::istream& operator>>(std::istream& is, SpectrumList_Filter::Predicate::FilterMode& mode);
105 
106 
108 {
109  public:
111  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const;
112  virtual bool done() const;
113  virtual std::string describe() const { return "set of spectrum indices"; }
114 
115  private:
117  mutable bool eos_;
118 };
119 
120 
122 {
123  public:
125  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const;
126  virtual bool done() const;
127  virtual std::string describe() const { return "set of scan numbers"; }
128 
129  private:
131  mutable bool eos_;
132 };
133 
134 
136 {
137 public:
138  SpectrumList_FilterPredicate_IdSet(const std::set<std::string>& idSet);
139  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const;
140  virtual bool done() const;
141  virtual std::string describe() const { return "set of spectrum ids"; }
142 
143 private:
144  std::set<std::string> idSet_;
145 };
146 
147 
149 {
150  public:
152  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const {return boost::logic::indeterminate;}
153  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
154  virtual std::string describe() const { return "set of scan events"; }
155 
156  private:
158 };
159 
160 
162 {
163  public:
164  SpectrumList_FilterPredicate_ScanTimeRange(double scanTimeLow, double scanTimeHigh);
165  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const;
166  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
167  virtual std::string describe() const { return "scan time range"; }
168 
169  private:
170  double scanTimeLow_;
172 };
173 
174 
176 {
177  public:
179  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const {return boost::logic::indeterminate;}
180  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
181  virtual std::string describe() const { return "set of MS levels"; }
182 
183  private:
185 };
186 
187 
189 {
190  public:
192  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const {return boost::logic::indeterminate;}
193  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
194  virtual std::string describe() const { return "set of charge states"; }
195 
196  private:
198 };
199 
200 
202 {
203  public:
204 
206  {
208  TargetMode_Isolated
209  };
210 
211  SpectrumList_FilterPredicate_PrecursorMzSet(const std::set<double>& precursorMzSet, chemistry::MZTolerance tolerance, FilterMode mode, TargetMode target = TargetMode_Selected);
212  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const {return boost::logic::indeterminate;}
213  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
214  virtual std::string describe() const { return "set of precursor M/Zs"; }
215 
216  private:
217  std::set<double> precursorMzSet_;
221 
222  double getPrecursorMz(const msdata::Spectrum& spectrum) const;
223 };
224 
225 
227 {
228  public:
230  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const {return boost::logic::indeterminate;}
231  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
232  virtual std::string describe() const { return "number of spectrum data points"; }
233 
234  private:
236 };
237 
238 
240 {
241  public:
242  SpectrumList_FilterPredicate_ActivationType(const std::set<pwiz::cv::CVID> filterItem, bool hasNoneOf_ = false);
243  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const {return boost::logic::indeterminate;}
244  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
245  virtual std::string describe() const { return "set of activation types"; }
246 
247  private:
248  std::set<pwiz::cv::CVID> cvFilterItems;
249  bool hasNoneOf;
250 };
251 
252 
254 {
255  public:
256  SpectrumList_FilterPredicate_AnalyzerType(const std::set<pwiz::cv::CVID> filterItem);
257  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const {return boost::logic::indeterminate;}
258  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
259  virtual std::string describe() const { return "set of analyzer types"; }
260 
261  private:
262  std::set<pwiz::cv::CVID> cvFilterItems;
263 };
264 
265 
267 {
268  public:
269  SpectrumList_FilterPredicate_Polarity(pwiz::cv::CVID polarity);
270  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const {return boost::logic::indeterminate;}
271  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
272  virtual std::string describe() const { return "polarity"; }
273 
274  private:
275  pwiz::cv::CVID polarity;
276 
277 };
278 
279 
281 {
282  public:
283  SpectrumList_FilterPredicate_MzPresent(chemistry::MZTolerance mzt, std::set<double> mzSet, ThresholdFilter tf, FilterMode mode);
285  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const {return boost::logic::indeterminate;}
286  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
287  virtual std::string describe() const { return "set of M/Zs in spectrum"; }
288 
289  private:
291  std::set<double> mzSet_;
293  FilterMode mode_;
294 };
295 
297 {
298  public:
299  SpectrumList_FilterPredicate_ThermoScanFilter(const std::string& matchString, bool matchExact, bool inverse);
300  virtual boost::logic::tribool accept(const msdata::SpectrumIdentity& spectrumIdentity) const {return boost::logic::indeterminate;}
301  virtual boost::logic::tribool accept(const msdata::Spectrum& spectrum) const;
302  virtual std::string describe() const { return "Thermo scan filter pattern"; }
303 
304  private:
305  std::string matchString_;
307  bool inverse_;
308 };
309 
310 } // namespace analysis
311 } // namespace pwiz
312 
313 
314 #endif // _SPECTRUMLIST_FILTER_HPP_
315 
virtual std::string describe() const
return a string describing how the predicate filters
a virtual container of integers, accessible via an iterator interface, stored as union of intervals ...
Definition: IntegerSet.hpp:37
virtual std::string describe() const
return a string describing how the predicate filters
virtual msdata::DetailLevel suggestedDetailLevel() const
can be overridden in subclasses that know they will need a certain detail level; it must be overridde...
virtual boost::logic::tribool accept(const msdata::SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...
virtual boost::logic::tribool accept(const msdata::SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...
virtual boost::logic::tribool accept(const msdata::SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...
virtual std::string describe() const
return a string describing how the predicate filters
boost::shared_ptr< Spectrum > SpectrumPtr
Definition: MSData.hpp:573
virtual boost::logic::tribool accept(const msdata::SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...
virtual boost::logic::tribool accept(const msdata::SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...
virtual std::string describe() const
return a string describing how the predicate filters
virtual boost::logic::tribool accept(const msdata::Spectrum &spectrum) const
return true iff Spectrum is accepted
virtual msdata::DetailLevel suggestedDetailLevel() const
can be overridden in subclasses that know they will need a certain detail level; it must be overridde...
client-implemented filter predicate – called during construction of SpectrumList_Filter to create th...
Inheritable pass-through implementation for wrapping a SpectrumList.
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition: MSData.hpp:711
#define PWIZ_API_DECL
Definition: Export.hpp:32
PWIZ_API_DECL std::ostream & operator<<(std::ostream &os, PepxmlRecordReader &prr)
virtual boost::logic::tribool accept(const msdata::SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...
virtual std::string describe() const
return a string describing how the predicate filters
virtual std::string describe() const
return a string describing how the predicate filters
virtual std::string describe() const
return a string describing how the predicate filters
Identifying information for a spectrum.
Definition: MSData.hpp:470
virtual std::string describe() const
return a string describing how the predicate filters
virtual bool done() const
return true iff done accepting spectra; this allows early termination of the iteration through the or...
virtual std::string describe() const
return a string describing how the predicate filters
virtual std::string describe() const
return a string describing how the predicate filters
handles registration of IterationListeners and broadcast of update messages
virtual boost::logic::tribool accept(const msdata::SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...
virtual std::string describe() const
return a string describing how the predicate filters
struct for expressing m/z tolerance in either amu or ppm
Definition: MZTolerance.hpp:38
PWIZ_API_DECL std::istream & operator>>(std::istream &is, SpectrumList_Filter::Predicate::FilterMode &mode)
virtual boost::logic::tribool accept(const msdata::SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...
FilterMode
controls whether spectra that pass the predicate are included or excluded from the result ...
SpectrumList filter, for creating Spectrum sub-lists.
virtual boost::logic::tribool accept(const msdata::SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...
The structure that captures the generation of a peak list (including the underlying acquisitions) ...
Definition: MSData.hpp:505
virtual std::string describe() const
return a string describing how the predicate filters
virtual std::string describe() const
return a string describing how the predicate filters
virtual std::string describe() const
return a string describing how the predicate filters
virtual boost::logic::tribool accept(const msdata::SpectrumIdentity &spectrumIdentity) const
return values: true: accept the Spectrum false: reject the Spectrum indeterminate: need to see the fu...