ProteoWizard
ProteinList_Filter.hpp
Go to the documentation of this file.
1 //
2 // $Id$
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_
pwiz::analysis::ProteinList_Filter::protein
virtual proteome::ProteinPtr protein(size_t index, bool getSequence=true) const
pwiz::proteome::ProteinListWrapper
Inheritable pass-through implementation for wrapping a ProteinList.
Definition: ProteinListWrapper.hpp:38
pwiz
Definition: ChromatogramList_Filter.hpp:36
pwiz::analysis::ProteinList_FilterPredicate_IdSet
Definition: ProteinList_Filter.hpp:89
pwiz::analysis::ProteinList_FilterPredicate_IndexSet::eos_
bool eos_
Definition: ProteinList_Filter.hpp:84
pwiz::analysis::ProteinList_Filter::operator=
ProteinList_Filter & operator=(ProteinList_Filter &)
pwiz::analysis::ProteinList_Filter
ProteinList filter, for creating Protein sub-lists.
Definition: ProteinList_Filter.hpp:40
PWIZ_API_DECL
#define PWIZ_API_DECL
Definition: Export.hpp:32
pwiz::analysis::ProteinList_FilterPredicate_IndexSet::done
virtual bool done() const
return true iff done accepting proteins; this allows early termination of the iteration through the o...
pwiz::analysis::ProteinList_FilterPredicate_IdSet::idSet_
std::set< std::string > idSet_
Definition: ProteinList_Filter.hpp:97
Export.hpp
ProteinListWrapper.hpp
pwiz::analysis::ProteinList_Filter::ProteinList_Filter
ProteinList_Filter(ProteinList_Filter &)
pwiz::analysis::ProteinList_FilterPredicate_IndexSet::ProteinList_FilterPredicate_IndexSet
ProteinList_FilterPredicate_IndexSet(const util::IntegerSet &indexSet)
pwiz::analysis::ProteinList_Filter::Predicate::~Predicate
virtual ~Predicate()
Definition: ProteinList_Filter.hpp:56
pwiz::analysis::ProteinList_Filter::size
virtual size_t size() const
pwiz::proteome::ProteinListPtr
boost::shared_ptr< ProteinList > ProteinListPtr
Definition: ProteomeData.hpp:73
pwiz::analysis::ProteinList_FilterPredicate_IdSet::ProteinList_FilterPredicate_IdSet
ProteinList_FilterPredicate_IdSet(const InputIterator &begin, const InputIterator &end)
Definition: ProteinList_Filter.hpp:92
pwiz::proteome::Protein
Definition: ProteomeData.hpp:37
pwiz::analysis::ProteinList_Filter::Predicate
client-implemented filter predicate – called during construction of ProteinList_Filter to create the ...
Definition: ProteinList_Filter.hpp:46
pwiz::analysis::ProteinList_Filter::ProteinList_Filter
ProteinList_Filter(const proteome::ProteinListPtr original, const Predicate &predicate)
pwiz::analysis::ProteinList_FilterPredicate_IndexSet::accept
virtual boost::logic::tribool accept(const proteome::Protein &protein) const
return true iff Protein is accepted
pwiz::analysis::ProteinList_FilterPredicate_IdSet::done
virtual bool done() const
return true iff done accepting proteins; this allows early termination of the iteration through the o...
pwiz::analysis::ProteinList_Filter::impl_
boost::shared_ptr< Impl > impl_
Definition: ProteinList_Filter.hpp:68
pwiz::analysis::ProteinList_FilterPredicate_IdSet::ProteinList_FilterPredicate_IdSet
ProteinList_FilterPredicate_IdSet(const std::set< std::string > &idSet)
pwiz::analysis::ProteinList_Filter::Predicate::accept
virtual boost::logic::tribool accept(const proteome::Protein &protein) const
return true iff Protein is accepted
Definition: ProteinList_Filter.hpp:48
pwiz::analysis::ProteinList_FilterPredicate_IdSet::accept
virtual boost::logic::tribool accept(const proteome::Protein &protein) const
return true iff Protein is accepted
pwiz::analysis::ProteinList_FilterPredicate_IndexSet
Definition: ProteinList_Filter.hpp:76
IntegerSet.hpp
pwiz::analysis::ProteinList_FilterPredicate_IndexSet::indexSet_
util::IntegerSet indexSet_
Definition: ProteinList_Filter.hpp:83
pwiz::util::IntegerSet
a virtual container of integers, accessible via an iterator interface, stored as union of intervals
Definition: IntegerSet.hpp:38
pwiz::analysis::ProteinList_Filter::Predicate::done
virtual bool done() const
return true iff done accepting proteins; this allows early termination of the iteration through the o...
Definition: ProteinList_Filter.hpp:54
pwiz::proteome::ProteinPtr
boost::shared_ptr< Protein > ProteinPtr
Definition: ProteomeData.hpp:48