Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FilterStructs.cc
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 protocols/flxbb/FilterStructs.cc
11 /// @brief
12 /// @author Nobuyasu Koga ( nobuyasu@uw.edu )
13 
14 // Unit Header
16 
17 // Project Headers
18 #include <core/pose/Pose.hh>
20 #include <basic/Tracer.hh>
21 
22 // Utility Headers
23 #include <utility/exit.hh>
24 
25 #include <utility/vector1.hh>
26 
27 
28 using basic::T;
29 using basic::Error;
30 using basic::Warning;
31 
32 static basic::Tracer TR("protocols.flxbb.FilterStructs");
33 
34 
35 using namespace core;
36 using namespace protocols::flxbb;
37 
38 namespace protocols {
39 namespace flxbb {
40 
41 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
42 /// @brief default constructor
43 FilterStructs::FilterStructs():
44  name_( "BaseFilterStructs" ),
45  filter_on_( true ),
46  ntrial_( 5 ),
47  current_trial_( 0 ),
48  best_pose_( NULL )
49 {}
50 
51 /// @brief value constructor
53  name_( name ),
54  filter_on_( true ),
55  ntrial_( 5 ),
56  current_trial_( 0 ),
57  best_pose_( NULL )
58 {}
59 
60 /// @brief value constructor
61 FilterStructs::FilterStructs( String const & name, Size const ntrial ):
62  name_( name ),
63  filter_on_( true ),
64  ntrial_( ntrial ),
65  current_trial_( 0 ),
66  best_pose_( NULL )
67 {}
68 
69 
70 /// @brief value constructor
71 FilterStructs::FilterStructs( String const & name, Pose const & pose, Size const ntrial ):
72  name_( name ),
73  filter_on_( true ),
74  ntrial_( ntrial ),
75  current_trial_( 0 ),
76  best_pose_( new Pose(pose) )
77 {}
78 
79 /// @brief copy constructor
81  ReferenceCount(),
82  name_( rval.name_ ),
83  filter_on_( rval.filter_on_ ),
84  ntrial_( rval.ntrial_ ),
85  best_pose_( rval.best_pose_ )
86 {
87  current_trial_ = 0;
88 }
89 
90 /// @brief destructor
92 
93 /// @brief clone this object
96 {
97  utility_exit_with_message( "clone has been called on a Mover which has not overriden the base class implementation. Probably you tried to pass a Mover to the job distributor or parser which does not have clone implemented. Implement the function and try again.\n");
98  return FilterStructsOP( NULL );
99 }
100 
101 /// @brief create a new instance of this type of object
104 {
105  utility_exit_with_message("fresh_instance has been called on a Mover which has not overriden the base class implementation. Probably you tried to pass a Mover to the job distributor which does not have fresh_instance implemented. Implement the function and try again.\n");
106  return FilterStructsOP( NULL );
107 }
108 
109 /// @brief return best pose
112 {
113  return best_pose_;
114 }
115 
116 /// @brief
117 void
119 {
120  name_ = name;
121 }
122 
123 /// @brief set ntrial
124 void
126 {
127  ntrial_ = ntrial;
128 }
129 
130 /// @brief
131 void
133 {
134  set_filter_on();
135  current_trial_ = 0;
136  best_pose_ = new Pose( pose );
137 }
138 
139 /// @brief set ntrial
140 void
142 {
143  ++current_trial_;
144 }
145 
146 /// @brief
147 bool
149 {
150  if( current_trial_ >= ntrial_ ){
151  return true;
152  }else{
153  return false;
154  }
155 }
156 
157 /// @brief set best pose
158 void
160 {
161  best_pose_ = new Pose( pose );
162 }
163 
164 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
165 /// @brief value constructor
167  FilterStructs( "FilterStructs_Packstat", ntrial ),
168  best_packscore_( 0.0 )
169 {}
170 
171 /// @brief value constructor
173  FilterStructs( "FilterStructs_Packstat", pose, ntrial ),
174  best_packscore_( 0.0 )
175 {}
176 
177 /// @brief copy constructor
179  Super( rval ),
180  best_packscore_( rval.best_packscore_ )
181 {}
182 
183 /// @brief destructor
185 
186 /// @brief clone
188 {
189  return new FilterStructs_Packstat( *this );
190 }
191 
192 /// @brief fresh instance
194 {
195  return new FilterStructs_Packstat();
196 }
197 
198 /// @brief
200 {
201  best_packscore_ = 0.0;
202  initialize( pose );
203 }
204 
205 /// @brief filter apply
207 {
208  using namespace core::scoring::packstat;
209  count_ntrial();
210  Real packscore;
211  packscore = compute_packing_score( pose );
212 
213  if ( packscore > best_packscore_ ) {
214  set_bestpose( pose );
215  best_packscore_ = packscore;
216  TR << " Packscore : " << best_packscore_ << std::endl;
217  }
218  if( filter_is_over() ){
219  set_filter_off();
220  }
221 }
222 
223 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
224 /// @brief constructor
226  FilterStructs( "FilterStructs_TotalCharge", ntrial ),
227  disallowed_value_( 1 )
228 {}
229 
230 /// @brief constructor
232  FilterStructs( "FilterStructs_TotalCharge", pose, ntrial ),
233  disallowed_value_( 1 )
234 {}
235 
236 /// @brief copy constructor
238  Super( rval ),
239  disallowed_value_( rval.disallowed_value_ )
240 {}
241 
242 /// @brief destructor
244 
245 /// @brief clone
247 {
248  return new FilterStructs_TotalCharge( *this );
249 }
250 
251 /// @brief clone
253 {
254  return new FilterStructs_TotalCharge();
255 }
256 
257 /// @brief
259 {
260  initialize( pose );
261 }
262 
263 /// @brief filter apply
265 {
266 
267  count_ntrial();
268  Real total_charge( 0.0 );
269  for( Size i=1; i<=pose.total_residue(); ++i){
270 
271  chemical::AA aa = pose.aa( i );
272 
273  if( aa == chemical::aa_from_name( "GLU" ) ){
274  total_charge -= 1.0;
275  }else if( aa == chemical::aa_from_name( "ASP" ) ){
276  total_charge -= 1.0;
277  }else if( aa == chemical::aa_from_name( "ARG" ) ){
278  total_charge += 1.0;
279  }else if( aa == chemical::aa_from_name( "LYS" ) ){
280  total_charge += 1.0;
281  }
282  }
283 
284  if( total_charge != disallowed_value_ || filter_is_over() ){
285  set_filter_off();
286  set_bestpose( pose );
287  TR << " Total charge : " << total_charge << std::endl;
288  }
289 
290 }
291 
292 
293 } // namespace flxbb
294 } // namespace protocols