Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GraftMover.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 moves/GraftMover.cc
11 /// @brief grafts a cdr onto the template of an antibody framework
12 /// @detailed
13 /// @author Aroop Sircar (aroopsircar@yahoo.com)
14 
15 // Unit headers
17 
18 // Package headers
20 
21 // Rosetta Headers
23 
26 #include <core/id/types.hh>
27 
37 #include <core/pose/Pose.hh>
38 #include <core/scoring/rms_util.hh>
42 #include <basic/Tracer.hh>
43 
47 //#include <protocols/loops/LoopMover.fwd.hh>
58 
59 #include <utility/exit.hh>
60 
62 #include <core/pose/util.hh>
63 #include <utility/vector0.hh>
64 #include <utility/vector1.hh>
65 
66 //Auto Headers
67 #include <core/pose/util.tmpl.hh>
68 static basic::Tracer TR("protocols.antibody.GraftMover");
69 static basic::Tracer TRO("protocols.antibody.GraftOneMover");
70 
71 namespace protocols {
72 namespace antibody {
73 
74 using namespace core;
75 using namespace moves;
76 
77 GraftMover::GraftMover():Mover( "GraftMover" ){
78  set_default();
79 } // GraftMover default constructor
80 
81 // GraftMover default destructor
83 
85  TR << "Setting up default settings" << std::endl;
86  graft_l1_ = false;
87  graft_l2_ = false;
88  graft_l3_ = false;
89  graft_h1_ = false;
90  graft_h2_ = false;
91  graft_h3_ = false;
92  camelid_ = false;
93 } // GraftMover set_default
94 
95 void GraftMover::apply( pose::Pose & pose_in )
96 {
97  TR << "Grafting designated CDRs" << std::endl;
98 
99  antibody::Antibody antibody_in( pose_in, camelid_ );
100  SequenceMoverOP graft_sequence ( new SequenceMover() );
101  Size nres = pose_in.total_residue();
102 
103  // Storing secondary structure
104  utility::vector1<char> secondary_struct_storage;
105  for( Size i = 1; i <= nres; i++ )
106  secondary_struct_storage.push_back( pose_in.secstruct( i ) );
107 
108  if( !camelid_ ) {
109  if ( graft_l1_ ) {
110  GraftOneMoverOP graftone_l1( new GraftOneMover(
111  antibody_in.cdrl_[1][1],antibody_in.cdrl_[1][2],"l1" ));
112  graftone_l1->enable_benchmark_mode( benchmark_ );
113  graft_sequence->add_mover( graftone_l1 );
114  }
115  if ( graft_l2_ ) {
116  GraftOneMoverOP graftone_l2( new GraftOneMover(
117  antibody_in.cdrl_[2][1],antibody_in.cdrl_[2][2],"l2" ));
118  graftone_l2->enable_benchmark_mode( benchmark_ );
119  graft_sequence->add_mover( graftone_l2 );
120  }
121  if ( graft_l3_ ) {
122  GraftOneMoverOP graftone_l3( new GraftOneMover(
123  antibody_in.cdrl_[3][1],antibody_in.cdrl_[3][2],"l3" ));
124  graftone_l3->enable_benchmark_mode( benchmark_ );
125  graft_sequence->add_mover( graftone_l3 );
126  }
127  }
128  if ( graft_h1_ ) {
129  GraftOneMoverOP graftone_h1( new GraftOneMover(
130  antibody_in.cdrh_[1][1],antibody_in.cdrh_[1][2],"h1" ));
131  graftone_h1->enable_benchmark_mode( benchmark_ );
132  graft_sequence->add_mover( graftone_h1 );
133  }
134  if ( graft_h2_ ) {
135  GraftOneMoverOP graftone_h2( new GraftOneMover(
136  antibody_in.cdrh_[2][1],antibody_in.cdrh_[2][2],"h2" ));
137  graftone_h2->enable_benchmark_mode( benchmark_ );
138  graft_sequence->add_mover( graftone_h2 );
139  }
140  if ( graft_h3_ ) {
141  GraftOneMoverOP graftone_h3( new GraftOneMover(
142  antibody_in.cdrh_[3][1],antibody_in.cdrh_[3][2],"h3" ));
143  graftone_h3->enable_benchmark_mode( benchmark_ );
144  graft_sequence->add_mover( graftone_h3 );
145  }
146 
147  graft_sequence->apply(pose_in);
148 
149  if ( !graft_h3_ ) {
150  TR << "Extending CDR H3" << std::endl;
151 
152  Size framework_loop_begin( antibody_in.cdrh_[3][1] - 1 );
153  Size frmrk_loop_end_plus_one( antibody_in.cdrh_[3][2] + 1 );
154  Size cutpoint = framework_loop_begin + 1;
155  loops::Loop cdr_h3( framework_loop_begin, frmrk_loop_end_plus_one,
156  cutpoint, 0, false );
157  simple_one_loop_fold_tree( pose_in, cdr_h3);
158 
159  // silly hack to make extended loops work
160  loops::LoopsOP loop_list = new loops::Loops();
161  loop_list->add_loop( cdr_h3 );
162  /* Commented out by BDW with JX's consent
163  loops::loop_mover::LoopMoverOP my_loop_move = new loops::loop_mover::LoopMover( loop_list );
164  my_loop_move->set_extended_torsions( pose_in, cdr_h3 );
165  */
166  }
167 
168  if( graft_l1_ || graft_l2_ || graft_l3_ ||
169  graft_h1_ || graft_h2_ || graft_h3_ ) {
170  // disallowing bogus sidechains while repacking using include_current
171  utility::vector1<bool> allow_repack( nres, false );
172  for( Size i = 1; i <= nres; i++ ) {
173  if( pose_in.secstruct(i) == 'X' )
174  allow_repack[i] = true;
175  if ( !graft_h2_ && ( i >= antibody_in.cdrh_[2][1] ) &&
176  ( i <= antibody_in.cdrh_[2][2] ) )
177  allow_repack[i] = true;
178  if ( !graft_h3_ && ( i >= antibody_in.cdrh_[3][1] ) &&
179  ( i <= antibody_in.cdrh_[3][2] ) )
180  allow_repack[i] = true;
181  }
182 
183  // Recover secondary structures
184  for( Size i = 1; i <= nres; i++ )
185  pose_in.set_secstruct( i, secondary_struct_storage[ i ] );
186  // saving sidechains for use of include_current
187  pose::Pose saved_sidechains( pose_in );
188 
189  // generating centroids for residues devoid of sidechains
192  to_centroid.apply( pose_in );
193  to_full_atom.apply( pose_in );
194  //recover sidechains from starting structures
196  saved_sidechains );
197  recover_sidechains.apply( pose_in );
198  bool include_current( false );
199  // High resolution scores
200  scoring::ScoreFunctionOP antibody_score(
203  set_packer_default( pose_in, antibody_score, include_current );
204  packer_->apply( pose_in );
205 
206  // Retain coordinates for which full atomic coordinates were
207  // available in the input structure. Even for template residues
208  // which match corresponding target residues, keep the template
209  // sidechians. For the residues which do not have any sidechain
210  // coordinates, grab them from a repacked version of the pose
211  // generated without using include_current
212  for( Size i = 1; i <= nres; i++ ) {
213  conformation::Residue const & original_rsd(
214  saved_sidechains.residue( i ) );
215  conformation::Residue const & packed_rsd(
216  pose_in.residue( i ) );
217  if( !allow_repack[i] ) {
218  for( Size j=1; j <= packed_rsd.natoms(); ++j ) {
219  std::string const & atom_name( packed_rsd.atom_name(j) );
220  if( original_rsd.type().has_atom_name( atom_name ) )
221  pose_in.set_xyz( id::AtomID( packed_rsd.atom_index(
222  atom_name),i), original_rsd.xyz( atom_name ) );
223  }
224  }
225  }
226  include_current = true;
227  set_packer_default( pose_in, antibody_score, include_current );
228  packer_->apply( pose_in );
229 
230  SequenceMoverOP close_grafted_loops ( new SequenceMover() );
231  if( !camelid_ ) {
232  if ( graft_l1_ ) {
233  CloseOneMoverOP closeone_l1( new CloseOneMover(
234  antibody_in.cdrl_[1][1],antibody_in.cdrl_[1][2]) );
235  closeone_l1->enable_benchmark_mode( benchmark_ );
236  close_grafted_loops->add_mover( closeone_l1 );
237  }
238  if ( graft_l2_ ) {
239  CloseOneMoverOP closeone_l2( new CloseOneMover(
240  antibody_in.cdrl_[2][1],antibody_in.cdrl_[2][2]) );
241  closeone_l2->enable_benchmark_mode( benchmark_ );
242  close_grafted_loops->add_mover( closeone_l2 );
243  }
244  if ( graft_l3_ ) {
245  CloseOneMoverOP closeone_l3( new CloseOneMover(
246  antibody_in.cdrl_[3][1],antibody_in.cdrl_[3][2]) );
247  closeone_l3->enable_benchmark_mode( benchmark_ );
248  close_grafted_loops->add_mover( closeone_l3 );
249  }
250  }
251  if ( graft_h1_ ) {
252  CloseOneMoverOP closeone_h1( new CloseOneMover(
253  antibody_in.cdrh_[1][1],antibody_in.cdrh_[1][2]) );
254  closeone_h1->enable_benchmark_mode( benchmark_ );
255  close_grafted_loops->add_mover( closeone_h1 );
256  }
257  if ( graft_h2_ ) {
258  CloseOneMoverOP closeone_h2( new CloseOneMover(
259  antibody_in.cdrh_[2][1],antibody_in.cdrh_[2][2]) );
260  closeone_h2->enable_benchmark_mode( benchmark_ );
261  close_grafted_loops->add_mover( closeone_h2 );
262  }
263  if ( graft_h3_ ) {
264  CloseOneMoverOP closeone_h3( new CloseOneMover(
265  antibody_in.cdrh_[3][1],antibody_in.cdrh_[3][2]) );
266  closeone_h3->enable_benchmark_mode( benchmark_ );
267  close_grafted_loops->add_mover( closeone_h3 );
268  }
269  close_grafted_loops->apply(pose_in);
270 
271  for( Size i = 1; i <= nres; i++ )
272  if( pose_in.secstruct(i) == 'Y' )
273  allow_repack[i] = true;
274 
275  to_centroid.apply( pose_in );
276  to_full_atom.apply( pose_in );
277  recover_sidechains.apply( pose_in );
278  set_packer_default( pose_in, antibody_score, include_current );
279  packer_->apply( pose_in );
280 
281  // Retain coordinates for which full atomic coordinates were
282  // available in the input structure. Even for template residues
283  // which match corresponding target residues, keep the template
284  // sidechians. For the residues which do not have any sidechain
285  // coordinates, grab them from a repacked version of the pose
286  // generated without using include_current
287  for( Size i = 1; i <= nres; i++ ) {
288  conformation::Residue const & original_rsd(
289  saved_sidechains.residue( i ) );
290  conformation::Residue const & packed_rsd(
291  pose_in.residue( i ) );
292  if( !allow_repack[i] ) {
293  for( Size j=1; j <= packed_rsd.natoms(); ++j ) {
294  std::string const & atom_name( packed_rsd.atom_name(j) );
295  if( original_rsd.type().has_atom_name( atom_name ) )
296  pose_in.set_xyz( id::AtomID( packed_rsd.atom_index(
297  atom_name),i), original_rsd.xyz( atom_name ) );
298  }
299  }
300  }
301  include_current = true;
302  set_packer_default( pose_in, antibody_score, include_current );
303  packer_->apply( pose_in ); // packing to account for loop closure
304 
305  for( Size i = 1; i <= nres; i++ )
306  allow_repack[i] = true;
307  include_current = true;
308  set_packer_default( pose_in, antibody_score, include_current );
309  packer_->apply( pose_in ); // packing all to relieve clashes
310 
311  // relax optimized CDR grafted regions
312  relax_optimized_CDR_grafts( pose_in );
313 
314 
315  // Recover secondary structures
316  for( Size i = 1; i <= nres; i++ )
317  pose_in.set_secstruct( i, secondary_struct_storage[ i ] );
318 
319  }
320 
321  // align Fv to native.Fv
322  pose::Pose native_pose;
323  if( get_native_pose() )
324  native_pose = *get_native_pose();
325  else
326  native_pose = pose_in;
327  antibody::Antibody native_ab( native_pose, camelid_ );
328  antibody::Antibody antibody_out( pose_in, camelid_ );
329 
330  antibody_out.align_to_native( native_ab );
331  pose_in = antibody_out.Fv;
332 } // GraftMover::apply()
333 
336 return "GraftMover";
337 }
338 
340  pose::Pose & pose_in,
341  scoring::ScoreFunctionOP scorefxn,
342  bool include_current) {
343 
344  //set up packer
346  task = pack::task::TaskFactory::create_packer_task( pose_in );
347  task->restrict_to_repacking();
348  task->or_include_current( include_current );
350 
351 } // GraftMover set_packer_default
352 
354  Size query_start,
355  Size query_end,
356  std::string template_name ) : Mover( "GraftOneMover" ){
357  query_start_ = query_start;
358  query_end_ = query_end;
359  template_name_ = template_name;
360  set_default();
361 } // GraftOneMover default constructor
362 
364  TRO << "Reading in template: " << template_name_ << ".pdb "
365  << std::endl;
368  template_start_ = antibody.current_start;
369  template_end_ = antibody.current_end;
370 } // GraftOneMover::set_default
371 
374 return "GraftOneMover";
375 }
376 void GraftOneMover::apply( pose::Pose & pose_in ) {
377  Size const nres( pose_in.total_residue() ); // Total residues
378  Size query_size = ( query_end_ - query_start_ ) + 1;
379 
380  pose::Pose truncated_pose;
381  truncated_pose = pose_in;
382 
383  // create a sub pose with 5 flanking residues on either side of CDR loop
384  truncated_pose.conformation().delete_residue_range_slow(
385  query_end_ + 5, nres);
386  truncated_pose.conformation().delete_residue_range_slow(
387  1, query_start_ - 5);
388  truncated_pose.conformation().delete_residue_range_slow(
389  5, ( query_size - 1 ) + 5 );
390 
391  // create atom map for superimposing 2 flanking resiudes
395 
396  Size flank = 2; // default 2
397  for( Size start_stem = 4 - (flank-1); start_stem <= 4; start_stem++ ) {
398  for( Size j=1; j <= 4; j++ ) {
399  id::AtomID const id1( j, start_stem );
400  id::AtomID const id2( j, start_stem );
401  atom_map[ id1 ] = id2;
402  }
403  }
404  for( Size end_stem = 4 + query_size + 1; end_stem <= 4+query_size+flank;
405  end_stem++ ) {
406  for( Size j=1; j <= 4; j++ ) {
407  id::AtomID const id1( j, end_stem );
408  id::AtomID const id2( j, end_stem - query_size );
409  atom_map[ id1 ] = id2;
410  }
411  }
412  scoring::superimpose_pose( template_pose_, truncated_pose,
413  atom_map );
414 
415 
416  // copy coordinates of properly oriented template to framework
417  for( Size i = query_start_; i <= query_end_; ++i ) {
418  conformation::Residue const & orientable_rsd(pose_in.residue(i));
419  conformation::Residue const & template_rsd( template_pose_.
420  residue( i - (query_start_ - 5) ) );
421  // keeping track of missing rotamers
422  if( template_rsd.name() != orientable_rsd.name() )
423  pose_in.set_secstruct( i, 'X' );
424  for( Size j=1; j <= template_rsd.natoms(); ++j ) {
425  std::string const & atom_name( template_rsd.atom_name(j) );
426  if( orientable_rsd.type().has_atom_name( atom_name ) )
427  pose_in.set_xyz( id::AtomID( orientable_rsd.atom_index(
428  atom_name),i), template_rsd.xyz(
429  atom_name ) );
430  // hack for generating coordinates of amide hydrogen for target
431  // residues whose template was a Proline residue (Proline residues
432  // do not have the amide hydrogen found ubiquitously in all other
433  // amino acids)
434  if( template_rsd.name() == "PRO" && orientable_rsd.name() != "PRO"
435  && atom_name == " CD " ){
436  id::AtomID_Mask missing( false );
437  // dimension the missing-atom mask
438  core::pose::initialize_atomid_map( missing, pose_in );
439  missing[ id::AtomID(
440  pose_in.residue_type(i).atom_index("H"), i ) ] = true;
441  pose_in.conformation().fill_missing_atoms( missing );
442  }
443  }
444  }
445 } // GraftOneMover::apply
446 
448  Size loop_begin(0), loop_end(0);
449  bool detect_flag( false );
450  for( Size ii = 1; ii <= pose_in.total_residue(); ii++ ) {
451  if( (pose_in.secstruct(ii) == 'Y') && !detect_flag ) {
452  loop_begin = ii;
453  detect_flag = true;
454  }
455  if( (pose_in.secstruct(ii) != 'Y') && detect_flag ) {
456  loop_end = ii - 1;
457  detect_flag = false;
458  }
459  if((detect_flag == false) && (loop_begin != 0) && (loop_end != 0 )) {
460  LoopRlxMoverOP rlx_one_loop(new LoopRlxMover( loop_begin, loop_end));
461  rlx_one_loop->enable_benchmark_mode( benchmark_ );
462  rlx_one_loop->apply( pose_in );
463  loop_begin = 0;
464  loop_end = 0;
465  }
466  } // for ii <= nres
467 } // GraftMover::relax_optimized_CDR_grafts
468 
469 
471  Size query_start,
472  Size query_end
473 )
474  : Mover( "CloseOneMover" )
475 {
476  loop_start_ = query_start;
477  loop_end_ = query_end;
478  set_default();
479 } // CloseOneMover default constructor
480 
482  allowed_separation_ = 1.9;
483  flanking_residues_ = 5; // default 5;
484 } // CloseOneMover::set_default
485 
486 void CloseOneMover::apply( pose::Pose & pose_in ) {
487 
488  Size const N ( 1 ); // N atom
489  Size const C ( 3 ); // C atom
490 
491  // Coordinates of the C and N atoms at stem
492  numeric::xyzVector_float peptide_C, peptide_N;
493  // N-terminal
494  peptide_C = pose_in.residue( loop_start_ - 1 ).xyz( C );
495  peptide_N = pose_in.residue( loop_start_ ).xyz( N );
496  Real nter_separation=peptide_C.distance(peptide_N);
497  // C-terminal
498  peptide_C = pose_in.residue( loop_end_ ).xyz( C );
499  peptide_N = pose_in.residue( loop_end_ + 1 ).xyz( N );
500  Real cter_separation=peptide_C.distance(peptide_N);
501 
502  // switching to centroid mode
505 
506  bool repack_flag( false );
507  if( ( nter_separation > allowed_separation_ ) ||
508  ( cter_separation > allowed_separation_ ) ) {
509  to_centroid.apply( pose_in );
510  repack_flag = true;
511  }
512 
513  // saving sidechains for use of include_current
514  pose::Pose saved_sc( pose_in );
515  //recover sidechains from starting structures
516  protocols::simple_moves::ReturnSidechainMover recover_sidechains( saved_sc );
517 
518  bool nter( false );
519  if( nter_separation > allowed_separation_ ) {
520  nter = true;
521  close_one_loop_stem( pose_in, loop_start_, nter );
522  }
523 
524  if( cter_separation > allowed_separation_ ) {
525  nter = false;
526  close_one_loop_stem( pose_in, loop_end_, nter );
527  }
528 
529  Real separation = 0.00;
530  for( Size ii = loop_start_; ii <= loop_end_; ii++ ) {
531  peptide_C = pose_in.residue( ii ).xyz( C );
532  peptide_N = pose_in.residue( ii + 1 ).xyz( N );
533  separation=peptide_C.distance(peptide_N);
534  if( separation > allowed_separation_ ) {
535  repack_flag = true;
536  Size cutpoint = ii;
537  close_one_loop_stem( pose_in, loop_start_, loop_end_, cutpoint );
538  }
539  } // for
540 
541  if( repack_flag ) {
542  to_full_atom.apply( pose_in );
543  recover_sidechains.apply( pose_in );
544  }
545 
546  return;
547 } // CloseOneMover::apply
548 
551 return "CloseOneMover";
552 }
553 
555  pose::Pose & pose_in,
556  Size cutpoint_in,
557  bool nter
558 ) {
559  using namespace protocols;
560  using namespace protocols::loops;
561 
564 
565 
566  // storing starting fold tree
567  kinematics::FoldTree tree_in( pose_in.fold_tree() );
568 
569  Size loop_flex_begin, loop_flex_end;
570  if( nter ) {
571  loop_flex_begin = cutpoint_in;
572  loop_flex_end = cutpoint_in + ( flanking_residues_ - 1 );
573  }
574  else {
575  loop_flex_begin = cutpoint_in - ( flanking_residues_ - 1 );
576  loop_flex_end = cutpoint_in;
577  }
578 
579  //setting MoveMap
580  kinematics::MoveMapOP loop_map;
581  loop_map = new kinematics::MoveMap();
582  loop_map->clear();
583  loop_map->set_chi( false );
584  loop_map->set_bb( false );
585  utility::vector1< bool> allow_bb_move( pose_in.total_residue(), false );
586  for( Size ii = loop_flex_begin; ii <= loop_flex_end; ii++ ) {
587  allow_bb_move[ ii ] = true;
588  pose_in.set_secstruct( ii, 'Y' );
589  }
590  loop_map->set_bb( allow_bb_move );
591  loop_map->set_jump( 1, false );
592 
593  Size loop_begin, loop_end, cutpoint;
594  if( nter ) {
595  loop_begin = loop_flex_begin - 2;
596  loop_end = loop_flex_end;
597  cutpoint = loop_flex_begin - 1;
598  }
599  else {
600  loop_begin = loop_flex_begin;
601  loop_end = loop_flex_end + 2;
602  cutpoint = loop_flex_end;
603  }
604 
605  loops::Loop one_loop( loop_begin, loop_end, cutpoint, 0, false );
606  simple_one_loop_fold_tree( pose_in, one_loop );
607 
608  // set cutpoint variants for correct chainbreak scoring
609  if( !pose_in.residue( cutpoint ).is_upper_terminus() ) {
610  if( !pose_in.residue( cutpoint ).has_variant_type(
614  cutpoint );
615  if( !pose_in.residue( cutpoint + 1 ).has_variant_type(
619  cutpoint + 1 );
620  }
621 
622  scoring::ScoreFunctionOP lowres_scorefxn;
623  lowres_scorefxn = scoring::ScoreFunctionFactory::
624  create_score_function( "cen_std", "score4L" );
625  lowres_scorefxn->set_weight( scoring::chainbreak, 10. / 3. );
626 
627  Real min_tolerance = 0.001;
628  if( benchmark_ ) min_tolerance = 1.0;
629  std::string min_type = std::string( "dfpmin_armijo_nonmonotone" );
630  bool nb_list = true;
632  lowres_scorefxn, min_type, min_tolerance, nb_list );
633 
634  // more params
635  Size loop_size = ( loop_end - loop_begin ) + 1;
636  Size n_small_moves ( numeric::max(Size(5), Size(loop_size/2)) );
637  Size inner_cycles( loop_size );
638  Size outer_cycles( 2 );
639  if( benchmark_ ) {
640  n_small_moves = 1;
641  inner_cycles = 1;
642  outer_cycles = 1;
643  }
644 
645  Real high_move_temp = 2.00;
646  // minimize amplitude of moves if correct parameter is set
648  high_move_temp,
649  n_small_moves );
651  high_move_temp,
652  n_small_moves );
653  small_mover->angle_max( 'H', 2.0 );
654  small_mover->angle_max( 'E', 5.0 );
655  small_mover->angle_max( 'L', 6.0 );
656  shear_mover->angle_max( 'H', 2.0 );
657  shear_mover->angle_max( 'E', 5.0 );
658  shear_mover->angle_max( 'L', 6.0 );
659 
660 
661 
662  CcdMoverOP ccd_moves = new CcdMover(one_loop,loop_map);
663  RepeatMoverOP ccd_cycle = new RepeatMover(ccd_moves, n_small_moves);
664 
665  SequenceMoverOP wiggle_cdr( new SequenceMover() );
666  wiggle_cdr->add_mover( small_mover );
667  wiggle_cdr->add_mover( shear_mover );
668  wiggle_cdr->add_mover( ccd_cycle );
669 
670 
671  loop_min_mover->apply( pose_in );
672 
673  Real const init_temp( 2.0 );
674  Real const last_temp( 0.5 );
675  Real const gamma = std::pow( (last_temp/init_temp), (1.0/inner_cycles));
676  Real temperature = init_temp;
677 
678  MonteCarloOP mc;
679  mc = new moves::MonteCarlo( pose_in, *lowres_scorefxn, temperature );
680  mc->reset( pose_in ); // monte carlo reset
681 
682  // outer cycle
683  for(Size i = 1; i <= outer_cycles; i++) {
684  mc->recover_low( pose_in );
685 
686  // inner cycle
687  for ( Size j = 1; j <= inner_cycles; j++ ) {
688  temperature *= gamma;
689  mc->set_temperature( temperature );
690  wiggle_cdr->apply( pose_in );
691  loop_min_mover->apply( pose_in );
692 
693  mc->boltzmann( pose_in );
694 
695  } // inner cycles
696  } // outer cycles
697  mc->recover_low( pose_in );
698 
699  // minimize
700  if( !benchmark_ )
701  loop_min_mover->apply( pose_in );
702 
703  // Restoring pose stuff
704  pose_in.fold_tree( tree_in ); // Tree
705 
706  return;
707 } // CloseOneMover::close_one_loop_stem
708 
710  pose::Pose & pose_in,
711  Size loop_begin,
712  Size loop_end,
713  Size cutpoint
714 )
715 {
716  using namespace protocols;
717  using namespace protocols::loops;
718 
721 
722 
723  // storing starting fold tree
724  kinematics::FoldTree tree_in( pose_in.fold_tree() );
725 
726  //setting MoveMap
727  kinematics::MoveMapOP loop_map;
728  loop_map = new kinematics::MoveMap();
729  loop_map->clear();
730  loop_map->set_chi( false );
731  loop_map->set_bb( false );
732  utility::vector1< bool> allow_bb_move( pose_in.total_residue(), false );
733  for( Size ii = loop_begin; ii <= loop_end; ii++ ) {
734  allow_bb_move[ ii ] = true;
735  pose_in.set_secstruct( ii, 'Y' );
736  }
737  loop_map->set_bb( allow_bb_move );
738  loop_map->set_jump( 1, false );
739 
740  loops::Loop one_loop( loop_begin, loop_end, cutpoint, 0, false );
741  simple_one_loop_fold_tree( pose_in, one_loop );
742 
743  // set cutpoint variants for correct chainbreak scoring
744  if( !pose_in.residue( cutpoint ).is_upper_terminus() ) {
745  if( !pose_in.residue( cutpoint ).has_variant_type(
749  cutpoint );
750  if( !pose_in.residue( cutpoint + 1 ).has_variant_type(
754  cutpoint + 1 );
755  }
756 
757  scoring::ScoreFunctionOP lowres_scorefxn;
758  lowres_scorefxn = scoring::ScoreFunctionFactory::
759  create_score_function( "cen_std", "score4L" );
760  lowres_scorefxn->set_weight( scoring::chainbreak, 10. / 3. );
761 
762  Real min_tolerance = 0.001;
763  if( benchmark_ ) min_tolerance = 1.0;
764  std::string min_type = std::string( "dfpmin_armijo_nonmonotone" );
765  bool nb_list = true;
767  lowres_scorefxn, min_type, min_tolerance, nb_list );
768 
769  // more params
770  Size loop_size = ( loop_end - loop_begin ) + 1;
771  Size n_small_moves ( numeric::max(Size(5), Size(loop_size/2)) );
772  Size inner_cycles( loop_size );
773  Size outer_cycles( 2 );
774  if( benchmark_ ) {
775  n_small_moves = 1;
776  inner_cycles = 1;
777  outer_cycles = 1;
778  }
779 
780  Real high_move_temp = 2.00;
781  // minimize amplitude of moves if correct parameter is set
783  high_move_temp,
784  n_small_moves );
786  high_move_temp,
787  n_small_moves );
788  small_mover->angle_max( 'H', 2.0 );
789  small_mover->angle_max( 'E', 5.0 );
790  small_mover->angle_max( 'L', 6.0 );
791  shear_mover->angle_max( 'H', 2.0 );
792  shear_mover->angle_max( 'E', 5.0 );
793  shear_mover->angle_max( 'L', 6.0 );
794 
795 
796 
797  CcdMoverOP ccd_moves = new CcdMover(one_loop,loop_map);
798  RepeatMoverOP ccd_cycle = new RepeatMover(ccd_moves, n_small_moves);
799 
800  SequenceMoverOP wiggle_cdr( new SequenceMover() );
801  wiggle_cdr->add_mover( small_mover );
802  wiggle_cdr->add_mover( shear_mover );
803  wiggle_cdr->add_mover( ccd_cycle );
804 
805 
806  loop_min_mover->apply( pose_in );
807 
808  Real const init_temp( 2.0 );
809  Real const last_temp( 0.5 );
810  Real const gamma = std::pow( (last_temp/init_temp), (1.0/inner_cycles));
811  Real temperature = init_temp;
812 
813  MonteCarloOP mc;
814  mc = new moves::MonteCarlo( pose_in, *lowres_scorefxn, temperature );
815  mc->reset( pose_in ); // monte carlo reset
816 
817  // outer cycle
818  for(Size i = 1; i <= outer_cycles; i++) {
819  mc->recover_low( pose_in );
820 
821  // inner cycle
822  for ( Size j = 1; j <= inner_cycles; j++ ) {
823  temperature *= gamma;
824  mc->set_temperature( temperature );
825  wiggle_cdr->apply( pose_in );
826  loop_min_mover->apply( pose_in );
827 
828  mc->boltzmann( pose_in );
829 
830  } // inner cycles
831  } // outer cycles
832  mc->recover_low( pose_in );
833 
834  // minimize
835  if( !benchmark_ )
836  loop_min_mover->apply( pose_in );
837 
838  // Restoring pose stuff
839  pose_in.fold_tree( tree_in ); // Tree
840 
841  return;
842 } // CloseOneMover::close_one_loop_stem
843 
845  Size query_start,
846  Size query_end
847 ) : Mover( "LoopRlxMover" )
848 {
849  loop_start_ = query_start;
850  loop_end_ = query_end;
851  set_default();
852 } // LoopRlxMover default constructor
853 
856  create_score_function( "standard", "score12" );
857  highres_scorefxn_->set_weight( scoring::chainbreak, 1.0 );
858  highres_scorefxn_->set_weight( scoring::overlap_chainbreak, 10./3. );
859  return;
860 } // LoopRlxMover::set_default
861 
862 
863 ///////////////////////////////////////////////////////////////////////////
864 /// @begin LoopRlxMover::apply
865 ///
866 /// @brief relaxes the region specified
867 ///
868 /// @detailed This is all done in high resolution.Hence there are no rigid
869 /// body moves relative to the docking partners. Only small moves
870 /// are carried out here to see if there are better fits.
871 /// Repacking is carried out extensively after each move.
872 ///
873 /// @param[in] pose, loop begin position, loop end position
874 ///
875 /// @global_read none
876 ///
877 /// @global_write none
878 ///
879 /// @remarks
880 ///
881 /// @references
882 ///
883 /// @authors Aroop 05/12/2010
884 ///
885 /// @last_modified 05/12/2010
886 ///////////////////////////////////////////////////////////////////////////
887 void LoopRlxMover::apply( pose::Pose & pose_in ) {
888  using namespace protocols;
889  using namespace protocols::loops;
890  using namespace protocols::moves;
891  using namespace pack;
892  using namespace pack::task;
893  using namespace pack::task::operation;
894 
897 
898  TR << "LoopRlxMover: Apply" << std::endl;
899 
900  // storing starting fold tree
901  kinematics::FoldTree tree_in( pose_in.fold_tree() );
902 
903  //setting MoveMap
904  kinematics::MoveMapOP loop_map;
905  loop_map = new kinematics::MoveMap();
906  loop_map->clear();
907  loop_map->set_chi( false );
908  loop_map->set_bb( false );
909  utility::vector1< bool> allow_bb_move( pose_in.total_residue(), false );
910  for( Size ii = loop_start_; ii <= loop_end_; ii++ )
911  allow_bb_move[ ii ] = true;
912  loop_map->set_bb( allow_bb_move );
913  loop_map->set_jump( 1, false );
914 
915 
916  Size loop_size = ( loop_end_ - loop_start_ ) + 1;
917  Size cutpoint = loop_start_ + int(loop_size/2);
918 
919  loops::Loop one_loop( loop_start_, loop_end_, cutpoint, 0, false );
920  simple_one_loop_fold_tree( pose_in, one_loop );
921 
922  if ( !pose_in.is_fullatom() )
923  utility_exit_with_message("Fullatom poses only");
924 
925  // set cutpoint variants for correct chainbreak scoring
926  if( !pose_in.residue( cutpoint ).is_upper_terminus() ) {
927  if( !pose_in.residue( cutpoint ).has_variant_type(
931  cutpoint );
932  if( !pose_in.residue( cutpoint + 1 ).has_variant_type(
936  cutpoint + 1 );
937  }
938 
939  utility::vector1< bool> allow_repack( pose_in.total_residue(), false );
940  select_loop_residues( pose_in, one_loop, true /*include_neighbors*/,
941  allow_repack);
942  loop_map->set_chi( allow_repack );
943 
945  setup_packer_task( pose_in );
946  ( *highres_scorefxn_ )( pose_in );
947  tf_->push_back( new protocols::toolbox::task_operations::RestrictToInterface( allow_repack ) );
948  loop_repack->task_factory(tf_);
949  loop_repack->apply( pose_in );
950 
951  Real min_tolerance = 0.001;
952  if( benchmark_ ) min_tolerance = 1.0;
953  std::string min_type = std::string( "dfpmin_armijo_nonmonotone" );
954  bool nb_list = true;
956  highres_scorefxn_, min_type, min_tolerance, nb_list );
957 
958  // more params
959  Size n_small_moves ( numeric::max(Size(5), Size(loop_size/2)) );
960  Size inner_cycles( loop_size );
961  Size outer_cycles( 2 );
962  if( benchmark_ ) {
963  n_small_moves = 1;
964  inner_cycles = 1;
965  outer_cycles = 1;
966  }
967 
968  Real high_move_temp = 2.00;
969  // minimize amplitude of moves if correct parameter is set
971  high_move_temp,
972  n_small_moves );
974  high_move_temp,
975  n_small_moves );
976  small_mover->angle_max( 'H', 2.0 );
977  small_mover->angle_max( 'E', 5.0 );
978  small_mover->angle_max( 'L', 6.0 );
979  shear_mover->angle_max( 'H', 2.0 );
980  shear_mover->angle_max( 'E', 5.0 );
981  shear_mover->angle_max( 'L', 6.0 );
982 
983  CcdMoverOP ccd_moves = new CcdMover( one_loop, loop_map );
984  RepeatMoverOP ccd_cycle = new RepeatMover(ccd_moves, n_small_moves);
985 
986  SequenceMoverOP wiggle_loop( new SequenceMover() );
987  wiggle_loop->add_mover( small_mover );
988  wiggle_loop->add_mover( shear_mover );
989  wiggle_loop->add_mover( ccd_cycle );
990 
991  // rotamer trials
992  select_loop_residues( pose_in, one_loop, true /*include_neighbors*/,
993  allow_repack);
994  loop_map->set_chi( allow_repack );
995  setup_packer_task( pose_in );
996  ( *highres_scorefxn_ )( pose_in );
997  tf_->push_back( new protocols::toolbox::task_operations::RestrictToInterface( allow_repack ) );
1000 
1001  pack_rottrial->apply( pose_in );
1002 
1003 
1004  Real const init_temp( 2.0 );
1005  Real const last_temp( 0.5 );
1006  Real const gamma = std::pow( (last_temp/init_temp), (1.0/inner_cycles));
1007  Real temperature = init_temp;
1008 
1009  MonteCarloOP mc;
1010  mc = new moves::MonteCarlo( pose_in, *highres_scorefxn_, temperature );
1011  mc->reset( pose_in ); // monte carlo reset
1012 
1013  // outer cycle
1014  for(Size i = 1; i <= outer_cycles; i++) {
1015  mc->recover_low( pose_in );
1016 
1017  // inner cycle
1018  for ( Size j = 1; j <= inner_cycles; j++ ) {
1019  temperature *= gamma;
1020  mc->set_temperature( temperature );
1021  wiggle_loop->apply( pose_in );
1022  loop_min_mover->apply( pose_in );
1023 
1024  // rotamer trials
1025  select_loop_residues( pose_in, one_loop, true /*include_neighbors*/,
1026  allow_repack);
1027  loop_map->set_chi( allow_repack );
1028  setup_packer_task( pose_in );
1029  ( *highres_scorefxn_ )( pose_in );
1030  tf_->push_back( new protocols::toolbox::task_operations::RestrictToInterface( allow_repack ) );
1033  pack_rottrial->apply( pose_in );
1034 
1035  mc->boltzmann( pose_in );
1036 
1037 
1038  if ( numeric::mod(j,Size(20))==0 || j==inner_cycles ) {
1039  // repack trial
1041  setup_packer_task( pose_in );
1042  ( *highres_scorefxn_ )( pose_in );
1043  tf_->push_back( new protocols::toolbox::task_operations::RestrictToInterface( allow_repack ) );
1044  loop_repack->task_factory( tf_ );
1045  loop_repack->apply( pose_in );
1046  mc->boltzmann( pose_in );
1047  }
1048  } // inner cycles
1049  } // outer cycles
1050  mc->recover_low( pose_in );
1051 
1052  // minimize
1053  if( !benchmark_ )
1054  loop_min_mover->apply( pose_in );
1055 
1056  // Restoring pose stuff
1057  pose_in.fold_tree( tree_in ); // Tree
1058 
1059  TR << "LoopRlxMover: Finished Apply" << std::endl;
1060 
1061  return;
1062 } // LoopRlxMover::apply
1063 
1066  return "LoopRlxMover";
1067 }
1068 
1069 void
1071  pose::Pose & pose_in
1072 ) {
1073  using namespace pack::task;
1074  using namespace pack::task::operation;
1075 
1076  if( init_task_factory_ ) {
1077  tf_ = new TaskFactory( *init_task_factory_ );
1078  TR << "LoopRlxMover Reinitializing Packer Task" << std::endl;
1079  return;
1080  }
1081  else
1082  tf_ = new TaskFactory;
1083 
1084  TR << "LoopRlxMover Setting Up Packer Task" << std::endl;
1085 
1086  tf_->push_back( new OperateOnCertainResidues( new PreventRepackingRLT,
1087  new ResidueLacksProperty("PROTEIN") ) );
1088  tf_->push_back( new InitializeFromCommandline );
1089  tf_->push_back( new IncludeCurrent );
1090  tf_->push_back( new RestrictToRepacking );
1091  tf_->push_back( new NoRepackDisulfides );
1092 
1093  // incorporating Ian's UnboundRotamer operation.
1094  // note that nothing happens if unboundrot option is inactive!
1097  unboundrot->initialize_from_command_line();
1098  operation::AppendRotamerSetOP unboundrot_operation =
1099  new operation::AppendRotamerSet( unboundrot );
1100  tf_->push_back( unboundrot_operation );
1101  // adds scoring bonuses for the "unbound" rotamers, if any
1103 
1105 
1106  TR << "LoopRlxMover Done: Setting Up Packer Task" << std::endl;
1107 
1108 } // LoopRlxMover::setup_packer_task
1109 
1110 
1111 
1112 } // namespace moves
1113 } // namespace protocols