Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CDRH3Modeler.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/antibody/CDRH3Modeler.cc
12 /// @brief models CDR H3 loop using loop modeling
13 /// @detailed
14 /// @author Aroop Sircar (aroopsircar@yahoo.com)
15 
16 // Unit headers
18 
19 // Rosetta Headers
21 
25 #include <core/fragment/FragSet.hh>
26 #include <core/id/types.hh>
36 
38 #include <core/pose/Pose.hh>
39 #include <core/pose/PDBInfo.hh>
40 #include <core/pose/util.hh>
44 #include <basic/Tracer.hh>
45 
46 #include <numeric/numeric.functions.hh>
47 #include <numeric/random/random.hh>
48 #include <numeric/xyz.functions.hh>
49 
53 #include <protocols/loops/Loop.hh>
54 #include <protocols/loops/Loops.hh>
55 //#include <protocols/loops/LoopMover.fwd.hh>
67 
68 #include <utility/exit.hh>
69 #include <utility/io/izstream.hh>
70 #include <utility/pointer/owning_ptr.hh>
71 
73 #include <utility/vector0.hh>
74 #include <utility/vector1.hh>
75 
76 static numeric::random::RandomGenerator RG(11141980);
77 
78 static basic::Tracer TR("protocols.antibody.CDRH3Modeler");
79 
80 namespace protocols {
81 namespace antibody {
82 
83 using namespace core;
84 using namespace protocols::moves;
85 
88 ) : moves::Mover( "CDRH3Modeler" )
89 {
90  cdr_h3_frags_ = cdr_h3_frags;
91  set_default();
92 } // CDRH3Modeler default constructor
93 
94 // CDRH3Modeler default destructor
96 
98  benchmark_ = false;
99  do_h3_modeling_ = false;
100  base_ = 1;
101  c_ter_stem_ = 3;
102  cen_cst_ = 10.0;
103  high_cst_ = 100.0; // if changed here, please change at the end of
104  // AntibodyModeler as well
105 
107  create_score_function( "cen_std", "score4L" );
108  lowres_scorefxn_->set_weight( scoring::chainbreak, 10./3. );
109  // adding constraints
111 
113  create_score_function("standard", "score12" );
114  highres_scorefxn_->set_weight( scoring::chainbreak, 1.0 );
115  highres_scorefxn_->set_weight( scoring::overlap_chainbreak, 10./3. );
116  // adding constraints
118 
119  apply_centroid_mode_ = false;
120  apply_fullatom_mode_ = false;
121 
122  current_loop_is_H3_ = true;
123  H3_filter_ = true;
124  antibody_build_ = true;
125  antibody_refine_ = true;
126  min_base_relax_ = false;
127  h3_random_cut_ = false;
129  snug_fit_ = true;
130  loops_flag_ = true;
131  docking_local_refine_ = true;
132  dle_flag_ = true;
133  refine_input_loop_ = true;
134  h3_flank_ = 2;
135  flank_relax_ = true;
136  freeze_h3_ = true;
137  is_camelid_ = false;
138  base_ = 1;
139  // size of loop above which 9mer frags are used
140  cutoff_9_ = 16; // default 16
141  // size of loop above which 3mer frags are used
142  cutoff_3_ = 6; // default 6
143 
144  TR << "H3M Finished Setting Defaults" << std::endl;
145 
146  return;
147 } // CDRH3Modeler set_default
148 
150  scoring::ScoreFunctionOP lowres_scorefxn
151 )
152 {
153  lowres_scorefxn_ = lowres_scorefxn;
154 } // set_lowres_score_func
155 
157  scoring::ScoreFunctionOP highres_scorefxn
158 )
159 {
160  highres_scorefxn_ = highres_scorefxn;
161 } // set_highres_score_func
162 
164 {
165  if( !do_h3_modeling_ )
166  return;
167 
168  TR << "H3M Applying CDR H3 modeler" << std::endl;
169 
170  using namespace core::pose;
171  using namespace core::scoring;
172  using namespace protocols::moves;
173 
174  start_pose_ = pose_in;
175  antibody_in_.set_Fv( pose_in, is_camelid_ );
176  setup_packer_task( pose_in );
177  pose::Pose start_pose = pose_in;
178 
180  c_ter_stem_ = 0;
181 
182  Size framework_loop_begin( antibody_in_.cdrh_[3][1] );
183  Size frmrk_loop_end_plus_one( antibody_in_.cdrh_[3][2] + 1 );
184  //Size framework_loop_size = ( frmrk_loop_end_plus_one -
185  // framework_loop_begin ) + 1;
186  Size cutpoint = framework_loop_begin + 1;
187  loops::Loop cdr_h3( framework_loop_begin, frmrk_loop_end_plus_one,
188  cutpoint, 0, true );
190 
191  // switching to centroid mode
194 
195  // Building centroid mode loop
196  if( apply_centroid_mode_ ) {
197  to_centroid.apply( antibody_in_.Fv );
199  if( is_camelid_ )
201  antibody_in_.cdrh_[1][2] );
202  to_full_atom.apply( antibody_in_.Fv );
203 
205  true );
206  for( Size ii = antibody_in_.cdrh_[3][1];
207  ii <= ( antibody_in_.cdrh_[3][2] + 1 ); ii++ )
208  allow_chi_copy[ii] = false;
209  //recover sidechains from starting structures
211  start_pose_, allow_chi_copy );
212  recover_sidechains.apply( antibody_in_.Fv );
213 
214  // Packer
217  packer->task_factory(tf_);
218  packer->apply( antibody_in_.Fv );
219  }
220 
221  if( apply_fullatom_mode_ ) {
223  if( !benchmark_ ) {
224  Size repack_cycles(1);
225  if( antibody_refine_ && !snug_fit_ )
226  repack_cycles = 3;
229  packer->task_factory(tf_);
230  packer->nloop( repack_cycles );
231  packer->apply( antibody_in_.Fv );
232  }
233  }
234 
235  // Minimize CDR H2 loop if this is a camelid
236  if( is_camelid_ ) {
237  bool store_current_loop = current_loop_is_H3_;
238  bool store_H3_filter = H3_filter_;
239  current_loop_is_H3_ = false;
240  H3_filter_ = false;
241  bool closed_cutpoints( false );
242 
243  antibody::Antibody starting_antibody;
244  starting_antibody = antibody_in_;
245 
246  while( !closed_cutpoints) {
247  antibody_in_ = starting_antibody;
249  antibody_in_.cdrh_[1][2] );
250  closed_cutpoints = cutpoints_separation();
251  } // while( ( cut_separation > 1.9 )
252 
253  // Restoring variables to initial state
254  current_loop_is_H3_ = store_current_loop;
255  H3_filter_ = store_H3_filter;
256  }
257 
258  pose_in = antibody_in_.Fv;
259 
260  TR << "H3M Finished applying CDR H3 modeler" << std::endl;
261 
262  return;
263 } // CDRH3Modeler::apply()
264 
267  return "CDRH3Modeler";
268 }
269 
270 
272  using namespace core::pose;
273  using namespace core::scoring;
274  using namespace protocols::moves;
275 
276  if( !apply_centroid_mode_ )
277  return;
278 
279  TR << "H3M Modeling Centroid CDR H3 loop" << std::endl;
280 
281  Size frmrk_loop_end_plus_one( antibody_in_.cdrh_[3][2] + 1 );
282  Size framework_loop_size = ( frmrk_loop_end_plus_one -
283  antibody_in_.cdrh_[3][1] ) + 1;
284  Size cutpoint = antibody_in_.cdrh_[3][1] + 1;
285  loops::Loop cdr_h3( antibody_in_.cdrh_[3][1], frmrk_loop_end_plus_one,
286  cutpoint, 0, true );
288 
289  // silly hack to make extended loops to work
290  loops::LoopsOP cdr_h3_loop_list = new loops::Loops();
291  cdr_h3_loop_list->add_loop( cdr_h3 );
292  /* Commented out by BDW with JX's consent
293  loops::loop_mover::LoopMoverOP my_loop_move = new loops::loop_mover::LoopMover( cdr_h3_loop_list );
294  my_loop_move->set_extended_torsions( antibody_in_.Fv, cdr_h3 );
295  my_loop_move->apply( antibody_in_.Fv );
296  */
297 
298  Size unaligned_cdr_loop_begin(0)/*, unaligned_cdr_loop_end(0)*/;
300  std::string template_name = "h3";
301  antibody::Antibody hfr_template( template_pose_, template_name );
302  unaligned_cdr_loop_begin = hfr_template.current_start;
303  //unaligned_cdr_loop_end = hfr_template.current_end; // set but never used ~Labonte
304 
306  template_pose_.psi( unaligned_cdr_loop_begin - 1 ) );
308  template_pose_.omega( unaligned_cdr_loop_begin - 1 ) );
309 
310  Size modified_framework_loop_end = frmrk_loop_end_plus_one - c_ter_stem_;
311  loops::Loop trimmed_cdr_h3( antibody_in_.cdrh_[3][1],
312  modified_framework_loop_end, cutpoint, 0, true );
313 
314  antibody::Antibody starting_antibody;
315  starting_antibody = antibody_in_;
316  bool closed_cutpoints( false );
317 
318  while( !closed_cutpoints) {
319  antibody_in_ = starting_antibody;
320  if( framework_loop_size > 5 )
322  scored_frag_close( antibody_in_.Fv, trimmed_cdr_h3 );
323  if( trimmed_cdr_h3.size() > cutoff_9_ ) { // aroop_temp default cutoff_9_
324  Size saved_cutoff_9 = cutoff_9_;
325  cutoff_9_ = 100; // never going to reach
326  scored_frag_close( antibody_in_.Fv, trimmed_cdr_h3 );
327  cutoff_9_ = saved_cutoff_9; // restoring
328  }
329  closed_cutpoints = cutpoints_separation();
330  } // while( ( cut_separation > 1.9 )
331 
332  TR << "H3M Finished Modeling Centroid CDR H3 loop" << std::endl;
333 
334  return;
335 
336 } // build_centroid_loop
337 
339  using namespace core::pose;
340  using namespace core::scoring;
341  using namespace protocols::moves;
342 
343  if( !apply_fullatom_mode_ )
344  return;
345 
346  TR << "H3M Modeling Fullatom CDR H3 loop" << std::endl;
347 
348  antibody::Antibody starting_antibody;
349  starting_antibody = antibody_in_;
350  bool closed_cutpoints( false );
351 
352  while( !closed_cutpoints) {
353  antibody_in_ = starting_antibody;
355  antibody_in_.cdrh_[3][2] + base_ );
356  closed_cutpoints = cutpoints_separation();
357  } // while( ( cut_separation > 1.9 )
358 
359  TR << "H3M Finished modeling Fullatom CDR H3 loop" << std::endl;
360 
361  return;
362 } // build_fullatom_loop
363 
366 ) {
367  H3_base_library = base_library_in;
368  return;
369 } // store_H3_cter_fragment
370 
372  pose::Pose & pose_in,
373  loops::Loop const & loop
374 ) {
375  using namespace kinematics;
376 
377  TR << "H3M Setting up simple one loop fold tree" << std::endl;
378 
379  //setup fold tree for this loop
380  FoldTree f;
381  f.clear();
382  Size nres = pose_in.total_residue();
383  Size jumppoint1 = loop.start() - 1;
384  Size jumppoint2 = loop.stop() + 1;
385 
386  if( jumppoint1 < 1 ) jumppoint1 = 1;
387  if( jumppoint2 > nres) jumppoint2 = nres;
388 
389  f.add_edge( 1, jumppoint1, Edge::PEPTIDE );
390  f.add_edge( jumppoint1, loop.cut(), Edge::PEPTIDE );
391  f.add_edge( loop.cut() + 1, jumppoint2, Edge::PEPTIDE );
392  f.add_edge( jumppoint2, nres, Edge::PEPTIDE );
393  f.add_edge( jumppoint1, jumppoint2, 1 );
394  f.reorder( 1 );
395 
396  pose_in.fold_tree( f );
397 
398  TR << "H3M Finished setting up simple one loop fold tree" << std::endl;
399 
400  return;
401 } // simple_one_loop_fold_tree
402 
404  pose::Pose & pose_in,
405  Size jumppoint1,
406  Size cutpoint,
407  Size jumppoint2
408 ) {
409  using namespace kinematics;
410 
411  TR << "H3M Setting up simple fold tree" << std::endl;
412 
413  //setup fold tree for this loop
414  FoldTree f;
415  f.clear();
416  Size nres = pose_in.total_residue();
417 
418  if( jumppoint1 < 1 ) jumppoint1 = 1;
419  if( jumppoint2 > nres) jumppoint2 = nres;
420 
421  f.add_edge( 1, jumppoint1, Edge::PEPTIDE );
422  f.add_edge( jumppoint1, cutpoint, Edge::PEPTIDE );
423  f.add_edge( cutpoint + 1, jumppoint2, Edge::PEPTIDE );
424  f.add_edge( jumppoint2, nres, Edge::PEPTIDE );
425  f.add_edge( jumppoint1, jumppoint2, 1 );
426  f.reorder( 1 );
427 
428  pose_in.fold_tree( f );
429 
430  TR << "H3M Finished setting up simple fold tree" << std::endl;
431 
432  return;
433 } // simple_fold_tree
434 
436  antibody::Antibody & antibody_in,
438  bool is_camelid
439 ) {
440  using namespace fragment;
441 
442  TR << "H3M Reading CDR H3 C-ter Fragments" << std::endl;
443 
444  bool is_kinked( antibody_in.kinked_ );
445  bool is_extended( antibody_in.extended_ );
446 
447  // extract single letter aa codes for the chopped loop residues
448  Size cdr_h3_size = ( antibody_in.cdrh_[3][2] -
449  antibody_in.cdrh_[3][1] ) + 1;
450  utility::vector1< char > aa_1name;
451  for( Size ii = antibody_in.cdrh_[3][1] - 2;
452  ii <= ( antibody_in.cdrh_[3][1] - 2 ) + cdr_h3_size + 3; ++ii )
453  aa_1name.push_back( antibody_in.Fv_sequence_[ii] );
454 
455  // used only when no length & kink match are found
456  utility::vector1< FragData > H3_base_library_seq_kink;
457 
458  // used only when no (length & kink) or (length & seq) are found
459  utility::vector1< FragData > H3_base_library_kink;
460 
461  std::string H3_ter_library_filename;
462  // file is read in from where other contraints are supposed to exist
463  if( is_camelid )
464  H3_ter_library_filename = "camelid_H3_CTERM";
465  else
466  H3_ter_library_filename = "H3_CTERM";
467 
468  // Read the file defined by command line option
469  utility::io::izstream H3_ter_library_stream( H3_ter_library_filename );
470 
471  // Check to see if file exists
472  if ( !H3_ter_library_stream ) {
473  TR << "[Error]: Could not open H3 base library file: "
474  << H3_ter_library_filename << std::endl
475  << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" << std::endl;
476  std::exit( EXIT_FAILURE );
477  }
478 
479  std::string pdb_name;
480  std::string res_no;
481  char res_name;
482  Real phi(0.0);
483  Real psi(0.0);
484  Real omega(0.0);
485  Size H3_length(0);
486  Real resolution(0.0);
487  std::string base_type;
488 
489  Size pdb_H3_length = cdr_h3_size;
490  Size h3_base_frag_size( is_camelid ? 6 : 4 ); // changed from 4:6
491  bool end_not_reached(true);
492  while(end_not_reached){
493  bool seq_match( true );
494  bool kink_match( false );
495 
496  FragData f;
497  f.set_valid( true );
498 
499  for ( Size i = 1; i <= h3_base_frag_size; ++i ) {
500  H3_ter_library_stream >> pdb_name
501  >> res_no
502  >> res_name
503  >> omega
504  >> phi
505  >> psi
506  >> H3_length
507  >> resolution
508  >> base_type
509  >> std::skipws;
510  if ( H3_ter_library_stream.eof() ) {
511  end_not_reached = false;
512  break;
513  }
514  if( res_name != aa_1name[aa_1name.size() - 5 + i] )
515  seq_match = false;
516 
518  new BBTorsionSRFD( 3, 'L', res_name ) ); // 3 protein torsions
519  // ugly numbers 1-3, but pose.set_phi also uses explicit numbers
520  res_torsions->set_torsion ( 1, phi );
521  res_torsions->set_torsion ( 2, psi );
522  res_torsions->set_torsion ( 3, omega );
523  res_torsions->set_secstruct ( 'L' );
524  f.add_residue( res_torsions );
525  }
526  if( !is_camelid ) {
527  if( is_kinked && base_type == "KINK" )
528  kink_match = true;
529  else if( is_extended && base_type == "EXTENDED" )
530  kink_match = true;
531  else if( !is_kinked && !is_extended && base_type == "NEUTRAL" )
532  kink_match = true;
533  } else {
534  if( is_extended && base_type == "EXTENDED" )
535  kink_match = true;
536  else if( ( is_kinked && base_type == "KINK" ) ||
537  ( is_kinked && base_type == "EXTENDED" ) )
538  kink_match = true;
539  else if( !is_kinked && !is_extended )
540  kink_match = true;
541  }
542  if( is_camelid && end_not_reached && kink_match ) {
543  H3_base_library.push_back( f );
544  } else if( end_not_reached && ( H3_length == pdb_H3_length )
545  && kink_match ) {
546  H3_base_library.push_back( f );
547  }
548  if( end_not_reached && seq_match && kink_match ) {
549  H3_base_library_seq_kink.push_back( f );
550  }
551  if( end_not_reached && kink_match ) {
552  H3_base_library_kink.push_back( f );
553  }
554  }
555 
556  H3_ter_library_stream.close();
557  H3_ter_library_stream.clear();
558 
559  // if no match found based on sequence and kink match criterion
560  // then choose based on size and kink match criterion
561  // if still no match, then choose based only on kink
562  if( H3_base_library.size() == 0 ) {
563  H3_base_library = H3_base_library_seq_kink;
564  }
565  if( H3_base_library.size() == 0 ) {
566  H3_base_library = H3_base_library_kink;
567  }
568 
569  TR << "H3M Finished reading CDR H3 C-ter Fragments" << std::endl;
570 
571  return;
572 }
573 
575 
576  TR << "H3M Inserting CDR H3 C-ter Fragments" << std::endl;
577 
578  // Storing initial fold tree
579  kinematics::FoldTree const input_tree( antibody_in_.Fv.fold_tree() );
580 
581  Size loop_begin(0), loop_end(0), cutpoint(0), random_H3_ter(0);
582  //utility::vector1< fragment::FragData >::const_iterator H3_ter;
584 
585  loop_begin = antibody_in_.cdrh_[3][1];
586  cutpoint = antibody_in_.cdrh_[3][1] + 1;
587  random_H3_ter = RG.random_range( 1, H3_base_library.size() );
588  //H3_ter = H3_base_library.begin();
589 
590  loop_end = antibody_in_.cdrh_[3][2] + 1;
591 
592  loops::Loop cdr_h3( loop_begin, loop_end, cutpoint, 0, true );
594 
595  // choosing a base randomly
596  //H3_ter = H3_ter + random_H3_ter;
597  f = H3_base_library[ random_H3_ter ];
598 
599  pose::Pose start_pose = antibody_in_.Fv;
600  //inserting base dihedrals
601  Size cter_insertion_pos( is_camelid_ ? 4 : 2 );
602  if( (antibody_in_.cdrh_[3][2] - cter_insertion_pos) <=
603  antibody_in_.cdrh_[3][1] ) {
604  TR << "H3 LOOP IS TOO SHORT: CAN NOT USE N-TERM INFORMATION" << std::endl;
605  } else {
606  // H3_ter->apply(...);
608  cter_insertion_pos, antibody_in_.cdrh_[3][2] + 1 );
609  }
610 
611  // Restoring pose fold tree
612  antibody_in_.Fv.fold_tree( input_tree );
613 
614  TR << "H3M Finished Inserting CDR H3 C-ter Fragments" << std::endl;
615 
616  return;
617 } // antibody_modeling_insert_ter
618 
620 
621  bool closed_cutpoints = true;
622 
624  it_end=antibody_in_.all_cdr_loops.end(),
625  it_next; it != it_end; ++it ) {
626  Size cutpoint = it->cut();
627  Real separation = 10.00; // an unlikely high number
628  separation = cutpoint_separation( antibody_in_.Fv, cutpoint );
629 
630  if( separation > 1.9 ) {
631  closed_cutpoints = false;
632  break;
633  }
634  }
635  return( closed_cutpoints );
636 } // cutpoints_separation
637 
639 pose::Pose & pose_in,
640  Size cutpoint ) {
641 
642  Size const N ( 1 ); // N atom
643  Size const C ( 3 ); // C atom
644 
645  // Coordinates of the C atom of cutpoint res and N atom of res cutpoint+1
646  numeric::xyzVector_float peptide_C(pose_in.residue( cutpoint ).xyz( C )),
647  peptide_N( pose_in.residue( cutpoint + 1 ).xyz( N ) );
648  Real cutpoint_separation=peptide_C.distance(peptide_N);
649 
650  return( cutpoint_separation );
651 } // cutpoint_separation
652 
653 ///////////////////////////////////////////////////////////////////////////
654 /// @begin scored_frag_close
655 ///
656 /// @brief builds a loop from fragments file.
657 ///
658 /// @detailed Loop is built by a monte carlo simulation using fragments
659 /// from a fragment files. CCD moves are used to close loops
660 /// with gaps at cutpoint.H3_check is enforced if H3_filter flag
661 /// is set in command line. Loop building results in many files
662 /// containing differnt conformations of the same loop in
663 /// phi-psi-omega angles. Parallel processing is utilized.
664 ///
665 /// @param[in] weight_map: in this case its a centroid weight
666 /// pose_in: loop to be built on this template provided
667 /// loop_begin/loop_end: loop termini definition
668 /// frag_size: 3-mer or 9-mer
669 /// frag_offset:agreement in frag file numbering & pose numberng
670 /// cycles1: max cycles to be spent building loops
671 /// cycles2: # of fragment swaps for each loop(depends on size)
672 /// do_ccd_moves: should ccd moves be used to close gaps
673 ///
674 /// @global_read benchmark_
675 ///
676 /// @global_write
677 ///
678 /// @remarks
679 ///
680 /// @references
681 ///
682 /// @authors Aroop 02/04/2010
683 ///
684 /// @last_modified 02/04/2010
685 ///////////////////////////////////////////////////////////////////////////
687  pose::Pose & pose_in,
688  loops::Loop const trimmed_cdr_h3 ) {
689  using namespace fragment;
690  using namespace protocols;
691  using namespace protocols::simple_moves;
692  using namespace protocols::loops;
697 
698  TR << "H3M Fragments based centroid CDR H3 loop building" << std::endl;
699 
700  if( trimmed_cdr_h3.size() <= 2)
701  utility_exit_with_message("Loop too small for modeling");
702 
703  // set cutpoint variants for correct chainbreak scoring
704  if( !pose_in.residue( trimmed_cdr_h3.cut() ).is_upper_terminus() ) {
705  if( !pose_in.residue( trimmed_cdr_h3.cut() ).has_variant_type(
709  trimmed_cdr_h3.cut() );
710  if( !pose_in.residue( trimmed_cdr_h3.cut() + 1 ).has_variant_type(
714  trimmed_cdr_h3.cut() + 1 );
715  }
716 
717 
718  Size cycles1(10);
719  // aroop_temp default 25 * loop size
720  Size cycles2(25 * trimmed_cdr_h3.size() );
721 
722  // params
723  Real const ccd_threshold( 0.1);
724  Size h3_attempts(0);
725  Real h3_fraction = 0.75; // 75% of loops are required to be H3's
726  Real current_h3_prob = RG.uniform();;
727  bool H3_found_ever(false);
728  bool loop_found(false);
729  Size total_cycles(0);
730  Size frag_size(0);
731  FragSetOP frags_to_use;
732  {
733  if( trimmed_cdr_h3.size() > cutoff_9_ ) {
734  frags_to_use = cdr_h3_frags_[1]->empty_clone();
735  frags_to_use = cdr_h3_frags_[1];
736  frag_size = 9;
737  } else {
738  frags_to_use = cdr_h3_frags_[2]->empty_clone();
739  frags_to_use = cdr_h3_frags_[2];
740  frag_size = 3;
741  }
742  }
743 
744  // Storing Fold Tree
745  kinematics::FoldTree old_fold_tree = pose_in.fold_tree();
746  // New Fold Tree
747  simple_one_loop_fold_tree( pose_in, trimmed_cdr_h3 );
748 
749  //setting MoveMap
750  kinematics::MoveMapOP cdrh3_map;
751  cdrh3_map = new kinematics::MoveMap();
752  cdrh3_map->clear();
753  cdrh3_map->set_chi( true );
754  cdrh3_map->set_bb( false );
755  for( Size ii = trimmed_cdr_h3.start(); ii<=trimmed_cdr_h3.stop(); ii++ ) {
756  cdrh3_map->set_bb( ii, true );
757  }
758  cdrh3_map->set_jump( 1, false );
759 
760  // setup monte_carlo
761  Real temp( 2.0);
762  MonteCarloOP mc, outer_mc;
763  mc = new moves::MonteCarlo( pose_in, *lowres_scorefxn_, temp );
764  outer_mc = new moves::MonteCarlo( pose_in, *lowres_scorefxn_, temp );
765  Size buffer( (is_camelid_ && antibody_in_.extended_) ? 2 : 0 );
766  while( !loop_found && ( total_cycles++ < cycles1) ) {
767  // insert random fragments over the whole loop
768  for(Size ii = trimmed_cdr_h3.start(); ii<=trimmed_cdr_h3.stop()
769  - ( buffer + (frag_size - 1 ) ); ii++ ) {
770  ClassicFragmentMoverOP cfm = new ClassicFragmentMover( frags_to_use,
771  cdrh3_map);
772  cfm->set_check_ss( false );
773  cfm->enable_end_bias_check( false );
774  cfm->define_start_window( ii );
775  cfm->apply( pose_in );
776  }
777  if( total_cycles == 1 ) {
778  mc->reset( pose_in );
779  }
780 
781  Size local_h3_attempts(0);
782  for ( Size c2 = 1; c2 <= cycles2; ++c2 ) {
783  // apply a random fragment
784  ClassicFragmentMoverOP cfm = new ClassicFragmentMover( frags_to_use,
785  cdrh3_map);
786  cfm->set_check_ss( false );
787  cfm->enable_end_bias_check( false );
788  cfm->apply( pose_in );
789 
790  bool H3_found_current(false);
792  ( local_h3_attempts++ < (50 * cycles2) ) ) {
793  H3_found_current = CDR_H3_filter(pose_in,antibody_in_.cdrh_[3][1],
794  ( antibody_in_.cdrh_[3][2] - antibody_in_.cdrh_[3][1] ) + 1 );
795  if( !H3_found_ever && !H3_found_current) {
796  --c2;
797  mc->boltzmann( pose_in );
798  } else if( !H3_found_ever && H3_found_current ) {
799  H3_found_ever = true;
800  mc->reset( pose_in );
801  } else if( H3_found_ever && !H3_found_current ) {
802  --c2;
803  continue;
804  } else if( H3_found_ever && H3_found_current )
805  mc->boltzmann( pose_in );
806  } else {
807  mc->boltzmann( pose_in );
808  }
809 
810  if ( (c2 > cycles2/2 && RG.uniform() * cycles2 < c2) ||
811  ( trimmed_cdr_h3.size() <= 5) ) {
812  // in 2nd half of simulation, start trying to close the loop:
813  CcdMoverOP ccd_moves = new CcdMover( trimmed_cdr_h3, cdrh3_map );
814  RepeatMoverOP ccd_cycle;
815  if( trimmed_cdr_h3.size() <= 5 ) {
816  ccd_cycle = new RepeatMover(ccd_moves,500*trimmed_cdr_h3.size());
817  ccd_cycle->apply( pose_in );
818  } else {
819  ccd_cycle = new RepeatMover(ccd_moves, 10*trimmed_cdr_h3.size());
820  ccd_cycle->apply( pose_in );
821  }
822  mc->boltzmann( pose_in );
823  }
824  }
825 
826  mc->recover_low( pose_in );
827  CcdLoopClosureMoverOP ccd_closure = new CcdLoopClosureMover(
828  trimmed_cdr_h3, cdrh3_map );
829  ccd_closure->set_tolerance( ccd_threshold );
830  ccd_closure->set_ccd_cycles( 500 );
831  ccd_closure->apply( pose_in );
832 
833  if( total_cycles == 1 )
834  outer_mc->reset( pose_in );
835 
836  if ( ccd_closure->forward_deviation() <= ccd_threshold &&
837  ccd_closure->backward_deviation() <= ccd_threshold ) {
838  // CDR-H3 filter for antibody mode
839  // introduce enough diversity
840  outer_mc->boltzmann( pose_in );
842  (current_h3_prob < h3_fraction) && (h3_attempts++<50) )
843  if( !CDR_H3_filter(pose_in, antibody_in_.cdrh_[3][1],
844  ( antibody_in_.cdrh_[3][2] - antibody_in_.cdrh_[3][1] ) + 1) )
845  continue;
846  loop_found = true;
847  } else if( H3_filter_ ) {
848  h3_attempts++;
849  }
850  }
851  outer_mc->recover_low( pose_in );
852 
853  // Restoring Fold Tree
854  pose_in.fold_tree( old_fold_tree );
855 
856  TR << "H3M Finished Fragments based centroid CDR H3 loop building"
857  << std::endl;
858 
859  return;
860 } // scored_frag_close
861 
862 ///////////////////////////////////////////////////////////////////////////
863 /// @begin CDR_H3_filter
864 ///
865 /// @brief tests if a loop has H3 like base charachteristics
866 ///
867 /// @detailed Uses the Shirai rules to find out if the dihedral angle
868 /// formed by CA atoms of residues n-2,n-1,n and n+1 conform to a
869 /// kinked/extended structure in accordance with the sequence. If
870 /// there is a match, a true value is returned
871 ///
872 /// @param[in] pose: full actual protein
873 /// loop_begin: seq numbered loop begin corresponding to pose
874 /// size: size of loop to compute loop_end
875 ///
876 /// @global_read reads -command line flag -base stored in dle_ns
877 /// to determine to do the complete H3 filter check or just do
878 /// a prediction of the H3 base type based on the
879 /// aforementioned dihedral angle
880 ///
881 /// @global_write
882 ///
883 /// @remarks
884 ///
885 /// @references Structural classification of CDR-H3 in antibodies
886 /// Hiroki Shirai, Akinori Kidera, Haruki Nakamura
887 /// FEBS Letters 399 (1996) 1-8
888 ///
889 /// @authors Aroop 02/04/2010
890 ///
891 /// @last_modified 02/04/2010
892 ///////////////////////////////////////////////////////////////////////////
894  const pose::Pose & pose_in,
895  Size const loop_begin,
896  Size const size,
897  char const light_chain
898 )
899 {
900 
901  TR << "H3M Checking Kink/Extended CDR H3 Base Angle" << std::endl;
902 
903  if( !H3_filter_ || is_camelid_ )
904  return( true );
905 
906  // Values read from plot in reference paper. Fig 1 on Page 3
907  // Values adjusted to match data from antibody training set
908  Real const kink_lower_bound = -10.00; // Shirai: 0
909  Real const kink_upper_bound = 70.00; // Shirai: 70
910  Real const extended_lower_bound = 125.00; // Shirai: ~180
911  Real const extended_upper_bound = 185.00; // Shirai: ~180
912 
913  // Hydrogen Bond maximum value is 3.9 Angstroms - not used
914  // Real const h_bond(3.9);
915  // Salt Bridge maximum value is 2.0 Angstroms - not used
916  // Real const s_bridge(4.0);
917 
918  // chop out the loop
919  pose::Pose h3_loop( pose_in, loop_begin - 2, loop_begin + size + 1 );
920 
921  //bool is_kinked( false );
922  //bool is_extended( false );
923  bool is_H3( false );
924 
925  // extract 3 letter residue codes for the chopped loop
926  std::vector <std::string> aa_name; // loop residue 3 letter codes
927  for(Size ii = 1; ii <= size + 3; ii++)
928  aa_name.push_back( h3_loop.residue(ii).name3() );
929 
930  Size const CA(2); // CA atom position in full_coord array
931  // base dihedral angle to determine kinked/extended conformation
932  Real base_dihedral( numeric::dihedral_degrees(
933  h3_loop.residue( aa_name.size() ).xyz( CA ),
934  h3_loop.residue( aa_name.size() - 1).xyz( CA ),
935  h3_loop.residue( aa_name.size() - 2).xyz( CA ),
936  h3_loop.residue( aa_name.size() - 3).xyz( CA ) ) );
937 
938  // std::cout << "Base Dihedral: " << base_dihedral << std::endl;
939 
940  // setting up pseudo-periodic range used in extended base computation
941  if( base_dihedral < kink_lower_bound )
942  base_dihedral = base_dihedral + 360.00;
943 
944 
945  // Rule 1a for standard kink
946  if ((aa_name[aa_name.size()-3] != "ASP") &&
947  (aa_name[aa_name.size()-1] == "TRP")) {
948  if( (base_dihedral > kink_lower_bound) &&
949  (base_dihedral < kink_upper_bound))
950  {
951  // std::cout << "KINK Found" << std::endl; // aroop_temp remove
952  //is_kinked = true; // set but never used ~Labonte
953  is_H3 = true;
954  }
955  }
956 
957  // Rule 1b for standard extended form
958  if ( ( aa_name[ aa_name.size() - 3 ] == "ASP" ) &&
959  ( ( aa_name[1] != "LYS" ) && ( aa_name[1] != "ARG" ) )&&
960  ( is_H3 != true ) ) {
961  if( ( base_dihedral > extended_lower_bound ) &&
962  ( base_dihedral < extended_upper_bound) ) {
963  // std::cout << "EXTENDED Found" << std::endl; // aroop_temp remove
964  //is_extended = true; // set but never used ~Labonte
965  is_H3 = true;
966  }
967 
968  if(!is_H3) {
969  // Rule 1b extension for special kinked form
970  bool is_basic(false); // Special basic residue exception flag
971  for(Size ii = 2; ii <= Size(aa_name.size() - 5); ii++) {
972  if( aa_name[ii] == "ARG" || aa_name[ii] == "LYS" ) {
973  is_basic = true;
974  break;
975  }
976  }
977 
978  if(!is_basic) {
979  Size rosetta_number_of_L49 = pose_in.pdb_info()->pdb2pose(
980  light_chain, 49 );
981  std::string let3_code_L49 =
982  pose_in.residue( rosetta_number_of_L49 ).name3();
983  if( let3_code_L49 == "ARG" || let3_code_L49 == "LYS")
984  is_basic = true;
985  }
986  if( is_basic && ( base_dihedral > kink_lower_bound ) &&
987  ( base_dihedral < kink_upper_bound ) ) {
988  // aroop_temp remove
989  // std::cout << "KINK (special 1b) Found" << std::endl;
990  //is_kinked = true; // set but never used ~Labonte
991  is_H3 = true;
992  }
993  }
994  }
995 
996  // Rule 1c for kinked form with salt bridge
997  if ( ( aa_name[ aa_name.size() - 3 ] == "ASP") &&
998  ( ( aa_name[1] == "LYS") || ( aa_name[1] == "ARG" ) ) &&
999  ( (aa_name[0] != "LYS" ) && ( aa_name[0] != "ARG" ) ) &&
1000  ( is_H3 != true) ) {
1001  if( (base_dihedral > kink_lower_bound ) &&
1002  (base_dihedral < kink_upper_bound ) ) {
1003  // aroop_temp remove
1004  // std::cout << "KINK (w sb) Found" << std::endl;
1005  //is_kinked = true; // set but never used ~Labonte
1006  is_H3 = true;
1007  }
1008  if(!is_H3) {
1009  bool is_basic(false); // Special basic residue exception flag
1010  Size rosetta_number_of_L46 = pose_in.pdb_info()->pdb2pose(
1011  light_chain, 46 );
1012  std::string let3_code_L46 =
1013  pose_in.residue( rosetta_number_of_L46 ).name3();
1014  if( let3_code_L46 == "ARG" || let3_code_L46 == "LYS")
1015  is_basic = true;
1016  if( is_basic && (base_dihedral > extended_lower_bound ) &&
1017  ( base_dihedral < extended_upper_bound ) ) {
1018  // aroop_temp remove
1019  // std::cout << "EXTENDED (special 1c) Found" << std::endl;
1020  //is_extended = true; // set but never used ~Labonte
1021  is_H3 = true;
1022  }
1023  }
1024  }
1025 
1026  // Rule 1d for extened form with salt bridge
1027  if ( ( aa_name[ aa_name.size() - 3 ] == "ASP") &&
1028  ( ( aa_name[1] == "LYS") || ( aa_name[1] == "ARG" ) ) &&
1029  ( ( aa_name[0] == "LYS") || ( aa_name[0] == "ARG") ) &&
1030  ( is_H3 != true ) ) {
1031  if( ( base_dihedral > extended_lower_bound ) &&
1032  ( base_dihedral < extended_upper_bound ) ) {
1033  // aroop_temp remove
1034  // std::cout << "EXTENDED (w sb) Found" << std::endl;
1035  //is_extended = true; // set but never used ~Labonte
1036  is_H3 = true;
1037  }
1038  }
1039 
1040  TR << "H3M Finished Checking Kink/Extended CDR H3 Base Angle: "
1041  << is_H3 << std::endl;
1042 
1043  return is_H3;
1044 } // CDR_H3_filter
1045 
1046 ///////////////////////////////////////////////////////////////////////////
1047 /// @begin loop_fa_relax
1048 ///
1049 /// @brief actually relaxes the region specified
1050 ///
1051 /// @detailed This is all done in high resolution.Hence there are no rigid
1052 /// body moves relative to the docking partners. Only small moves
1053 /// are carried out here to see if there are better fits.
1054 /// Repacking is carried out extensively after each move.
1055 ///
1056 /// @param[in] pose, loop begin position, loop end position
1057 ///
1058 /// @global_read none
1059 ///
1060 /// @global_write none
1061 ///
1062 /// @remarks
1063 ///
1064 /// @references
1065 ///
1066 /// @authors Aroop 02/04/2010
1067 ///
1068 /// @last_modified 02/04/2010
1069 ///////////////////////////////////////////////////////////////////////////
1071  pose::Pose & pose_in,
1072  Size const loop_begin,
1073  Size const loop_end )
1074 {
1075  using namespace protocols;
1076  using namespace protocols::simple_moves;
1077  using namespace protocols::loops;
1078  using namespace protocols::moves;
1079  using namespace protocols::toolbox::task_operations;
1080  using namespace pack;
1081  using namespace pack::task;
1082  using namespace pack::task::operation;
1085 
1086  TR << "H3M Relaxing CDR H3 Loop" << std::endl;
1087 
1088  // storing starting fold tree
1089  kinematics::FoldTree tree_in( pose_in.fold_tree() );
1090 
1091  //setting MoveMap
1092  kinematics::MoveMapOP cdrh3_map;
1093  cdrh3_map = new kinematics::MoveMap();
1094  cdrh3_map->clear();
1095  cdrh3_map->set_chi( false );
1096  cdrh3_map->set_bb( false );
1097  utility::vector1< bool> allow_bb_move( pose_in.total_residue(), false );
1098  for( Size ii = loop_begin; ii <= loop_end; ii++ )
1099  allow_bb_move[ ii ] = true;
1100  cdrh3_map->set_bb( allow_bb_move );
1101  cdrh3_map->set_jump( 1, false );
1102 
1103 
1104  // minimize_set_local_min( false, 0 );// all non-move-list rsds minimized
1105 
1106  Size loop_size = ( loop_end - loop_begin ) + 1;
1107  Size cutpoint = loop_begin + int(loop_size/2);
1108  if( current_loop_is_H3_ ) {
1109  if( (antibody_build_ || antibody_refine_ ) &&
1111  (decoy_loop_cutpoint_ != 0))
1112  cutpoint = decoy_loop_cutpoint_;
1113  //else if( h3_random_cut_ )
1114  // cutpoint = dle_choose_random_cutpoint(loop_begin, loop_end);
1115  }
1116  else
1117  cutpoint = loop_begin + Size( loop_size / 2);
1118  /*
1119  if( snug_fit_ && loops_flag_ && docking_local_refine_ &&
1120  dle_flag_ ) {
1121  one_loop = dle_ns::dle_loops;
1122  }
1123  else */
1124  loops::Loop one_loop( loop_begin, loop_end, cutpoint, 0, false );
1125 
1126  // sets up stuff to use rosetta's fullatom energy function
1127  //initialize_fullatom();
1128  // maximum number of rotamers to allow (buried, surface)
1129  //set_rot_limit( 45, 27 );
1130  // maximum sum for the dunbrak prob (buried,surf)
1131  //set_perc_limit( 0.9999, 0.9999 );
1132  // include extra rotamers in chi1/chi2/chi1aro
1133  //design::active_rotamer_options.set_ex12( true, true, true);
1134  // checking if old rosetta full atom flag is on
1135 
1136  if ( !pose_in.is_fullatom() )
1137  utility_exit_with_message("Fullatom poses only");
1138 
1139  ChangeFoldTreeMoverOP one_loop_fold_tree;
1140  ChangeFoldTreeMoverOP with_flank_fold_tree;
1141  simple_fold_tree( pose_in, loop_begin - 1, cutpoint, loop_end + 1 );
1142  one_loop_fold_tree = new ChangeFoldTreeMover( pose_in.fold_tree() );
1143  with_flank_fold_tree = new ChangeFoldTreeMover( pose_in.fold_tree() );
1144 
1145  //////////////////
1146  // setup fold_tree
1147  utility::vector1< bool> flank_allow_bb_move( allow_bb_move );
1149  simple_fold_tree( pose_in, loop_begin - h3_flank_ - 1, cutpoint,
1150  loop_end + h3_flank_ + 1 );
1151  with_flank_fold_tree = new ChangeFoldTreeMover( pose_in.fold_tree() );
1152  for( Size i = 1; i <= pose_in.total_residue(); i++ )
1153  if( (i >= (loop_begin - h3_flank_)) && (i <= (loop_end + h3_flank_)))
1154  flank_allow_bb_move[i] = true;
1155  }
1156  else
1157  one_loop_fold_tree->apply( pose_in );
1158 
1159  // set cutpoint variants for correct chainbreak scoring
1160  if( !pose_in.residue( cutpoint ).is_upper_terminus() ) {
1161  if( !pose_in.residue( cutpoint ).has_variant_type(
1165  cutpoint );
1166  if( !pose_in.residue( cutpoint + 1 ).has_variant_type(
1170  cutpoint + 1 );
1171  }
1172 
1173 
1174 
1175  utility::vector1< bool> allow_repack( pose_in.total_residue(), false );
1176  select_loop_residues( pose_in, one_loop, true /*include_neighbors*/,
1177  allow_repack);
1178  cdrh3_map->set_chi( allow_repack );
1179 
1182  ( *highres_scorefxn_ )( pose_in );
1183  tf_->push_back( new RestrictToInterface( allow_repack ) );
1184  loop_repack->task_factory(tf_);
1185  // loop_repack->apply( pose_in );
1186 
1187  Real min_tolerance = 0.001;
1188  if( benchmark_ ) min_tolerance = 1.0;
1189  std::string min_type = std::string( "dfpmin_armijo_nonmonotone" );
1190  bool nb_list = true;
1192  highres_scorefxn_, min_type, min_tolerance, nb_list );
1193 
1194  // more params
1195  Size n_small_moves ( numeric::max(Size(5), Size(loop_size/2)) );
1196  Size inner_cycles( loop_size );
1197  Size outer_cycles( 1 );
1199  outer_cycles = 5;
1200  if( antibody_refine_ && snug_fit_ )
1201  outer_cycles = 2;
1202  if( benchmark_ ) {
1203  n_small_moves = 1;
1204  inner_cycles = 1;
1205  outer_cycles = 1;
1206  }
1207 
1208  Real high_move_temp = 2.00;
1209  // minimize amplitude of moves if correct parameter is set
1211  high_move_temp,
1212  n_small_moves );
1214  high_move_temp,
1215  n_small_moves );
1216  if( min_base_relax_ ) {
1217  small_mover->angle_max( 'H', 0.5 );
1218  small_mover->angle_max( 'E', 0.5 );
1219  small_mover->angle_max( 'L', 1.0 );
1220  shear_mover->angle_max( 'H', 0.5 );
1221  shear_mover->angle_max( 'E', 0.5 );
1222  shear_mover->angle_max( 'L', 1.0 );
1223  }
1224  else {
1225  small_mover->angle_max( 'H', 2.0 );
1226  small_mover->angle_max( 'E', 5.0 );
1227  small_mover->angle_max( 'L', 6.0 );
1228  shear_mover->angle_max( 'H', 2.0 );
1229  shear_mover->angle_max( 'E', 5.0 );
1230  shear_mover->angle_max( 'L', 6.0 );
1231  }
1232 
1233  CcdMoverOP ccd_moves = new CcdMover( one_loop, cdrh3_map );
1234  RepeatMoverOP ccd_cycle = new RepeatMover(ccd_moves, n_small_moves);
1235 
1236  SequenceMoverOP wiggle_cdr_h3( new SequenceMover() );
1237  wiggle_cdr_h3->add_mover( one_loop_fold_tree );
1238  wiggle_cdr_h3->add_mover( small_mover );
1239  wiggle_cdr_h3->add_mover( shear_mover );
1240  wiggle_cdr_h3->add_mover( ccd_cycle );
1241  wiggle_cdr_h3->add_mover( with_flank_fold_tree );
1242 
1243 
1244  cdrh3_map->set_bb( flank_allow_bb_move );
1245  with_flank_fold_tree->apply( pose_in );
1246  loop_min_mover->movemap( cdrh3_map );
1247  loop_min_mover->apply( pose_in );
1248  cdrh3_map->set_bb( allow_bb_move );
1249 
1250  // rotamer trials
1251  select_loop_residues( pose_in, one_loop, true /*include_neighbors*/,
1252  allow_repack);
1253  cdrh3_map->set_chi( allow_repack );
1255  ( *highres_scorefxn_ )( pose_in );
1256  tf_->push_back( new RestrictToInterface( allow_repack ) );
1259 
1260  pack_rottrial->apply( pose_in );
1261 
1262 
1263  Real const init_temp( 2.0 );
1264  Real const last_temp( 0.5 );
1265  Real const gamma = std::pow( (last_temp/init_temp), (1.0/inner_cycles));
1266  Real temperature = init_temp;
1267 
1268  MonteCarloOP mc;
1269  mc = new moves::MonteCarlo( pose_in, *highres_scorefxn_, temperature );
1270  mc->reset( pose_in ); // monte carlo reset
1271 
1272  bool relaxed_H3_found_ever( false );
1273  if( H3_filter_)
1274  relaxed_H3_found_ever =CDR_H3_filter(pose_in,antibody_in_.cdrh_[3][1],
1275  (antibody_in_.cdrh_[3][2] - antibody_in_.cdrh_[3][1]) + 1 );
1276 
1277  // outer cycle
1278  for(Size i = 1; i <= outer_cycles; i++) {
1279  mc->recover_low( pose_in );
1280  Size h3_attempts(0); // number of H3 checks after refinement
1281 
1282  // inner cycle
1283  for ( Size j = 1; j <= inner_cycles; j++ ) {
1284  temperature *= gamma;
1285  mc->set_temperature( temperature );
1286  wiggle_cdr_h3->apply( pose_in );
1287  cdrh3_map->set_bb( flank_allow_bb_move );
1288  loop_min_mover->movemap( cdrh3_map );
1289  loop_min_mover->apply( pose_in );
1290  cdrh3_map->set_bb( allow_bb_move );
1291 
1292  // rotamer trials
1293  select_loop_residues( pose_in, one_loop, true /*include_neighbors*/,
1294  allow_repack);
1295  cdrh3_map->set_chi( allow_repack );
1297  ( *highres_scorefxn_ )( pose_in );
1298  tf_->push_back( new RestrictToInterface( allow_repack ) );
1301  pack_rottrial->apply( pose_in );
1302 
1303  bool relaxed_H3_found_current(false);
1304  // H3 filter check
1305  if(H3_filter_ && (h3_attempts <= inner_cycles)) {
1306  h3_attempts++;
1307  relaxed_H3_found_current = CDR_H3_filter(pose_in,
1308  antibody_in_.cdrh_[3][1], ( antibody_in_.cdrh_[3][2] -
1309  antibody_in_.cdrh_[3][1]) + 1 );
1310 
1311  if( !relaxed_H3_found_ever && !relaxed_H3_found_current) {
1312  mc->boltzmann( pose_in );
1313  }
1314  else if( !relaxed_H3_found_ever && relaxed_H3_found_current ) {
1315  relaxed_H3_found_ever = true;
1316  mc->reset( pose_in );
1317  }
1318  else if( relaxed_H3_found_ever && !relaxed_H3_found_current ) {
1319  --j;
1320  continue;
1321  }
1322  else if( relaxed_H3_found_ever && relaxed_H3_found_current )
1323  mc->boltzmann( pose_in );
1324  }
1325  else {
1326  if( H3_filter_ ) {
1327  bool relaxed_H3_found_current(false);
1328  relaxed_H3_found_current = CDR_H3_filter(pose_in,
1329  antibody_in_.cdrh_[3][1], ( antibody_in_.cdrh_[3][2] -
1330  antibody_in_.cdrh_[3][1]) + 1 );
1331  if( !relaxed_H3_found_ever && !relaxed_H3_found_current) {
1332  mc->boltzmann( pose_in );
1333  }
1334  else if( !relaxed_H3_found_ever && relaxed_H3_found_current ) {
1335  relaxed_H3_found_ever = true;
1336  mc->reset( pose_in );
1337  }
1338  else if( relaxed_H3_found_ever && !relaxed_H3_found_current ) {
1339  mc->recover_low( pose_in );
1340  }
1341  else if( relaxed_H3_found_ever && relaxed_H3_found_current )
1342  mc->boltzmann( pose_in );
1343  }
1344  else
1345  mc->boltzmann( pose_in );
1346  }
1347 
1348  if ( numeric::mod(j,Size(20))==0 || j==inner_cycles ) {
1349  // repack trial
1352  ( *highres_scorefxn_ )( pose_in );
1353  tf_->push_back( new RestrictToInterface( allow_repack ) );
1354  loop_repack->task_factory( tf_ );
1355  loop_repack->apply( pose_in );
1356  mc->boltzmann( pose_in );
1357  }
1358  } // inner cycles
1359  } // outer cycles
1360  mc->recover_low( pose_in );
1361 
1362  // minimize
1363  if( !benchmark_ ) {
1364  cdrh3_map->set_bb( flank_allow_bb_move );
1365  with_flank_fold_tree->apply( pose_in );
1366  loop_min_mover->movemap( cdrh3_map );
1367  loop_min_mover->apply( pose_in );
1368  cdrh3_map->set_bb( allow_bb_move );
1369  }
1370 
1371  // Restoring pose stuff
1372  pose_in.fold_tree( tree_in ); // Tree
1373 
1374  TR << "H3M Finished Relaxing CDR H3 Loop" << std::endl;
1375 
1376  return;
1377 } // CDRH3Modeler::loop_fa_relax
1378 
1379 ///////////////////////////////////////////////////////////////////////////
1380 /// @begin loop_centroid_relax
1381 ///
1382 /// @brief actually relaxes the region specified
1383 ///
1384 /// @detailed This is all done in low resolution. Intention was to give
1385 /// camelid CDR H1 a larger perturbation.
1386 ///
1387 /// @param[in] pose, loop begin position, loop end position
1388 ///
1389 /// @global_read none
1390 ///
1391 /// @global_write none
1392 ///
1393 /// @remarks
1394 ///
1395 /// @references
1396 ///
1397 /// @authors Aroop 05/07/2010
1398 ///
1399 /// @last_modified 05/07/2010
1400 ///////////////////////////////////////////////////////////////////////////
1402  pose::Pose & pose_in,
1403  Size const loop_begin,
1404  Size const loop_end )
1405 {
1406  using namespace protocols;
1407  using namespace protocols::simple_moves;
1408  using namespace protocols::loops;
1409  using namespace protocols::moves;
1410  using namespace pack;
1411  using namespace pack::task;
1412  using namespace pack::task::operation;
1415 
1416  TR << "H3M Centroid Relaxing Loop" << std::endl;
1417 
1418  // storing starting fold tree
1419  kinematics::FoldTree tree_in( pose_in.fold_tree() );
1420 
1421  //setting MoveMap
1422  kinematics::MoveMapOP loop_map;
1423  loop_map = new kinematics::MoveMap();
1424  loop_map->clear();
1425  loop_map->set_chi( false );
1426  loop_map->set_bb( false );
1427  utility::vector1< bool> allow_bb_move( pose_in.total_residue(), false );
1428  for( Size ii = loop_begin; ii <= loop_end; ii++ )
1429  allow_bb_move[ ii ] = true;
1430  loop_map->set_bb( allow_bb_move );
1431  loop_map->set_jump( 1, false );
1432 
1433 
1434  Size loop_size = ( loop_end - loop_begin ) + 1;
1435  Size cutpoint = loop_begin + Size(loop_size/2);
1436 
1437  loops::Loop one_loop( loop_begin, loop_end, cutpoint, 0, false );
1438  simple_one_loop_fold_tree( pose_in, one_loop );
1439 
1440  // set cutpoint variants for correct chainbreak scoring
1441  if( !pose_in.residue( cutpoint ).is_upper_terminus() ) {
1442  if( !pose_in.residue( cutpoint ).has_variant_type(
1446  cutpoint );
1447  if( !pose_in.residue( cutpoint + 1 ).has_variant_type(
1451  cutpoint + 1 );
1452  }
1453 
1454 
1455 
1456  Real min_tolerance = 0.001;
1457  if( benchmark_ ) min_tolerance = 1.0;
1458  std::string min_type = std::string( "dfpmin_armijo_nonmonotone" );
1459  bool nb_list = true;
1461  lowres_scorefxn_, min_type, min_tolerance, nb_list );
1462 
1463  // more params
1464  Size n_small_moves ( numeric::max(Size(5), Size(loop_size/2)) );
1465  Size inner_cycles( loop_size );
1466  Size outer_cycles( 1 );
1468  outer_cycles = 5;
1469  if( antibody_refine_ && snug_fit_ )
1470  outer_cycles = 2;
1471  if( benchmark_ ) {
1472  n_small_moves = 1;
1473  inner_cycles = 1;
1474  outer_cycles = 1;
1475  }
1476 
1477  Real high_move_temp = 2.00;
1478  // minimize amplitude of moves if correct parameter is set
1480  high_move_temp,
1481  n_small_moves );
1483  high_move_temp,
1484  n_small_moves );
1485  small_mover->angle_max( 'H', 2.0 );
1486  small_mover->angle_max( 'E', 5.0 );
1487  small_mover->angle_max( 'L', 6.0 );
1488 
1489  shear_mover->angle_max( 'H', 2.0 );
1490  shear_mover->angle_max( 'E', 5.0 );
1491  shear_mover->angle_max( 'L', 6.0 );
1492 
1493  CcdMoverOP ccd_moves = new CcdMover( one_loop, loop_map );
1494  RepeatMoverOP ccd_cycle = new RepeatMover(ccd_moves, n_small_moves);
1495 
1496  SequenceMoverOP wiggle_cdr_h3( new SequenceMover() );
1497  wiggle_cdr_h3->add_mover( small_mover );
1498  wiggle_cdr_h3->add_mover( shear_mover );
1499  wiggle_cdr_h3->add_mover( ccd_cycle );
1500 
1501 
1502  loop_min_mover->apply( pose_in );
1503 
1504  Real const init_temp( 2.0 );
1505  Real const last_temp( 0.5 );
1506  Real const gamma = std::pow( (last_temp/init_temp), (1.0/inner_cycles));
1507  Real temperature = init_temp;
1508 
1509  MonteCarloOP mc;
1510  mc = new moves::MonteCarlo( pose_in, *lowres_scorefxn_, temperature );
1511  mc->reset( pose_in ); // monte carlo reset
1512 
1513  // outer cycle
1514  for(Size i = 1; i <= outer_cycles; i++) {
1515  mc->recover_low( pose_in );
1516 
1517  // inner cycle
1518  for ( Size j = 1; j <= inner_cycles; j++ ) {
1519  temperature *= gamma;
1520  mc->set_temperature( temperature );
1521  wiggle_cdr_h3->apply( pose_in );
1522  loop_min_mover->apply( pose_in );
1523 
1524  mc->boltzmann( pose_in );
1525 
1526  } // inner cycles
1527  } // outer cycles
1528  mc->recover_low( pose_in );
1529 
1530  // minimize
1531  if( !benchmark_ )
1532  loop_min_mover->apply( pose_in );
1533 
1534  // Restoring pose stuff
1535  pose_in.fold_tree( tree_in ); // Tree
1536 
1537  TR << "H3M Finished Centroid Relaxing Loop" << std::endl;
1538 
1539  return;
1540 } // loop_centroid_relax
1541 
1542 void
1544  pose::Pose & pose_in ) {
1545  using namespace pack::task;
1546  using namespace pack::task::operation;
1547 
1548  if( init_task_factory_ ) {
1549  tf_ = new TaskFactory( *init_task_factory_ );
1550  TR << "CDRH3Modeler Reinitializing Packer Task" << std::endl;
1551  return;
1552  }
1553  else
1554  tf_ = new TaskFactory;
1555 
1556  TR << "CDRH3Modeler Setting Up Packer Task" << std::endl;
1557 
1558  tf_->push_back( new OperateOnCertainResidues( new PreventRepackingRLT,
1559  new ResidueLacksProperty("PROTEIN") ) );
1560  tf_->push_back( new InitializeFromCommandline );
1561  tf_->push_back( new IncludeCurrent );
1562  tf_->push_back( new RestrictToRepacking );
1563  tf_->push_back( new NoRepackDisulfides );
1564 
1565  // incorporating Ian's UnboundRotamer operation.
1566  // note that nothing happens if unboundrot option is inactive!
1569  unboundrot->initialize_from_command_line();
1570  operation::AppendRotamerSetOP unboundrot_operation =
1571  new operation::AppendRotamerSet( unboundrot );
1572  tf_->push_back( unboundrot_operation );
1573  // adds scoring bonuses for the "unbound" rotamers, if any
1575 
1577 
1578  TR << "CDRH3Modeler Done: Setting Up Packer Task" << std::endl;
1579 
1580 } // setup_packer_task
1581 
1582 
1583 
1584 } // namespace antibody
1585 } // namespace protocols