Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BasicFilters.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file src/protocols/filters/BasicFilters.hh
11 /// @brief header file for very simple Filter classes
12 /// @detailed
13 /// @author Florian Richter, floric@u.washington.edu (feb 09 ), Sarel Fleishman sarelf@u.washington.edu, Rocco Moretti (rmoretti@u.washington.edu)
14 
15 #ifndef INCLUDED_protocols_filters_BasicFilters_hh
16 #define INCLUDED_protocols_filters_BasicFilters_hh
17 
18 // Unit Headers
20 
21 // Package headers
25 #include <protocols/moves/ResId.hh>
26 
27 // Project Headers
28 #include <core/types.hh>
29 #include <core/pose/Pose.fwd.hh>
30 
31 // Utility headers
32 #include <utility/pointer/ReferenceCount.hh>
33 #include <utility/vector1.hh>
34 #include <utility/tag/Tag.fwd.hh>
35 
36 //// C++ headers
37 #include <string>
38 
39 namespace protocols {
40 namespace filters {
41 
42 class TrueFilter : public Filter {
43 public:
44  TrueFilter() : Filter( "TrueFilter" ) {}
45  bool apply( core::pose::Pose const & ) const { return true; }
46  FilterOP clone() const { return new TrueFilter; }
47  FilterOP fresh_instance() const { return new TrueFilter; }
48 };
49 
50 class FalseFilter : public Filter {
51 public:
52  FalseFilter() : Filter( "FalseFilter" ) {}
53  bool apply( core::pose::Pose const & ) const { return false; }
54  FilterOP clone() const { return new FalseFilter; }
55  FilterOP fresh_instance() const { return new FalseFilter; }
56 };
57 
58 class StochasticFilter : public Filter {
59 
60 public:
62  virtual ~StochasticFilter();
63  StochasticFilter( core::Real const confidence );
64  bool apply( core::pose::Pose const & pose ) const;
65  FilterOP clone() const;
66  FilterOP fresh_instance() const;
67  void report( std::ostream &, core::pose::Pose const & ) const {}
68 
69  void parse_my_tag(
70  utility::tag::TagPtr const tag,
72  Filters_map const &,
73  moves::Movers_map const &,
74  core::pose::Pose const & );
75 
76 private:
78 };
79 
80 /// @brief Used to define a compound logical statement involving other filters with
81 /// AND, OR and XOR
83 {
84 public:
85  typedef std::vector< std::pair< FilterOP, boolean_operations > > CompoundStatement;
86  typedef CompoundStatement::iterator iterator;
87  typedef CompoundStatement::const_iterator const_iterator;
88 
89 public:
91  virtual ~CompoundFilter();
93  bool apply( core::pose::Pose const & ) const;
94  FilterOP clone() const;
95  FilterOP fresh_instance() const;
96  void report( std::ostream &, core::pose::Pose const & ) const;
97  core::Real report_sm( core::pose::Pose const & ) const;
98  bool compute( core::pose::Pose const & ) const;
99  void clear();
100  iterator begin();
101  const_iterator begin() const;
102  iterator end();
103  const_iterator end() const;
104  virtual void set_resid( core::Size const resid );
105  void invert( bool const inv );
106 
107  void parse_my_tag(
108  utility::tag::TagPtr const,
109  moves::DataMap &,
110  Filters_map const &,
111  moves::Movers_map const &,
112  core::pose::Pose const & );
113 
114 private:
117  bool invert_;
118 };
119 
120 /// @brief Used to combine multiple seperate filters into a single filter value
121 class CombinedFilter : public Filter
122 {
123 public:
124  typedef std::pair< FilterOP, core::Real > FilterWeightPair;
126 
127  CombinedFilter();
128  virtual ~CombinedFilter();
129  bool apply( core::pose::Pose const & ) const;
130  FilterOP clone() const;
131  FilterOP fresh_instance() const;
132  void report( std::ostream &, core::pose::Pose const & ) const;
133  core::Real report_sm( core::pose::Pose const & ) const;
134  core::Real compute( core::pose::Pose const & ) const;
135 
136  void parse_my_tag(
137  utility::tag::TagPtr const,
138  moves::DataMap &,
139  Filters_map const &,
140  moves::Movers_map const &,
141  core::pose::Pose const & );
142 
143 private:
146 };
147 
148 
149 /// @brief Apply a sub-mover prior to calculating a filter value
150 class MoveBeforeFilter : public Filter
151 {
152 public:
155  virtual ~MoveBeforeFilter();
156  bool apply( core::pose::Pose const & ) const;
157  FilterOP clone() const;
158  FilterOP fresh_instance() const;
159  void report( std::ostream &, core::pose::Pose const & ) const;
160  core::Real report_sm( core::pose::Pose const & ) const;
161  //No compute(), as it passes everything on to the sub-mover
162 
163  void parse_my_tag(
164  utility::tag::TagPtr const,
165  moves::DataMap &,
166  Filters_map const &,
167  moves::Movers_map const &,
168  core::pose::Pose const & );
169 
170 private:
173 };
174 
175 /// @brief Evaluate to a value contingent on the evaluation of another filter.
176 class IfThenFilter : public Filter
177 {
178 public:
179  IfThenFilter();
180  //IfThenFilter(moves::MoverOP mover, FilterCOP filter);
181  virtual ~IfThenFilter();
182  bool apply( core::pose::Pose const & ) const;
183  FilterOP clone() const;
184  FilterOP fresh_instance() const;
185  void report( std::ostream &, core::pose::Pose const & ) const;
186  core::Real report_sm( core::pose::Pose const & ) const;
187  core::Real compute( core::pose::Pose const & ) const;
188 
190  /// @brief Set if threshold is an upper (false/default) or lower (true) limit
191  void set_lower_threshold( bool floor = false ) { floor_ = floor; }
192 
193 /// @brief Add a condition to the test.
194 /// If testfilter evaluates true, then this filter evaluates to valuefilter.
195 /// If valuefilter is NULL, then return value instead.
196 /// Conditions are evaluated in the order they were added.
197  void add_condition( FilterCOP testfilter, FilterCOP valuefilter, core::Real value = 0, bool invert = false, core::Real weight = 1 );
198 
199 /// @brief Add evaluation if no conditions trigger
200 /// If elsefilter is Null, use absolute value value instead.
201  void set_else( FilterCOP elsefilter, core::Real value = 0, core::Real elseweight = 1 );
202 
203  void parse_my_tag(
204  utility::tag::TagPtr const,
205  moves::DataMap &,
206  Filters_map const &,
207  moves::Movers_map const &,
208  core::pose::Pose const & );
209 
210 private:
215  ///@brief If true, invert the sense of the iffilter test.
217 
221 
223  ///@brief If true, threshold_ is a lower limit, rather than upper limit
224  bool floor_;
225 };
226 
227 } // filters
228 } // protocols
229 
230 #endif