Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
H3RefineCCD.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 protocols/antibody2/H3RefineCCD.cc
12 /// @brief Build a homology model of an antibody2
13 /// @detailed
14 ///
15 ///
16 /// @author Jianqing Xu (xubest@gmail.com)
17 
18 
19 
21 
22 #include <basic/Tracer.hh>
23 #include <basic/options/option.hh>
24 #include <basic/options/keys/in.OptionKeys.gen.hh>
25 
31 
36 
44 
46 
49 #include <protocols/loops/Loop.hh>
50 #include <protocols/loops/Loops.hh>
53 
56 
61 
63 #include <core/io/pdb/pose_io.hh>
64 #include <core/pose/Pose.hh>
65 #include <core/pose/PDBInfo.hh>
66 #include <core/pose/util.hh>
67 
68 
70 
72 //JQX:: this header file took care of the "CUTPOINT_LOWER" options below
73 
74 
75 
76 
77 
78 using basic::T;
79 using basic::Error;
80 using basic::Warning;
81 
82 static basic::Tracer TR("protocols.antibody2.H3RefineCCD");
83 
84 
85 
86 
87 using namespace core;
88 namespace protocols {
89 namespace antibody2 {
90 
91 
92 
93 
94 // default constructor
95 H3RefineCCD::H3RefineCCD( ) : Mover() {}
96 
97 H3RefineCCD::H3RefineCCD( AntibodyInfoOP antibody_info, AntibodyCDRNameEnum loop_name ) : Mover()
98 {
99  user_defined_ = false;
100  ab_info_ = antibody_info;
101  loop_name_ = loop_name;
102 
103  init();
104 }
105 
106 
108  AntibodyCDRNameEnum loop_name,
109  scoring::ScoreFunctionCOP highres_scorefxn
110  ) : Mover()
111 {
112  user_defined_ = true;
113  ab_info_ = antibody_info;
114  loop_name_ = loop_name;
115  highres_scorefxn_ = new scoring::ScoreFunction(*highres_scorefxn);
116 
117  init();
118 }
119 
120 H3RefineCCD::H3RefineCCD( AntibodyInfoOP antibody_info ) : Mover()
121 {
122  ab_info_ = antibody_info;
123 
124  init();
125 }
126 
127 
129 {
130  set_default();
131 
132  the_loop_ = ab_info_->get_CDR_loop(loop_name_);
133 
135  cutpoint_ = the_loop_.cut();
137  loop_size_ = ( loop_end_ - loop_begin_ ) + 1;
138 
139  gamma_ = std::pow( (last_temp_/init_temp_), (1.0/loop_size_)); //TODO: check this gama value carefully
140 
141  n_small_moves_ = numeric::max(Size(5), Size(loop_size_/2)) ;
143  outer_cycles_ = 2; //JQX: assume the SnugFit step has done some minimization
144  if( refine_input_loop_ ){
145  outer_cycles_ = 5;
146  }
147  if( benchmark_ ) {
148  min_tolerance_ = 1.0;
149  n_small_moves_ = 1;
150  inner_cycles_ = 1;
151  outer_cycles_ = 1;
152  }
153 
154 }
155 
156 
157 
158 
159 
161 {
162  include_neighbors_ = true;
163  H3_filter_ = true;
164  flank_relax_ = true;
165 
166  benchmark_ = false;
167  refine_input_loop_ = false;
168  is_camelid_ = false;
169 
170  neighbor_dist_ = 10.0;
171  flank_size_ = 2;
172  min_tolerance_ = 0.001;
173  high_move_temp_ = 2.00;
174 
175  init_temp_ = 2.0;
176  last_temp_ = 0.5;
177 
178  high_cst_ = 100.0;
180  minimization_type_ = "dfpmin_armijo_nonmonotone" ;
181 
182 
183  if(!user_defined_){
185  highres_scorefxn_->set_weight( scoring::chainbreak, 1.0 );
186  highres_scorefxn_->set_weight( scoring::overlap_chainbreak, 10./3. );
188  }
189 
190 }
191 
192 
193 
194 // default destructor
196 
197 //clone
199  return( new H3RefineCCD() );
200 }
201 
202 
203 
204 
205 
206 
207 
208 
209 
211  return "H3RefineCCD";
212 }
213 
214 
215 
217  start_pose_ = start_pose;
218 }
219 
220 
221 
222 
223 
224 
225 
226 
227 
229 
230  // score the pose first
231  (*highres_scorefxn_) (pose);
232 
233 
234  // the list of residues that are allowed to pack
235  for(Size ii=1; ii <=pose.total_residue();ii++) {allow_repack_.push_back(false);}
237 
238 
239  // the list of residues that are allowed to change backbone
240  utility::vector1< bool> allow_bb_move( pose.total_residue(), false );
241  for( Size ii = loop_begin_; ii <= loop_end_; ii++ ){
242  allow_bb_move[ ii ] = true;
243  }
244 
245  // the movemap of the h3 loop, if flank_relax_=false, flank_cdrh3_map_=cdrh3_map_
247  cdrh3_map_->set_jump( 1, false );
248  cdrh3_map_->set_bb( allow_bb_move );
249  cdrh3_map_->set_chi( allow_repack_ );
250 
251  if( flank_relax_) {
252  utility::vector1< bool> flank_allow_bb_move( allow_bb_move );
253  for( Size i = 1; i <= pose.total_residue(); i++ ){
254  if( (i >= (loop_begin_ - flank_size_)) && (i <= (loop_end_ + flank_size_)) ){
255  flank_allow_bb_move[i] = true;
256  }
257  }
258 
260  flank_cdrh3_map_->set_jump( 1, false );
261  flank_cdrh3_map_->set_bb( flank_allow_bb_move );
262  flank_cdrh3_map_->set_chi( allow_repack_ );
263  }
264  else{
266  }
267 
268 
269  // below are the definitions of a bunch of movers
270  using namespace protocols;
271  using namespace protocols::simple_moves;
272  using namespace protocols::loops;
273  using namespace protocols::moves;
274  using namespace protocols::toolbox::task_operations;
275  using namespace pack;
276  using namespace pack::task;
277  using namespace pack::task::operation;
280 
281 
282  // the Monte Carlo mover
284 
285 
286  // setup some easy objects to change the fold trees
287  // if not flank_relax =false, then change_FT_to_flankloop_ = change_FT_to_simpleloop_
288  simple_fold_tree( pose, loop_begin_ - 1, cutpoint_, loop_end_ + 1 );
290 
291  if(flank_relax_){
293  }
295 
296  // cut points variants for chain-break scoring
297  loops::remove_cutpoint_variants( pose, true ); //remove first
299 
300 
301 
302  // pack the loop and its neighboring residues
305  ( *highres_scorefxn_ )( pose );
306  tf_->push_back( new RestrictToInterface( allow_repack_ ) );
307  loop_repack_->task_factory(tf_);
308  //loop_repack_->apply( pose_in );
309 
310 
311  // minimize amplitude of moves if correct parameter is set
314 
315  small_mover->angle_max( 'H', 2.0 );
316  small_mover->angle_max( 'E', 5.0 );
317  small_mover->angle_max( 'L', 6.0 );
318 
319  shear_mover->angle_max( 'H', 2.0 );
320  shear_mover->angle_max( 'E', 5.0 );
321  shear_mover->angle_max( 'L', 6.0 );
322 
323 
324  // ccd moves
325  CcdMoverOP ccd_moves = new CcdMover( the_loop_, cdrh3_map_ );
327 
328 
329  // minimization mover
331 
332 
333  // put everything into a sequence mover
334  wiggle_cdr_h3_ = new SequenceMover() ;
336  wiggle_cdr_h3_->add_mover( small_mover );
337  wiggle_cdr_h3_->add_mover( shear_mover );
338  wiggle_cdr_h3_->add_mover( ccd_cycle );
340  wiggle_cdr_h3_->add_mover( loop_min_mover_ );
341 
342 }
343 
344 
345 
346 
347 
348 
349 
350 
351 
352 
353 
354 
355 
356 //APPLY
358  using namespace protocols::simple_moves;
359  using namespace protocols::moves;
360  using namespace protocols::toolbox::task_operations;
361  using namespace pack::task;
362  using namespace pack::task::operation;
363 
364  /// FIXME: This can cause issues if using the default refine_method in RefineOneCDRLoop and a loop in centroid mode!
365  /// This can happen in SnugDock.
366  if ( !pose.is_fullatom() ){utility_exit_with_message("Fullatom poses only");}
367 
368  TR << " Relaxing Fullatom CDR H3 loop" << std::endl;
369 
370 
371  finalize_setup(pose);
372 
373 
374  bool closed_cutpoints( false );
375  Size cycle( 1 );
376  while( !closed_cutpoints && cycle<max_cycle_close_trial_ ) {
377  TR << " Refining CDR H3 loop in HighRes. close_trial_cycle="<<cycle << std::endl;
378 
379 
380  change_FT_to_flankloop_->apply(pose);
381  loop_min_mover_->apply(pose);
382 
383  // rotamer trials
386  ( *highres_scorefxn_ )( pose );
387  tf_->push_back( new RestrictToInterface( allow_repack_ ) );
389  pack_rottrial->apply( pose );
390 
391 
392 
393 
394  Real temperature = init_temp_;
395  mc_->reset( pose ); // monte carlo reset
396 
397  bool relaxed_H3_found_ever( false );
398  if( H3_filter_){
399  relaxed_H3_found_ever = CDR_H3_cter_filter( pose,ab_info_);
400  }
401 
402  // outer cycle
403  for(Size i = 1; i <= outer_cycles_; i++) {
404  mc_->recover_low( pose );
405  Size h3_attempts(0); // number of H3 checks after refinement
406 
407  // inner cycle
408  for ( Size j = 1; j <= inner_cycles_; j++ ) {
409  mc_->set_temperature( temperature*= gamma_ );
410 
411  wiggle_cdr_h3_->apply( pose );
412 
413  // rotamer trials
416  ( *highres_scorefxn_ )( pose );
417  tf_->push_back( new RestrictToInterface( allow_repack_ ) );
418  pack_rottrial->task_factory(tf_);
419  pack_rottrial->apply( pose );
420 
421  bool relaxed_H3_found_current(false);
422  // H3 filter check
423  if(H3_filter_ && (h3_attempts <= inner_cycles_)) {
424  h3_attempts++;
425  relaxed_H3_found_current = CDR_H3_cter_filter( pose,ab_info_);
426 
427  if( !relaxed_H3_found_ever && !relaxed_H3_found_current) {
428  mc_->boltzmann( pose );
429  }
430  else if( !relaxed_H3_found_ever && relaxed_H3_found_current ) {
431  relaxed_H3_found_ever = true;
432  mc_->reset( pose );
433  }
434  else if( relaxed_H3_found_ever && !relaxed_H3_found_current ) {
435  --j;
436  continue;
437  }
438  else if( relaxed_H3_found_ever && relaxed_H3_found_current ){
439  mc_->boltzmann( pose );
440  }
441  }
442  else {
443  if( H3_filter_ ) {
444  bool relaxed_H3_found_current(false);
445  relaxed_H3_found_current = CDR_H3_cter_filter( pose,ab_info_);
446  if( !relaxed_H3_found_ever && !relaxed_H3_found_current) {
447  mc_->boltzmann( pose );
448  }
449  else if( !relaxed_H3_found_ever && relaxed_H3_found_current ) {
450  relaxed_H3_found_ever = true;
451  mc_->reset( pose );
452  }
453  else if( relaxed_H3_found_ever && !relaxed_H3_found_current ) {
454  mc_->recover_low( pose );
455  }
456  else if( relaxed_H3_found_ever && relaxed_H3_found_current ){
457  mc_->boltzmann( pose );
458  }
459  }
460  else{
461  mc_->boltzmann( pose );
462  }
463  }
464 
465  if ( numeric::mod(j,Size(20))==0 || j==inner_cycles_ ) {
466  // repack trial
469  ( *highres_scorefxn_ )( pose );
470  tf_->push_back( new RestrictToInterface( allow_repack_ ) );
471  loop_repack_->task_factory( tf_ );
472  loop_repack_->apply( pose );
473  mc_->boltzmann( pose );
474  }
475 
476 
477  } // inner
478  } // outer
479  mc_->recover_low( pose );
480 
481  // minimize
482  change_FT_to_flankloop_->apply( pose );
483  loop_min_mover_->apply( pose );
484 
485 
486 
487 
488  closed_cutpoints = cutpoints_separation( pose, ab_info_ );
489  ++cycle;
490  } // while( ( cut_separation > 1.9 )
491 
492  TR << "Finished Relaxing CDR H3 Loop" << std::endl;
493 
494  return;
495 
496 }
497 
498 
499 
500 
502  tf_ = new pack::task::TaskFactory(*tf);
503 }
504 
505 
506 
507 
508 
509 
510 
511 
512 
513 
514 
515 
516 } // namespace antibody2
517 } // namespace protocols