Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ParetoOptMutationMover.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 sw=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 /// @author Chris King (chrisk1@uw.edu)
11 // THIS CODE IS DEPRECATED AND WILL SOON DISAPPEAR
12 // currently this is just a wrapper for GreedyOptMutationMover
13 //#include <algorithm >
20 #include <core/pose/PDBInfo.hh>
21 #include <fstream>
22 // AUTO-REMOVED #include <utility/file/FileName.hh>
23 #include <iostream>
24 // AUTO-REMOVED #include <basic/options/keys/in.OptionKeys.gen.hh>
25 // AUTO-REMOVED #include <basic/options/option_macros.hh>
26 #include <numeric/random/random.hh>
27 #include <numeric/random/random_permutation.hh>
29 #include <core/pose/Pose.hh>
32 #include <utility/tag/Tag.hh>
34 // AUTO-REMOVED #include <protocols/moves/DataMap.hh>
35 #include <basic/Tracer.hh>
41 // AUTO-REMOVED #include <core/pack/task/operation/TaskOperations.hh>
43 #include <utility/vector1.hh>
44 #include <protocols/moves/Mover.hh>
45 #include <protocols/jd2/util.hh>
46 #include <boost/foreach.hpp>
47 #define foreach BOOST_FOREACH
52 #include <protocols/jd2/Job.hh>
53 #include <utility/vector0.hh>
56 #include <utility/string_util.hh>
57 #include <utility/io/ozstream.hh>
58 
59 //Auto Headers
60 #include <utility/excn/Exceptions.hh>
61 #include <basic/options/keys/OptionKeys.hh>
62 
63 namespace protocols {
64 namespace design_opt {
65 
66 static basic::Tracer TR( "protocols.design_opt.ParetoOptMutationMover" );
67 using namespace core;
68 using namespace chemical;
69 using utility::vector1;
70 using std::pair;
71 
72 ///@brief default ctor
74  Mover( ParetoOptMutationMoverCreator::mover_name() ),
75  task_factory_( NULL ),
76 // filters_( NULL ), /* how set default vecgtor of NULLs? */
77 // sample_type_( "low" ),
78  scorefxn_( NULL ),
79  relax_mover_( NULL ),
80  dump_pdb_( false ),
81  dump_table_( false ),
82  parallel_( false ),
83  stopping_condition_( NULL ),
84  stop_before_condition_( false ),
85  skip_best_check_( false ),
86  rtmin_( false ),
87  shuffle_order_( false )
88 {}
89 
90 //full ctor
94  protocols::moves::MoverOP relax_mover,
96  vector1< std::string > sample_types,
97  vector1< core::Real > filter_deltas,
98  bool dump_pdb,
99  bool dump_table,
100  bool parallel,
101  bool stop_before_condition,
102  bool skip_best_check,
103  bool rtmin,
104  bool shuffle_order,
105  protocols::filters::FilterOP stopping_condition
106 ) :
107  Mover( ParetoOptMutationMoverCreator::mover_name() )
108 {
110  filters_ = filters;
119  rtmin_ = rtmin;
122 }
123 
124 //destruction!
126 
127 //creators
130  return new ParetoOptMutationMover;
131 }
132 
135  return new ParetoOptMutationMover( *this );
136 }
137 
138 //name getters
141 {
143 }
144 
147 {
148  return "ParetoOptMutationMover";
149 }
150 
154 }
155 
156 // setter - getter pairs
157 void
159  relax_mover_ = mover;
160 }
161 
164  return relax_mover_;
165 }
166 
167 void
169  filters_ = filters;
170 }
171 
173  return filters_;
174 }
175 
176 void
178 {
180 }
181 
184 {
185  return task_factory_;
186 }
187 
188 void
191 }
192 
193 bool
195  return dump_pdb_;
196 }
197 
198 void
199 ParetoOptMutationMover::dump_table( bool const dump_table ){
201 }
202 
203 bool
205  return dump_table_;
206 }
207 
208 void
209 ParetoOptMutationMover::stop_before_condition( bool const stop_before_condition ){
211 }
212 
213 bool
215  return stop_before_condition_;
216 }
217 
218 void
219 ParetoOptMutationMover::skip_best_check( bool const skip_best_check ){
221 }
222 
223 bool
225  return skip_best_check_;
226 }
227 
228 void
230  rtmin_ = b;
231 }
232 
233 bool
235 
236 void
238  shuffle_order_ = b;
239 }
240 
241 bool
243 
246  return reset_delta_filters_;
247 }
248 
249 void
252 }
253 
254 void
257 }
258 
261  return sample_types_;
262 }
263 
264 void
267 }
268 
271  return filter_deltas_;
272 }
273 
274 void
277 }
278 
281  return scorefxn_;
282 }
283 
284 void
285 ParetoOptMutationMover::parallel( bool const parallel ){
287 }
288 
289 bool
291  return parallel_;
292 }
293 
294 
295 void
297 {
298  using namespace core::pack::task;
299  using namespace core::pack::task::operation;
300  using namespace core::chemical;
301 
302  //this is now but a hollow shell of a mover
306  greedy_opt->apply( pose );
307 }
308 
309 
310 void
312 {
313  //filter_delta should always be a scalar!
314  if( filter_delta < Real( 0. ) ) filter_delta = -1 * filter_delta;
315  filters_.push_back( filter );
316  sample_types_.push_back( sample_type );
317  filter_deltas_.push_back( filter_delta );
318 }
319 
320 //parse rosetta scripts tags
321 void
325  protocols::moves::Movers_map const & movers,
326  core::pose::Pose const & )
327 {
328  TR << "ParetoOptMutationMover"<<std::endl;
330  //load relax mover
331  std::string const relax_mover_name( tag->getOption< std::string >( "relax_mover", "null" ) );
332  protocols::moves::Movers_map::const_iterator mover_it( movers.find( relax_mover_name ) );
333  if( mover_it == movers.end() )
334  throw utility::excn::EXCN_RosettaScriptsOption( "Relax mover "+relax_mover_name+" not found" );
335  relax_mover( mover_it->second );
336  //load scorefxn
338  //load dump_pdb
339  dump_pdb( tag->getOption< bool >( "dump_pdb", false ) );
340  //load dump_table
341  dump_table( tag->getOption< bool >( "dump_table", false ) );
342  parallel( tag->getOption< bool >( "parallel", false ) );
343  if( tag->hasOption( "stopping_condition" ) ){
344  std::string const stopping_filter_name( tag->getOption< std::string >( "stopping_condition" ) );
345  stopping_condition( protocols::rosetta_scripts::parse_filter( stopping_filter_name, filters ) );
346  TR<<"Defined stopping condition "<<stopping_filter_name<<std::endl;
347  }
348 
349  //load multiple filters from branch tags
350  utility::vector1< utility::tag::TagPtr > const branch_tags( tag->getTags() );
351  foreach( utility::tag::TagPtr const btag, branch_tags ){
352  if( btag->getName() == "Filters" ){
353  utility::vector1< utility::tag::TagPtr > const filters_tags( btag->getTags() );
354  foreach( utility::tag::TagPtr const ftag, filters_tags ){
355  std::string const filter_name( ftag->getOption< std::string >( "filter_name" ) );
356  Filters_map::const_iterator find_filt( filters.find( filter_name ));
357  if( find_filt == filters.end() ) {
358  TR.Error << "Error !! filter not found in map: \n" << tag << std::endl;
359  runtime_assert( find_filt != filters.end() );
360  }
361  std::string const samp_type( ftag->getOption< std::string >( "sample_type", "low" ));
362  core::Real filter_delta( tag->getOption< core::Real >( "filter_delta", core::Real( 0. ) ) );
363  add_filter( find_filt->second->clone(), samp_type, filter_delta );
364  } //foreach ftag
365  }// fi Filters
366  else
367  throw utility::excn::EXCN_RosettaScriptsOption( "tag name " + btag->getName() + " unrecognized." );
368  }//foreach btag
369  //load single filter
370  {
371  std::string const filter_name( tag->getOption< std::string >( "filter", "true_filter" ) );
372  if( filter_name != "true_filter" || filters_.size() < 1 ){
373  protocols::filters::Filters_map::const_iterator find_filt( filters.find( filter_name ) );
374  if( find_filt == filters.end() )
375  throw utility::excn::EXCN_RosettaScriptsOption( "Filter "+filter_name+" not found" );
376  std::string const samp_type( tag->getOption< std::string >( "sample_type", "low" ) );
377  core::Real filter_delta( tag->getOption< core::Real >( "filter_delta", core::Real( 0. ) ) );
378  //only add the default dummy filter if we dont have any others, allows user to define filters in branch tags only
379  add_filter( find_filt->second->clone(), samp_type, filter_delta );
380  }
381  }
382 
383  //get filters to reset each time a mutation is accepted. For instance, reset the baseline value of delta filters to be the best pose.
384  utility::vector1< std::string > delta_filter_names;
385  delta_filter_names.clear();
386  if( tag->hasOption( "reset_delta_filters" ) ){
387  delta_filter_names = utility::string_split( tag->getOption< std::string >( "reset_delta_filters" ), ',' );
388  foreach( std::string const fname, delta_filter_names ){
389  reset_delta_filters_.push_back( dynamic_cast< protocols::simple_filters::DeltaFilter * >( protocols::rosetta_scripts::parse_filter( fname, filters )() ) );
390  TR<<"The baseline for Delta Filter "<<fname<<" will be reset upon each accepted mutation"<<std::endl;
391  }
392  }
393  //should mutations be allowed around the tested/introduced point mutation, if so, what shell radius
394  design_shell_ = tag->getOption< core::Real >( "design_shell", -1.0 );
395  //repack which radius after mutating
396  repack_shell_ = tag->getOption< core::Real >( "repack_shell", 8.0 );
397  //stop mover once the stopping_condition is reached and do not accept the last mutation (ie, reject the mutation that set the stopping_condition to true)
398  stop_before_condition( tag->getOption< bool >( "stop_before_condition", false ) );
399  //accept mutations during the combining stage as long as they pass the filter(s), regardless of whether or not the value is the best so far.
400  skip_best_check( tag->getOption< bool >( "skip_best_check", false ) );
401  rtmin( tag->getOption< bool >( "rtmin", false ) );
402  //load shuffle_order
403  shuffle_order( tag->getOption< bool >( "shuffle_order", false ) );
404 
405 
406 }
407 
408 
409 } // moves
410 } // protocols