Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AutoRBRelaxMover.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
11 /// @brief
12 /// @author Srivatsan Raman
13 /// @author Frank DiMaio
14 
15 #include <core/types.hh>
16 
17 #include <core/kinematics/Jump.hh>
18 #include <core/pose/Pose.hh>
19 #include <core/pose/util.hh>
20 #include <basic/Tracer.hh>
23 
25 #include <protocols/loops/Loop.hh>
26 
27 #include <core/scoring/Energies.hh>
28 
39 
42 
46 
47 
49 #include <basic/options/option.hh>
50 #include <core/fragment/FragSet.hh>
52 #include <numeric/random/random.hh>
53 
54 // C++ headers
55 #include <iostream>
56 #include <string>
57 
58 
59 //options
60 #include <basic/options/keys/edensity.OptionKeys.gen.hh>
61 #include <basic/options/keys/RBSegmentRelax.OptionKeys.gen.hh>
62 
64 #include <utility/vector0.hh>
65 #include <utility/vector1.hh>
66 
67 
68 using basic::T;
69 using basic::Error;
70 using basic::Warning;
71 
72 namespace protocols {
73 namespace rbsegment_relax {
74 
75 basic::Tracer tr("protocols.rbsegment_relax.RBSegment.AutoRBRelaxMover");
76 
77 ////////////////
78 // stupid mover
80 public:
82  movemap_(movemap),
83  start_(start),
84  stop_(stop),
85  cut_(cut) { }
86 
87  void apply( Pose & pose ) {
89  }
90 
91  virtual std::string get_name() const {
92  return ("CCDMoveWrapper");
93  }
94 
95 private:
98 };
99 
101 
102 
103 
104 ///////////////////
105 ///
107  using namespace basic::options;
108 
110  option[ OptionKeys::RBSegmentRelax::rb_scorefxn ]() );
111 
113 
114  nouter_cycles_ = option[ OptionKeys::RBSegmentRelax::nrboutercycles ]();
115  ninner_cycles_ = option[ OptionKeys::RBSegmentRelax::nrbmoves ]();
116 
117  loop_melt_ = 3;
118 
119  // load frags
121 
122  allowSeqShiftMoves_ = !(option[ OptionKeys::RBSegmentRelax::skip_seqshift_moves]());
123 
124  allowSSFragInserts_ = false;
125 
126  // fa stuff
132 
134  fa_scorefxn_->set_weight( core::scoring::chainbreak, 10.0/3.0);
135 
136  if ( option[ OptionKeys::edensity::mapfile ].user() ) {
139  }
140 }
141 
142 void
144  // ensure pose is in centroid mode
146  to_centroid.apply( pose );
147 
148  // ensure pose is rooted on VRT
150 
151  // Get DSSP parse; use it to:
152  // build fold tree (star topology)
153  // set movemap
154  // set variant types
155  setup_topology( pose );
156 
157  // load constraints
159 
160  core::Size nres = pose.total_residue()-1;
161  bool loops_closed = false;
162  grow_flexible( loop_melt_, nres, 1 );
163 
164  core::pose::Pose start_pose = pose;
165 
166  while( !loops_closed ) {
167  pose = start_pose;
168 
169  // setup fragment movers
172  it = frag_libs_.begin(), it_end = frag_libs_.end();
173  it != it_end; it++ ) {
175  cfm->set_check_ss( false );
176  cfm->enable_end_bias_check( false );
177  fragmover.push_back( cfm );
178  }
179 
180  // mc object
181  core::Real init_temp = 2.0;
182  core::Real temperature = init_temp;
183  core::Real final_temp = 0.6;
184  core::Real const gamma = std::pow(final_temp/init_temp, (1.0/(nouter_cycles_*ninner_cycles_)) );
185  moves::MonteCarloOP mc_ = new moves::MonteCarlo( pose, *scorefxn_, init_temp );
186 
187  // movement loop
188  float final_chain_break_weight = 1.0;
189  float delta_weight( final_chain_break_weight/nouter_cycles_ );
190 
191  // random mover
192  protocols::moves::RandomMover random_move;
193 
194  // loop fragment insertion
195  for ( std::vector< protocols::simple_moves::FragmentMoverOP >::const_iterator
196  it = fragmover.begin(),it_end = fragmover.end(); it != it_end; it++ )
197  random_move.add_mover(*it, rb_chunks_.size());
198 
199  // rigid-body move
200  for (int i=1; i<=(int)rb_chunks_.size(); ++i)
201  random_move.add_mover(new rigid::RigidBodyPerturbMover( i , 3.0 , 1.0 ));
202 
203  //TODO rigid-chunk fragment insertion
204  //if (allowSSFragInserts_) ;
205 
206  // sequence shift
207  if (allowSeqShiftMoves_) {
208  for (int i=1; i<=(int)rb_chunks_.size(); ++i)
209  for (int j=1; j<=(int)rb_chunks_[i].nContinuousSegments(); ++j) {
211  seq_shift_move->add_mover( new SequenceShiftMover(rb_chunks_[i][j]) );
212 
213  // find adjacent loops
214  for (core::Size k=1; k<=loops_.size(); ++k) {
215  bool adjLoopN = (loops_[k].stop() >= rb_chunks_[i][j].start()-1) && (loops_[k].stop() <= rb_chunks_[i][j].end()+1);
216  bool adjLoopC = (loops_[k].start() >= rb_chunks_[i][j].start()-1) && (loops_[k].start() <= rb_chunks_[i][j].end()+1);
217  if ( adjLoopN || adjLoopC ) {
218  seq_shift_move->add_mover( new CCDMoveWrapper(movemap_, loops_[k].start(), loops_[k].stop(), loops_[k].cut() ) );
219  }
220  }
221  random_move.add_mover(seq_shift_move, 0.5);
222  }
223  }
224 
225  scorefxn_->set_weight( core::scoring::chainbreak, 0.0 );
226  for( int n1 = 1; n1 <= (int)nouter_cycles_; ++n1 ) {
227  mc_->recover_low( pose );
228  scorefxn_->set_weight( core::scoring::chainbreak, n1*delta_weight );
229 
230  (*scorefxn_)(pose);
231  if ( tr.visible() ) { scorefxn_->show_line( tr.Info , pose ); }
232  tr.Info << std::endl;
233  mc_->score_function( *scorefxn_ );
234 
235  for( int n2 = 1; n2 <= (int)ninner_cycles_; ++n2 ) {
236  // cool
237  temperature *= gamma;
238  mc_->set_temperature( temperature );
239 
240  // randomly do something
241  if( numeric::random::uniform()*nouter_cycles_ > n1 ) {
242  random_move.apply(pose);
243  } else {
245  protocols::loops::loop_closure::ccd::ccd_moves(5, pose, *movemap_, it->start(), it->stop(), it->cut() );
246  }
247 
248  mc_->boltzmann( pose );
249  }
250  }
251  mc_->recover_low( pose );
252  mc_->show_counters();
253 
254  scorefxn_->set_weight( core::scoring::chainbreak, 1.0 );
255  (*scorefxn_)(pose);
256 
257  loops_closed = ( pose.energies().total_energies()[ core::scoring::chainbreak ] ) <= loops_.size()*0.5;
258  if (!loops_closed) {
259  tr << "Loops not closed! ("
261  << " > " << loops_.size()*0.5 << ")" << std::endl;
262  grow_flexible( loop_melt_, nres );
263  } else {
264  tr << "Loops closed! ("
266  << " <= " << loops_.size()*0.5 << ")" << std::endl;
267  }
268  }
269 
270  //////////////
271  // fastrelax -- keep foldtree
272  relax::FastRelax fast_relax( fa_scorefxn_ );
273  fast_relax.apply( pose );
274 }
275 
276 ////
277 //// grow loops
278 //// dont allow jump residues to be flexible
279 void
281  if (maxlen == 0) return;
282 
283  tr << "EXTENDING LOOPS:" << std::endl;
284  for ( core::Size i=1; i <= loops_.size(); i++ ) {
285  core::Size extend_start = (core::Size) numeric::random::random_range(minlen, maxlen-minlen);
286  core::Size extend_stop = (core::Size) numeric::random::random_range(minlen, maxlen-minlen);
287  if ( ( extend_start == 0 ) && ( extend_stop == 0 ) ) {
288  if ( numeric::random::uniform() > 0.5) extend_start = 1;
289  else extend_stop = 1;
290  }
291 
292  // dont go past termini
293  if (loops_[i].start() < 1 + extend_start) extend_start = loops_[i].start()-1;
294  if (loops_[i].stop() + extend_stop > nres ) extend_stop = nres - loops_[i].stop();
295 
296  // make sure we dont go over a jump point
297  for (core::Size j=1; j<=jumps_.size(); ++j) {
298  if (loops_[i].start()-extend_start <= jumps_[j] && loops_[i].start() > jumps_[j])
299  extend_start = loops_[i].start() - jumps_[j] + 1;
300  if (loops_[i].stop()+extend_stop >= jumps_[j] && loops_[i].stop() < jumps_[j])
301  extend_stop = jumps_[j] - loops_[i].stop() +1;
302  }
303 
304  loops_[i].set_start( loops_[i].start()-extend_start );
305  loops_[i].set_stop( loops_[i].stop()+extend_stop );
306  }
307  tr << loops_ << std::endl;
308 }
309 
310 ////
311 //// set up foldtree, variants, movemap, etc.
312 void
314  //core::Size nres = pose.total_residue()-1; // terminal VRT
315 
316  rigid_segs_.clear();
317  rb_chunks_.clear();
318  jumps_.clear();
319  loops_.clear();
320 
323 }
324 
325 }
326 }
327