Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CentroidRelax.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
6 // (c) under license. The Rosetta software is developed by the contributing
7 // (c) members of the Rosetta Commons. For more information, see
8 // (c) http://www.rosettacommons.org. Questions about this can be addressed to
9 // (c) University of Washington UW TechTransfer,email:license@u.washington.edu.
10 
11 /// @file Centroid-based relax, using Frank Dimaio's updated centroid stats
12 /// @brief CentroidRelax Protocol.
13 /// @author Jared Adolf-Bryfogle (jadolfbr@gmail.com)
14 
15 //Project Headers
18 #include <protocols/relax/util.hh>
19 
20 //Core Headers
21 #include <core/pose/Pose.hh>
33 
34 //Protocol Headers
36 
42 
43 //Option Headers
44 #include <basic/options/keys/relax.OptionKeys.gen.hh>
45 #include <basic/options/keys/score.OptionKeys.gen.hh>
46 #include <basic/options/option.hh>
47 
48 //Utility Headers
49 #include <basic/Tracer.hh>
50 #include <utility/file/FileName.hh>
51 #include <utility/file/file_sys_util.hh>
52 #include <utility/io/izstream.hh>
53 #include <utility/vector1.hh>
54 #include <basic/database/open.hh>
55 
56 static basic::Tracer TR("protocols.relax.CentroidRelax");
57 namespace protocols {
58 namespace relax {
59  using namespace basic::options;
60  using namespace core::scoring;
61  using namespace protocols::simple_moves;
62  using namespace core::pack::task;
63  using namespace protocols::moves;
64  using core::pose::Pose;
65  using core::Real;
66  using std::string;
67 
68 
70  RelaxProtocolBase("CentroidRelax")
71  {
72  string def_score = option [OptionKeys::relax::centroid::weights]();
74  set_score_function(score);
75  set_defaults();
76 
77  }
78 
80  RelaxProtocolBase("CentroidRelax")
81  {
82  string def_score = option [OptionKeys::relax::centroid::weights]();
84  set_score_function(score);
85  set_defaults();
86  set_movemap(mm);
87  }
88 
90  RelaxProtocolBase("CentroidRelax")
91  {
92  set_score_function(cen_scorefxn_in);
93  set_defaults();
94  set_movemap(mm);
95 
96  }
97 
98  //Mover Methods
100 
103  return new CentroidRelax(*this);
104  }
105 
106  string
108  return "CentroidRelax";
109  }
110 
111  void
113  ScoreFunctionOP score = cen_score->clone();
114  //Both Base class and CentroidRelax class have owning pointers to the centroid scorefunction.
115  set_scorefxn(score);
117  cen_scorefxn_->set_weight(chainbreak, 100.00); //I hate chainbreaks.
118  }
119 
120  void
122  ScoreFunctionOP score = fa_score->clone();
123  fa_scorefxn_ = score;
124  }
125  void
127 
128  set_rounds(option [OptionKeys::relax::default_repeats]());
129  set_ramp_vdw(option [OptionKeys::relax::centroid::ramp_vdw]());
130  set_ramp_rama(option [OptionKeys::relax::centroid::ramp_rama]());
131  set_cartesian(option[OptionKeys::relax::cartesian]());
133  set_use_rama2b(option [OptionKeys::score::ramaneighbors]());
134  set_use_increased_vdw_radii(option [OptionKeys::relax::centroid::increase_vdw_radii]());
135  do_final_repack(option [OptionKeys::relax::centroid::do_final_repack]());
137  }
138 
139 
140  void
142  rounds_ = rounds;
143  }
144 
145  void
148  }
149 
150  void
152  //Should be already in score function - But it's not.
153  Real rama_weight = cen_scorefxn_->get_weight(rama);
154  Real rama2b_weight = cen_scorefxn_->get_weight(rama2b);
155 
156  if (use){
158  if (rama2b_weight==0){
159  cen_scorefxn_->set_weight(rama2b, rama_weight);
160  cen_scorefxn_->set_weight(rama, 0.0);
161  }
162  }
163  else{
165  if (rama_weight==0){
166  cen_scorefxn_->set_weight(rama, rama2b_weight);
167  cen_scorefxn_->set_weight(rama2b, 0.0);
168  }
169  }
170  }
171 
172  void
174  ramp_rama_ = use;
175  }
176  void
178 
179  movemap_= get_movemap()->clone();
180  if ( core::pose::symmetry::is_symmetric( pose ) ) {
182  }
183 
184  initialize_movemap(pose, *movemap_);
185  make_dna_rigid(pose, *movemap_);
188  cen_scorefxn_->show(TR, pose);
189 
190  }
191 
192  void
194  ///Courtesy of Frank Dimaio:
195  TR<<"Increasing BB VDW Radii"<<std::endl;
196  core::scoring::methods::EnergyMethodOptions lowres_options(cen_scorefxn_->energy_method_options());
197  lowres_options.atom_vdw_atom_type_set_name("centroid_min");
198  cen_scorefxn_->set_energy_method_options(lowres_options);
199  }
200 
201  void
203  ramp_vdw_ = use;
204  }
205 
206  void
208  cartesian_ = cart;
209 
210  if (cart){
211  set_min_type("lbfgs_armijo_nonmonotone");
213  set_score_function(score);
214  }
215  else {
216  set_min_type(option [OptionKeys::relax::min_type]());
217  string def_score = option [OptionKeys::relax::centroid::weights]();
219  set_score_function(score);
220  }
221  }
222  void
224  min_type_ = min;
225  }
226 
227  void
229  string const fname = option [ OptionKeys::relax::centroid::parameters]();
230  utility::io::izstream param_stream;
231  basic::database::open(param_stream, fname);
232  Real vdw_ramp; Real rama_ramp; Real min; Real cst;
233  core::Size line_count = 0;
234  while (! param_stream.eof() ){
235  ++line_count;
236  param_stream >> vdw_ramp >> rama_ramp >> min >> cst;
237  def_parameters.vdw_params.push_back(vdw_ramp);
238  def_parameters.rama_params.push_back(rama_ramp);
239  def_parameters.min_params.push_back(min);
240  def_parameters.cst_params.push_back(cst);
241 
242  }
243  param_stream.close();
244 
245  }
246 
247  void
249  repack_sc_=repack_sc;
250  }
251 
252  void
254 
255 
256 
259  }
260 
261 
262  //Get the rama_weight. If it's rama2b, get that.
263  Real rama_weight = cen_scorefxn_->get_weight(rama);
264  if (rama_weight==0){
265  rama_weight = cen_scorefxn_->get_weight(rama2b);
266  if (rama_weight==0){
267  set_ramp_rama(false);
268  }
269  }
270 
271  //Get vdw weight.
272  Real vdw_weight = cen_scorefxn_->get_weight(vdw);
273  if (vdw_weight==0){
274  set_ramp_vdw(false);
275  }
276 
277 
278 
279 
280  MonteCarloOP cen_mc;
281 
282 
283  ReturnSidechainMoverOP recover_sc;
284 
285 
286  bool passed_centroid;
287  if (! pose.is_centroid()){
288  TR << "FullAtom Score::"<<std::endl;
289 
290  fa_scorefxn_->show(TR, pose);
291 
292  recover_sc = new ReturnSidechainMover(pose);
294  to_cen->apply(pose);
295 
296  passed_centroid = false;
297 
298  TR << "Centroid Score::"<<std::endl;
299  //cen_scorefxn_->show(TR, pose);
300  cen_mc = new MonteCarlo(pose, *cen_scorefxn_, 1.0);
301 
302  } else {
303 
304  passed_centroid = true;
305  cen_scorefxn_->show(TR, pose);
306  cen_mc = new MonteCarlo(pose, *cen_scorefxn_, 1.0);
307 
308  }
309 
310 
312 
313  //Initialize MinMover
314  MinMoverOP minmover;
315  if ( core::pose::symmetry::is_symmetric( pose ) ) {
317  else {
318  minmover = new MinMover( movemap_, cen_scorefxn_, min_type_, def_parameters.min_params[1], true );
319  }
320  minmover->cartesian( cartesian_ );
321 
322  //Test to make sure something is ramped - If not, run basic.
323  if (!ramp_vdw_ && !ramp_rama_){
324  TR << "Running BASIC Relax" <<std::endl;
325  for (core::Size i=1; i<=rounds_; i++){
326  minmover->apply(pose);
327  TR <<"Cen Score: "<<(*cen_scorefxn_)(pose)<<std::endl;
328  cen_mc->boltzmann(pose);
329  }
330 
331  cen_mc->recover_low(pose);
332  }
333  else{
334  TR <<"Starting RAMPED Protocol"<<std::endl;
335  EnergyMap cen_emap = cen_scorefxn_()->weights();
336  TR <<"Total Rounds : " <<rounds_ <<std::endl;
337  TR <<"Total Ramps : " <<def_parameters.vdw_params.size() <<std::endl;
338  //Outer loop
339  for (core::Size i=1; i<= rounds_; i++){
340  TR <<"Starting Round "<<i<<std::endl;
341 
342  //Inner loop
343  for (core::Size i2 = 1; i2 <=def_parameters.vdw_params.size(); i2++){
344 
345  //Set Weights
346  TR<< "Ramp "<<i2<<std::endl;
347  if (ramp_vdw_){
348  cen_scorefxn_->set_weight(vdw, cen_emap[vdw]*def_parameters.vdw_params[i2]);
349  }
350  if (ramp_rama_){
351  cen_scorefxn_->set_weight(rama_type_, cen_emap[rama_type_]*def_parameters.rama_params[i2]);
352  }
353  //Removing ramp, as without any coordinate constraints structures core will compress
354  //if (constrain_coords_ && ramp_down_constraints_){
355  //cen_scorefxn_->set_weight(coordinate_constraint, cen_emap[coordinate_constraint]*def_parameters.cst_params[i2]);
356  //}
357  minmover->tolerance(def_parameters.min_params[i2]);
358  minmover->apply(pose);
359  TR << (*cen_scorefxn_)(pose) << std::endl;
360  //Use MC on last run->Check how many times we ramp from the vdw_params ->Doesn't matter which param we check.
361  if (i2==def_parameters.vdw_params.size()){
362  TR <<"Cen Energy with full weights :"<<(*cen_scorefxn_)(pose)<<std::endl;
363  cen_scorefxn_->show(TR, pose);
364  cen_mc->boltzmann(pose);
365  }
366  }
367  //Recover lowest scoring decoy if last round.
368  if (i==rounds_){
369  cen_mc->recover_low(pose);
370  }
371  }
372  }
373 
374  if (!passed_centroid){
375  //TR <<"Scoring Final Pose :"<<pose.is_centroid()<<std::endl;
376  cen_scorefxn_->show(TR, pose);
377  recover_sc->apply(pose);
378  fa_scorefxn_->show(TR, pose);
379  if (repack_sc_){
380  TR <<"Repacking Sidechains"<<std::endl;
382  task->restrict_to_repacking();
383  task->temporarily_fix_everything();
384  for (core::Size i=1; i<=pose.total_residue();++i){
385  if (movemap_->get_chi(i)){
386  task->temporarily_set_pack_residue(i, true);
387  }
388  }
390  packer->apply(pose);
391  fa_scorefxn_->show(TR, pose);
392  }
393 
394  TR << "Centroid relax complete. Returning all-atom Structure."<<std::endl;
395  return;
396  }
397  else {
398 
399  TR << "Centroid relax complete. Returning centroid Structure." <<std::endl;
400  cen_scorefxn_->show(TR, pose);
401  return;
402  }
403 
404 
405  }//END apply method
406 }
407 }
408