ProteoWizard
ProteinList_Filter.hpp
Go to the documentation of this file.
1 //
2 // $Id: ProteinList_Filter.hpp 4010 2012-10-17 20:22:16Z chambm $
3 //
4 //
5 // Original author: Matt Chambers <matt.chambers <a.t> vanderbilt.edu>
6 //
7 // Copyright 2012 Vanderbilt University - Nashville, TN 37232
8 //
9 // Licensed under the Apache License, Version 2.0 (the "License");
10 // you may not use this file except in compliance with the License.
11 // You may obtain a copy of the License at
12 //
13 // http://www.apache.org/licenses/LICENSE-2.0
14 //
15 // Unless required by applicable law or agreed to in writing, software
16 // distributed under the License is distributed on an "AS IS" BASIS,
17 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 // See the License for the specific language governing permissions and
19 // limitations under the License.
20 //
21 
22 
23 #ifndef _PROTEINLIST_FILTER_HPP_
24 #define _PROTEINLIST_FILTER_HPP_
25 
26 
30 #include "boost/logic/tribool.hpp"
31 
32 #include <set>
33 
34 namespace pwiz {
35 namespace analysis {
36 
37 
38 /// ProteinList filter, for creating Protein sub-lists
40 {
41  public:
42 
43  /// client-implemented filter predicate -- called during construction of
44  /// ProteinList_Filter to create the filtered list of proteins
46  {
47  /// return true iff Protein is accepted
48  virtual boost::logic::tribool accept(const proteome::Protein& protein) const {return false;}
49 
50  /// return true iff done accepting proteins;
51  /// this allows early termination of the iteration through the original
52  /// ProteinList, possibly using assumptions about the order of the
53  /// iteration (e.g. index is increasing)
54  virtual bool done() const {return false;}
55 
56  virtual ~Predicate() {}
57  };
58 
59  ProteinList_Filter(const proteome::ProteinListPtr original, const Predicate& predicate);
60 
61  /// \name ProteinList interface
62  //@{
63  virtual size_t size() const;
64  virtual proteome::ProteinPtr protein(size_t index, bool getSequence = true) const;
65  //@}
66 
67  private:
68  struct Impl;
69  boost::shared_ptr<Impl> impl_;
72 };
73 
74 
76 {
77  public:
79  virtual boost::logic::tribool accept(const proteome::Protein& protein) const;
80  virtual bool done() const;
81 
82  private:
84  mutable bool eos_;
85 };
86 
87 
89 {
90  public:
91  ProteinList_FilterPredicate_IdSet(const std::set<std::string>& idSet);
92  template <typename InputIterator> ProteinList_FilterPredicate_IdSet(const InputIterator& begin, const InputIterator& end) : idSet_(begin, end) {}
93  virtual boost::logic::tribool accept(const proteome::Protein& protein) const;
94  virtual bool done() const;
95 
96  private:
97  mutable std::set<std::string> idSet_;
98 };
99 
100 
101 } // namespace analysis
102 } // namespace pwiz
103 
104 
105 #endif // _PROTEINLIST_FILTER_HPP_