Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FlexPepDockingProtocol.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 /// @file FlexPepDockingProtocol.cc
10 ///
11 /// @brief protocol for docking flexible peptides onto globular proteins
12 /// @date August 5, 2008
13 /// @author Barak Raveh / Nir London
14 
15 
25 #include <core/chemical/AA.hh>
28 // AUTO-REMOVED #include <core/chemical/VariantType.hh>
29 #include <core/fragment/FragSet.hh>
31 #include <core/io/pdb/pose_io.hh>
34 #include <basic/options/option.hh>
35 #include <basic/options/keys/in.OptionKeys.gen.hh>
36 #include <basic/options/keys/out.OptionKeys.gen.hh>
37 #include <basic/options/keys/docking.OptionKeys.gen.hh>
38 #include <basic/options/keys/loops.OptionKeys.gen.hh>
39 #include <basic/options/keys/packing.OptionKeys.gen.hh>
47 #include <core/pose/Pose.hh>
48 #include <core/pose/PDBInfo.hh>
49 // AUTO-REMOVED #include <core/pose/util.hh>
50 #include <core/scoring/rms_util.hh>
55 // note constraints are relevant for currently commented out code
56 // AUTO-REMOVED #include <core/scoring/constraints/AtomPairConstraint.hh>
61 #include <basic/prof.hh>
62 #include <basic/Tracer.hh>
63 #include <core/types.hh>
64 #include <numeric/angle.functions.hh>
65 // AUTO-REMOVED #include <protocols/simple_moves/FragmentMover.hh>
68 #include <protocols/jd2/Job.hh>
72 #include <protocols/moves/Mover.hh>
83 // AUTO-REMOVED #include <protocols/moves/PyMolMover.hh>
85 #include <utility/file/FileName.hh>
86 #include <utility/tag/Tag.hh>
87 #include <numeric/random/random.fwd.hh>
88 #include <ObjexxFCL/FArray1D.hh>
89 #include <string>
90 #include <set>
91 #include <sstream>
92 #include <cstdio>
93 #include <algorithm>
94 
95 #include <utility/vector0.hh>
96 #include <utility/vector1.hh>
97 #include <utility/excn/Exceptions.hh>
98 #include <utility/keys/Key3Vector.hh>
99 
100 
101 using basic::T;
102 using basic::Error;
103 using basic::Warning;
104 
105 static basic::Tracer TR("FlexPepDockingProtocol");
106 using namespace core;
107 using namespace ObjexxFCL;
108 
109 namespace protocols {
110  namespace flexpep_docking {
111 
112 /// constructor
113 FlexPepDockingProtocol::FlexPepDockingProtocol(Size const rb_jump_in)
114  : Mover(),
115  rb_jump_(rb_jump_in),
116  flags_(),
117  //create a metrics object
118  fpdock_metrics_(flags_.clone())
119 {
120  Mover::type( "FlexPepDockingProtocol" );
121  set_default();
122 }
123 
124 // constructor
126  Size const rb_jump_in,
127  bool const fullatom,
128  bool const view
129 ) :
130  Mover(),
131  rb_jump_(rb_jump_in),
132  flags_(),
133  fpdock_metrics_(flags_.clone())
134 {
135  Mover::type( "FlexPepDockingProtocol" );
136  set_default();
137  fullatom_ = fullatom;
138  view_ = view;
139 }
140 
141  // empty destructor - for good includiong of OP clasesses
143 {
144 }
145 
146 // cloner
148 {
149  FlexPepDockingProtocolOP clonedObj =
151  clonedObj->scorefxn_ = scorefxn_->clone();
152  clonedObj->flags_ = flags_; // TODO: is this really needed?
153  // TODO: do we need anything else?
154  return clonedObj;
155 }
156 
157 
158 
159 /// @brief setup that is called from constructor
161 {
162  using namespace basic::options;
163  using namespace core::scoring;
164  using namespace core::pack;
165  using namespace core::pack::task;
166 
167  fullatom_ = option[ OptionKeys::out::file::fullatom ](); // TODO: use flags_
168  view_ = option[ OptionKeys::docking::view ](); // TODO: use flags_, and don't use docking:: options
169  scorefxn_ = core::scoring::getScoreFunction(); // from cmd-line (-score:weights -score:patch)
171  ( CENTROID_WTS, "score4L") ; // centroid score in between chains
172 
173  //reset interface measures:
174  if_metrics_["I_sc"] = 0.0;
175  if_metrics_["I_bsa"] = 0.0;
176  if_metrics_["I_hb"] = 0.0;
177  if_metrics_["I_pack"] = 0.0;
178  if_metrics_["I_unsat"] = 0.0;
179 
180  // prepare unbound rotamer task-operation (reading from cmd-line -unboundrot)
181  // (NOTE: if -unboundrot is not active - nothing happens)
184  unboundrot_oper->initialize_from_command_line();
185  operation::AppendRotamerSetOP append_ubrot_taskoper =
186  new operation::AppendRotamerSet( unboundrot_oper );
187 
188  // all-protein packer settings:
190  allprotein_tf_->push_back( new operation::InitializeFromCommandline ); // -ex1,ex2,use_input_sc,etc.
191  allprotein_tf_->push_back( new operation::IncludeCurrent ); // TODO: since our input is a prepacked structure, I always included its side-chains (these are NOT necessarily the native side-chains). But, maybe this should be left to the user (Barak)
192  allprotein_tf_->push_back( new operation::RestrictToRepacking ); // prevents design
193  allprotein_tf_->push_back(append_ubrot_taskoper); // add support to -unboundrot
194  if( option[OptionKeys::packing::resfile].user() )
195  allprotein_tf_->push_back( new operation::ReadResfile );
196 
197  // interface packer settings:
198  interface_tf_ = new task::TaskFactory(*allprotein_tf_); // base on settings for allprotein_tf_
199  if(! flags_.pep_fold_only)
201 
203  interface_packer_->score_function( scorefxn_ );
204  interface_packer_->task_factory( interface_tf_ );
205 
208 
209  // Loop modeling options
210  // NOTE: most LoopRelax options are initiated automatically from cmd-line
211  // TODO: should refine be set to default? we want to guarantee a full-atom output
213  loop_relax_mover_->fa_scorefxn(scorefxn_); // TODO: for now we do not touch the centroid part...
214  loop_relax_mover_->remodel("no"); // remodel only in centroid part, if at all? // TODO: rethink this
215  loop_relax_mover_->relax("no"); // We don't want structure relaxation by all means // TODO: inform user
216  // we must have a full-atom output here // TODO: inform user about this
217  if(loop_relax_mover_->refine() == "no") {
218  loop_relax_mover_->refine("refine_kic");
219  }
220  if( option[ OptionKeys::loops::frag_files ].user() ) {
221  // these protocols optionally take a fragment set .. only load if
222  // specified
225  loop_relax_mover_->frag_libs( frag_libs );
226  }
227 }
228 
229 
230 
231 ///@brief setup the peptide docking fold tree
232 // jumps are created from the receptor, and then
233 // between consecutive peptide anchors:
234 void
236 {
237  using namespace std;
238  //This assert does not hold if we add ligand residues other than the protein and the peptide
239  //runtime_assert( flags_.receptor_nres() + flags_.peptide_nres()
240  // == (int)pose.total_residue());
241  ObjexxFCL::FArray1D_int cuts(1000,0); // dim1 = serial # of cut
242  ObjexxFCL::FArray2D_int jumps(2,1000,0); // dim1 = from/to ; dim2 = serial # of jump
243  std::map<int,int> const& peptide_cuts = flags_.peptide_cuts;
244  std::map<int,int> const& peptide_anchors = flags_.peptide_anchors;
245  const int JUMP_FROM = 1;
246  const int JUMP_TO = 2;
247 
248  int receptor_ncuts = 0;
249  if(! flags_.pep_fold_only){ // receptor = docking mode
250  jumps(JUMP_FROM, 1) = flags_.receptor_anchor_pos; // first jump is from receptor anchor (towards first peptide anchor, below)
251  cuts( 1 ) = flags_.receptor_last_res();
252  receptor_ncuts++;
253  }
254  std::map<int,int>::const_iterator iter;
255  for(iter = peptide_cuts.begin(); iter != peptide_cuts.end(); iter++) {
256  cuts( iter->first + receptor_ncuts ) = iter->second;
257  }
258  // add jump from each anchor to the following anchor (and from receptor, to first peptide anchor, if in docking mode)
259  int num_jumps = 0; int max_jump = 0;
260  for(iter = peptide_anchors.begin(); iter != peptide_anchors.end(); iter++) {
261  int pep_anchor_num = iter->first;
262  int residue = iter->second;
263  int cur_jump = pep_anchor_num + receptor_ncuts - 1;
264  if( cur_jump >= 1 ) { // this anchor is destination of either previous anchor (>=2), or of the receptor, if in docking mode
265  jumps(JUMP_TO, cur_jump) = residue;
266  num_jumps++;
267  }
268  jumps(JUMP_FROM, cur_jump + 1) = residue; // this anchor is src of jump to next anchor
269 
270 
271  #if (defined WIN32) && (defined WIN_PYROSETTA)
272  max_jump = max( max_jump, cur_jump );
273  #else
274  max_jump = std::max( max_jump, cur_jump );
275  #endif
276  }
277  runtime_assert_msg(max_jump == num_jumps,
278  "invalid anchor indexing in FlexPepDock parameter file (or in default FlexPepDock parameters)");
279 
280  //hack to support multiple ligands besides the peptide
281  //assumes ligand(s) is last residue in the pdb.
282  if (flags_.is_ligand_present(pose)) { // TODO: verify code validity for peptide-folding only (= no receptor)
283  core::pose::PDBInfoCOP pdbinfo = pose.pdb_info();
285  cuts ( num_jumps+1 ) = flags_.peptide_last_res();
286  Size resi = flags_.receptor_nres() + flags_.peptide_nres() + 1;
287  while (resi <= pose.total_residue()) {
288  char currChain = pdbinfo->chain(resi);
289  int ligand_jump = ++max_jump;
290  jumps(JUMP_FROM, ligand_jump) = flags_.receptor_anchor_pos; // TODO: this line is probably incompatible with pep_fold_only
291  jumps(JUMP_TO, ligand_jump) = resi;
292  num_jumps++;
293  cuts(num_jumps+1) = resi;
294  while (resi <= pose.total_residue() && pdbinfo->chain(resi) == currChain) {
295  resi++;
296  }
297  }
298  }
299  }
300 
301  // create and attach fold-tree
303  f.clear();
304  f.tree_from_jumps_and_cuts
305  ( pose.total_residue(), num_jumps, jumps, cuts );
306  TR.Debug << "old fold tree: " << pose.fold_tree() << std::endl;
307  pose.fold_tree(f);
308  TR.Debug << "new fold tree: " << pose.fold_tree() << std::endl;
309 }
310 
311 
312 
313 ////////////////////////////////////////
314 // set constraints to prevent receptor from changing too much from starting structure
315 ////////////////////////////////////////
316 void
318 {
319  using namespace core::scoring::constraints;
320  using namespace core::chemical;
321  using namespace core::conformation;
322  using namespace core::id;
323  using namespace core::scoring;
324 
325  ConstraintSetOP cst_set( new ConstraintSet() );
326  HarmonicFuncOP spring = new HarmonicFunc( 0 /*mean*/, 1 /*std-dev*/);
327  conformation::Conformation const & conformation( pose.conformation() );
328  for (int i=flags_.receptor_first_res();
329  i <= flags_.receptor_last_res(); i++)
330  {
331  // Residue const & reside = pose.residue( i );
332  AtomID CAi ( pose.residue(i).atom_index( " CA " ), i );
333  cst_set->add_constraint
335  ( CAi, CAi, conformation.xyz( CAi ), spring )
336  );
337  }
338  pose.constraint_set( cst_set );
339  scorefxn_->set_weight(coordinate_constraint, 1.0);
340 }
341 
342 
343 /////////////////////////////////////////
344 // Set movemaps for optimization
345 // assumes the flags were filled with the pose
346 // length, so should be invoked only after apply()
347 //
348 // if cmd-line -in:file:movemap is used, overrides movemap
349 // position explicitly set by the user (see MoveMap::init_from_file()
350 // for more information)
351 /////////////////////////////////////////
352 void
354 {
355  using namespace basic::options;
356 
357  // rb + all sc torsions + peptide bb)
358  movemap_->set_bb_true_range(
361  movemap_->set_chi(true);
362 
363  // rigid-body
364  movemap_->set_jump(false);
365  movemap_->set_jump( rb_jump_, true );
366 
367  // minimizer may also allow receptor bb to move
368  movemap_minimizer_=movemap_->clone();
370  for (int i=flags_.receptor_first_res();
371  i <= flags_.receptor_last_res(); i++){
372  movemap_minimizer_->set_bb(i, true);
373  }
374  }
375 
376  // overrides movemaps at user custom positions
377  if( option[OptionKeys::in::file::movemap].user() ) {
378  movemap_->init_from_file( option[OptionKeys::in::file::movemap] );
379  movemap_minimizer_->init_from_file( option[OptionKeys::in::file::movemap] );
380  }
381 
382 }
383 
384 
385 /////////////////////////////////////////
386 // Minimize_only function. to use if the
387 // user raised the flexPepDockMinimizeOnly
388 // flag
389 /////////////////////////////////////////
390 void
392  core::pose::Pose & pose,
393  const std::string & min_type,
394  const float min_func_tol
395 )
396 {
397  protocols::simple_moves::MinMover minimizer(movemap_minimizer_, scorefxn_, min_type, min_func_tol, true /*nb_list*/ );
398  minimizer.apply(pose);
399 }
400 
401 
402 ////////////////////////////////////////////////////////////////////////////////
403 /// @begin create and apply prepack mover
404 ///
405 /// @brief prepack protocol for flexpepdock
406 // (0) minimize all side-chains + peptide b.b., just to get a reference to best possible energy
407 // (i) translate apart (by 1000A)
408 // (ii) repack + minimize side-chains of protein
409 // (iii) translate back (by 1000A)
410 ///
411 // @detailed
412 // Prepacking a docked structure
413 //
414 // @param
415 // pose - the pose to prepack
416 // ppk_receptor - whether to prepack the receptor protein
417 // ppk_peptide - whether to prepack the lignad peptide
418 void
420  pose::Pose & pose, bool ppk_receptor, bool ppk_peptide
421 )
422 {
423  using namespace moves;
424  using namespace basic::options;
425  using namespace std;
426  using namespace core::pack;
427 
428  // set up dofs: all side-chain DOFs except S-S bonds
430  mm_protein->clear();
431  int const receptor_nres = flags_.receptor_nres();
432  core::Size pack_start = (ppk_receptor) ? 1 : receptor_nres+1;
433  core::Size pack_end = (ppk_peptide) ? pose.total_residue() : receptor_nres;
434  for ( core::Size i = pack_start; i <= pack_end; ++i) {
435  mm_protein->set_chi(i, true);
436  }
437  // set up packer
439  task = pack::task::TaskFactory::create_packer_task( pose );
440  task->initialize_from_command_line().restrict_to_repacking();//flags+no-design
442  noRepackDisulf.apply(pose, *task);
443  // allow packing only in the range [pack_start..pack_end]
444  for(core::Size resid = 1; resid < pack_start; resid++)
445  {task->nonconst_residue_task(resid).prevent_repacking();}
446  for(core::Size resid = pack_end+1; resid <= pose.total_residue() ; resid++)
447  {task->nonconst_residue_task(resid).prevent_repacking();}
448  // support cmd-line option for unbound rotamers
451  unboundrot_oper->initialize_from_command_line();
452  task->append_rotamerset_operation( unboundrot_oper );
454 
455  // set up min mover to pre-minimize the side chains + backbone // TODO: 1e-5 - is this a good threshold? optimize this
456  protocols::simple_moves::MinMoverOP min_mover( new protocols::simple_moves::MinMover(mm_protein, scorefxn_, "dfpmin_armijo_nonmonotone", 1e-5, true/*nblist*/, false/*deriv_check*/ ) );
457 
458  //set up translate-by-axis movers
459  Real trans_magnitude = 1000;
460  rigid::RigidBodyTransMoverOP translate_away ( new rigid::RigidBodyTransMover( pose, rb_jump_ ) );
461  translate_away->step_size( trans_magnitude );
462  rigid::RigidBodyTransMoverOP translate_back ( new rigid::RigidBodyTransMover( pose, rb_jump_ ) );
463  translate_back->step_size( trans_magnitude );
464  translate_back->trans_axis().negate();
465 
466  // print energy for repack + minimization of original complex, just as a reference
467  core::pose::Pose orig_pose( pose );
468  min_mover->apply(pose);
469  TR.Debug << "Initial score: " << (*scorefxn_)(orig_pose) << endl;
470  TR.Debug << "minimized score = " << (*scorefxn_)(pose) << endl;
471  pose = orig_pose; // restore
472 
473  // run pre-pack protocol
474  if(! flags_.pep_fold_only)
475  translate_away->apply(pose);
476  prepack_protein->apply(pose);
477  min_mover->movemap(mm_protein); // only s.c.
478  min_mover->apply(pose); // only s.c.
479  if(! flags_.pep_fold_only)
480  translate_back->apply(pose);
481 }
482 
483 
484 /////////////////////////////////////////
485 // randomly perturb phi-psi of peptide to
486 // a given range. *also assumes params ia read
487 /////////////////////////////////////////
488 void
490  core::pose::Pose & pose
491 )
492 {
493  using namespace std;
494  using namespace numeric;
495 
496  double pertSize = flags_.random_phi_psi_pert_size;
497 
498  for (int i=flags_.peptide_first_res();
500  double phi_offset = numeric::random::uniform()*(pertSize)*2 - pertSize;
501  double psi_offset = numeric::random::uniform()*(pertSize)*2 - pertSize;
502  double new_phi = principal_angle_degrees( pose.phi(i) + phi_offset );
503  double new_psi = principal_angle_degrees( pose.psi(i) + psi_offset );
504  pose.set_phi(i,new_phi);
505  pose.set_psi(i,new_psi);
506  }
507 }
508 
509 
510 /////////////////////////////////////////
511 // extend peptide setting all phi/psi to
512 // +- 135 deg. assumes peptide dofs were defined.
513 /////////////////////////////////////////
514 void
516  core::pose::Pose & pose
517 )
518 {
519  using namespace std;
520  using namespace numeric;
521 
522  for (int i=flags_.peptide_first_res();
524  pose.set_phi(i,-135);
525  pose.set_psi(i,135);
526  }
527 }
528 
529 
530 /////////////////////////////////////////
531 void
533  core::pose::Pose & pose
534 )
535 {
536  using namespace std;
537  using namespace moves;
538 
539  float current_score = (*scorefxn_)( pose );
540  float new_score;
541  core::pose::Pose tmpPose;
542  // TODO: sepearate rotation and translation flags
544  rb_jump_ /*jump_num*/,
545  flags_.rb_rot_size /*rot*/,
546  flags_.rb_trans_size /*trans*/ );
547  do {
548  tmpPose = pose;
549  rb_mover->apply(tmpPose);
550  new_score = (*scorefxn_)( tmpPose );
551  } while ((new_score-current_score) > 3000);
552  pose = tmpPose;
553 }
554 
555 
556 /////////////////////////////////////////
557 // perform small moves on the peptide
558 /////////////////////////////////////////
559 void
561  core::pose::Pose & pose
562 )
563 {
564  using namespace std;
565  using namespace core::pose;
566  using namespace protocols;
567 
568  simple_moves::SmallMoverOP small_mover( new simple_moves::SmallMover( movemap_, 0.8 /*temp*/, 100 /*nmoves ???*/ ) );
569  small_mover->angle_max('L',flags_.smove_angle_range);
570  small_mover->apply(pose);
571 
572 }
573 
574 
575 /////////////////////////////////////////
576 // perform sheer moves on the peptide
577 /////////////////////////////////////////
578 void
580  core::pose::Pose & pose
581 )
582 {
583  using namespace std;
584  using namespace core::pose;
585  using namespace protocols;
586 
587  simple_moves::ShearMoverOP shear_mover( new simple_moves::ShearMover( movemap_, 0.8 /*temp*/, 100 /*nmoves ???*/ ) );
588  shear_mover->angle_max('L',flags_.smove_angle_range);
589  shear_mover->apply(pose);
590 
591 }
592 
593 
594 /////////////////////////////////////////
595 // backrub the peptide
596 /////////////////////////////////////////
597 void
599  core::pose::Pose & pose
600 )
601 {
602  using namespace std;
603  using namespace core::pose;
604  using namespace protocols;
605 
606  // set up the BackrubMover
608  // read known and unknown optimization parameters from the database
609  // ? backrubmover.branchopt().read_database();
610  backrubmover.clear_segments();
611  backrubmover.set_input_pose(&pose);
612 
613  // determine list of residues to backrub
615  for (int i=flags_.peptide_first_res();
617  resnums.push_back(i);
618 
619  // add segments to the backrub mover
620  backrubmover.add_mainchain_segments(resnums, utility::vector1<std::string>(1, "CA"), 3 , 34 );
621  //values adaptd from bacrub.cc
622  TR << "backrub: added mainchain segments" << endl;
623  // ? backrubmover.optimize_branch_angles(pose);
624  backrubmover.apply(pose);
625  TR << "backrub: applied" << endl;
626 }
627 
628 
629 /////////////////////////////////////////
630 // change sequence of peptide to polyAla
631 /////////////////////////////////////////
632 void
634  core::pose::Pose & pose
635 )
636 {
637  using namespace std;
638  using namespace core::pose;
639  using namespace protocols;
640  using namespace core::conformation;
641  using namespace core::chemical;
642 
643  ResidueTypeSetCAP residue_set( ChemicalManager::get_instance()->residue_type_set( "fa_standard" ) );
644  // ResidueTypeSet const & residue_set ( pose.residue(1).residue_type_set() );
645  ResidueType const & restype( residue_set->name_map( "ALA" ) );
646  ResidueOP ala;
647  for (int i=flags_.peptide_first_res();
649  ala = ResidueFactory::create_residue(restype);// ,pose.residue(i),pose.conformation(),true/*preserve CB*/);
650  pose.replace_residue(i,*ala,true);
651  }
652 }
653 
654 /////////////////////////////////////////
655 // TODO: think about filters in the future - make more serious decisions
656 // on how to use them
657 // check if the given pose passes the filters imposed by the cmd line
658 /////////////////////////////////////////
659 bool
661  using namespace std;
662  bool passed = true;
663  //if no filters were turned on during the run filters are passed
664  if (flags_.score_filter!=10000) { // TODO: make good indication of whether the user specified score_filter (requires some changes into flags_ infrastructure, in order to use basic::options::user()
665  TR << "Applying score filter " << flags_.score_filter << endl;
666  passed = ((*scorefxn_)(pose) < flags_.score_filter);
667  }
668  if (flags_.hb_filter!=0) {
669  //TODO calc HB number: passed = passed && hb
670  }
671  if (flags_.hotspot_filter!=0) {
672  //TODO calc number of hotspots: passed = passed && hotspots
673  }
674 
675  return passed;
676 }
677 
678 /////////////////////////////////////////
679 // Randomly move peptides cutpoint in
680 // order to not bias the sampling
681 // of torsion angles.
682 /////////////////////////////////////////
683 void
685 
686  using namespace core::kinematics;
687  using namespace numeric;
688  Size new_rand_cut = (Size)(numeric::random::uniform()*(flags_.peptide_nres()));
689  FoldTree f = pose.fold_tree();
690  f.slide_jump(rb_jump_, //along which jump
691  f.upstream_jump_residue(rb_jump_),//keep prot anchor
692  flags_.peptide_first_res() + new_rand_cut ); //change pep cutpoint
693  TR << "Moved peptide cutpoint to " << flags_.peptide_first_res() + new_rand_cut << std::endl;
694 }
695 
696 
697 /////////////////////////////////////////
698 // torsions (small/shear) MCM
699 /////////////////////////////////////////
700 void
702  core::pose::Pose & pose,
703  const int cycles,
704  const std::string & min_type,
705  const float minimization_threshold,
706  const float min_func_tol
707 )
708 {
709  using namespace std;
710  using namespace core::pose;
711  using namespace core::kinematics;
712  using namespace moves;
713 
714  // create a monte_carlo object
715  const float temperature ( 0.8 ); // TODO: tune param
716  moves::MonteCarloOP mc ( new moves::MonteCarlo (pose, *scorefxn_,temperature));
717  int n_accepted = 0; // diagnostic counter
718  const float rt_energycut = 0.05; // TODO: tune param
719 
722  protocols::simple_moves::MinMover minimizer(movemap_minimizer_, scorefxn_, min_type, min_func_tol, true /*nb_list*/ );
723 
724  // start the minimization
725  for( int i=1; i<=cycles; ++i ) {
726 
727  if ( i % 2 == 0) {
728  small_moves(pose);
729  }
730  else {
731  shear_moves(pose);
732  }
733  if ( i % 8 == 0 || i == cycles) {
734  interface_packer_->apply( pose );
735  } else {
736  //rotamer_trials, but for the whole protein
737  rottrial_ecut.apply(pose); // allow non-interface residues as well?
738  }
739  const float current_score = (*scorefxn_)( pose );
740  const float lowest_score = mc->lowest_score();
741  if ( current_score - lowest_score < minimization_threshold ) {
742  minimizer.apply(pose);
743  }
744  const bool accepted = mc->boltzmann( pose );
745  if( accepted ) {
746  ++n_accepted;
747  }
748  }
749  TR.Debug << "torsion-MCM --" << n_accepted << " out of " << cycles
750  << " monte carlo cycles accepted" << endl;
751  pose = mc->lowest_score_pose();
752 }
753 
754 ////////////////////////////////////////////////////////////////////////////
755 //
756 // @brief
757 // Rigid body optimization session using Monte-Carlo with Energy Minimization
758 //
759 // @param pose[in,out] Pose to be optimized
760 // @param cycles[in] Number of MCM cycles
761 // @param min_type[in] Type of energy minimization method
762 // @param trans_magnitude[in] Translation magnitude in each perturbation
763 // (Angstroms)
764 // @param rot_magnitude[in] Rotation magnitude in each perturbation
765 // (Degrees)
766 // @param minimization_threshold Minimize only structures that "stand a chance" - energy > best.energy + min_thresh // TODO: do we want this filter? How much running time does it save?
767 //
768 ////////////////////////////////////////////////////////////////////////////
769 void
771  core::pose::Pose & pose,
772  const int cycles,
773  const std::string & min_type,
774  const float trans_magnitude,
775  const float rot_magnitude,
776  const float minimization_threshold,
777  const float min_func_tol
778 )
779 {
780  using namespace std;
781  using namespace core::pose;
782  using namespace core::kinematics;
783  using namespace moves;
784 
785  // create a monte_carlo object
786  const float temperature ( 0.8 ); // TODO: tune param
787  moves::MonteCarloOP mc ( new moves::MonteCarlo (pose, *scorefxn_,temperature));
788  int n_accepted = 0; // diagnostic counter
789  const float rt_energycut = 0.05; // TODO: tune param
790 
792  rb_jump_, rot_magnitude, trans_magnitude );
797  movemap_minimizer_, scorefxn_, min_type, min_func_tol, true /*nb_list*/ );
798 
799  // start the minimization
800  for( int i=1; i<=cycles; ++i ) {
801  rb_mover.apply(pose);
802  if ( i % 8 == 0 || i == cycles) { // tune param 8
803  interface_packer_->apply( pose );
804  } else {
805  //rotamer_trials but for the whole protein
806  rottrial_ecut.apply(pose);
807  }
808  const float current_score = (*scorefxn_)( pose );
809  const float lowest_score = mc->lowest_score();
810  if ( current_score - lowest_score < minimization_threshold ) {
811  minimizer.apply(pose);
812  }
813  const bool accepted = mc->boltzmann( pose );
814  if( accepted ) {
815  ++n_accepted;
816  }
817  }
818  TR.Debug << "rigid-body-MCM --" << n_accepted << " out of " << cycles
819  << " monte carlo cycles accepted" << endl;
820  pose = mc->lowest_score_pose();
821 }
822 
823 
824 ////////////////////////////////////////////////////////////////////////////
825 //
826 // @brief
827 // Take a radnom subset of the peptide and send to loop modeling
828 // TODO: add this to centroid mode optimization as well?
829 //
830 // @param pose[in,out] Pose to be optimized
831 //
832 ////////////////////////////////////////////////////////////////////////////
833 void
835  core::pose::Pose & pose
836 )
837 {
838  if(flags_.peptide_nres() < 5) // TODO: 3 is minimum for KIC loop closure, and flanks should be excluded
839  return;
840  // set up and model a random loop
841  Size first_res = flags_.peptide_first_res(); // TODO: make sure it is ok to use the N' residue
842  Size last_res = flags_.peptide_last_res() - 1; // TODO: add the C' terminal, Dan sais there might be a bug with C' followed by another chain
844  loops->add_loop(first_res, last_res); // TODO: cut defaults to zero, is this a random cut?
845  for(Size i = first_res; i <= last_res ; i++)
846  runtime_assert( movemap_->get_bb(i) ); // verify loop is movable, this should have been always true for the peptide
847  loop_relax_mover_->loops( loops );
848  loop_relax_mover_->apply( pose );
849 }
850 
851 
852 
853 //////////////////////////////////////////////////////////////////////////////////
854 // @brief
855 // The high-resolution protocol for docking a flexible peptide
856 // onto a globular protein
857 //
858 // @param pose[in,out] an input pose conformation to be optimized
859 void
861 {
862  using namespace core::scoring;
863  using namespace moves;
865  using namespace std;
866 
867  core::scoring::ScoreFunctionOP orig_scorefxn = scorefxn_->clone();
868 
869  float rb_trans_mag = 0.2; // in angstroms. more repulsion = less perturb.
870  float rb_rot_mag = 7 ; // in degrees.
871  // params for ramping of fa_rep / fa_atr / rama scores:
872  int rep_ramp_cycles = flags_.rep_ramp_cycles;
873  float origw_fa_atr = scorefxn_->get_weight( fa_atr );
874  float origw_fa_rep = scorefxn_->get_weight( fa_rep );
875  float origw_rama = scorefxn_->get_weight( rama );
876  float rep_ramp_step = ( origw_fa_rep - 0.02 ) / float(rep_ramp_cycles-1) ;
877  float rama_ramp_step = (origw_rama - 0.01) / float(rep_ramp_cycles-1) ;
878 
879  // design operation settings:
882  if(! flags_.pep_fold_only)
883  {
886  receptor_protector_oper_->clear();
887  for(int i = flags_.receptor_first_res();
888  i <= flags_.receptor_last_res(); ++i){
889  receptor_protector_oper_->include_residue(i);
890  }
891  design_tf->push_back(receptor_protector_oper_);
892  design_mover_->task_factory(design_tf);
893  TR << "Disabling receptor design" << endl;
894  }
895  }
896 
897  // start protocol:
898  interface_packer_->apply( pose ); // initial sidechains repack
899  for ( int i = 1; i <= rep_ramp_cycles; i++ )
900  {
901  //randomlySlidePeptideJump(pose);
902  if (flags_.boost_fa_atr){ // ramping fa_atr
903  scorefxn_->set_weight
904  ( fa_atr, origw_fa_atr*(1 + 0.25*(rep_ramp_cycles-i) ) );
905  }
906  if (flags_.ramp_fa_rep) { // ramping fa_rep
907  float rep_weight = (0.02 + rep_ramp_step * float(i-1));
908  scorefxn_->set_weight( fa_rep, rep_weight );
909  }
910  // from soft to strong rama
911  if (flags_.ramp_rama) { // ramping rama
912  float rama_weight = (0.01 + rama_ramp_step * float(i-1));
913  scorefxn_->set_weight( rama, rama_weight );
914  }
915  if (flags_.design_peptide) {
916  TR.Debug << "Sequence - Before design: " << pose.sequence() << endl;
917  TR.Debug << "Peptide sequence: " << pose.chain_sequence(2) << endl;
918  TR.Debug << "Designing " << i << endl;
919  design_mover_->apply( pose );
920  TR.Debug << "Sequence - After design: " << pose.sequence() << endl;
921  TR.Debug << "Peptide sequence: " << pose.chain_sequence(2) << endl;
922  }
923  if ( flags_.rbMCM && ! flags_.pep_fold_only ) {
925  pose, flags_.mcm_cycles , "dfpmin_armijo_atol", /* TODO: switch to dfpmin_armijo_nonmonotone_atol, or by flag*/
926  rb_trans_mag, rb_rot_mag,
927  15.0/*min_thresh*/, 1.0 /*tolerance*/ );
928  }
929  if (flags_.torsionsMCM) {
931  pose, flags_.mcm_cycles ,
932  "dfpmin_armijo_atol", 15.0/*min_thresh*/, /* TODO: switch to dfpmin_armijo_nonmonotone_atol, or by flag */
933  1.0 /*tolerance*/ ); // tolerance of 0.1?
934  }
937  }
938  } // end of ramping cycles
939  scorefxn_ = orig_scorefxn->clone(); // restore (note that this removes the coordinate constraints weight set above)
940 
941  // final minimization, with stringent tolerance
942  protocols::simple_moves::MinMover minimizer(movemap_minimizer_, scorefxn_, "dfpmin_armijo_atol", 0.001, true /*nb_list*/ );
943  minimizer.apply(pose);
944  // final scoring, w/o constraints for receptor backbone
946  scorefxn_->set_weight( coordinate_constraint, 0.0 ); // TODO: if the user supplied more coordinate constraints from cmd-line, this will bug the final score
947  (*scorefxn_)(pose);
948 
949 }
950 
951 
952 
953 ////////////////////////////////////////////////////////////////////////////////
954 /// @begin FlexPepDocking apply
955 ///
956 /// @brief main flexible peptide docking protocol
957 ///
958 /// @detailed
959 /// Main function for peptide docking. Includes the following steps:
960 /// 1) Optional centroid mode docking, with alternating MCM
961 /// cycles of rigid-body movement and peptide torsion relaxation
962 /// 2) High-resolution peptide docking, with alternating MCM
963 /// cycles of rigid-body movement and peptide torsion relaxation
964 /// with side-chain repacking on-the-fly
965 // OR:
966 /// Prepack mode: prepare a starting structure for later runs
967 /// OR:
968 /// Score only mode
969 // OR:
970 /// Minimize only mode
971 ///
972 /// IMPORTANT NOTE:
973 /// Apply should not change the internal state of this object
974 /// in a way that will affect the behaviour of subsequent apply() invocations
975 /// (because, e.g., the job distributor may invoke apply()
976 /// for multiple decoys, using the same mover object)
977 void
979 {
980  using namespace scoring;
981  using namespace viewer;
982  using namespace std;
983 
984  TR <<"apply" << std::endl;
985  // if no native provided, use pose as pseudo-native reference
986  if( get_native_pose().get() == NULL ){
987  set_native_pose( new pose::Pose(pose) ); // TODO: debug this - will it work for PoseCOP;
988  TR.Warning << "WARNING: No native supplied by used - using starting structure as reference for statistics" << std::endl;
989  }
990 
991  // protocols::moves::AddPyMolObserver(pose);
992  flags_.updateChains(pose); // validate chain boundaries and letters
993  if(!flags_.valid_anchors())
995  this->setup_foldtree( pose );
996  fpdock_metrics_.set_flags(flags_.clone()); // TODO: a somewhat ugly hack
997  // TODO: is it proper that an apply() method alters the fold-tree of a pose?
998  //should we restore the old fold tree after the run?
999  if ( view_ ) {
1001  ( pose.conformation(), "start_pose", 450, 450 , true);
1002  }
1003 
1004  // initial manupulation
1005  pose::Pose start_pose_4stats;
1008  } else {
1009  start_pose_4stats = pose;
1010  }
1011  pose::Pose pose_after_lowres = pose;
1012  set_allowed_moves(); //set the allowed dofs in the system
1015  if(flags_.min_receptor_bb) {
1017  }
1018 
1019  // initial peptide manipulations
1022  }
1023  if (flags_.extend) {
1024  extend_peptide(pose);
1025  }
1026  if (flags_.randomRBstart) {
1027  random_rb_pert(pose);
1028  }
1029  if (flags_.backrub_opt) {
1030  TR << "doing backrub! " << std::endl;
1031  backrub_move(pose);
1032  }
1033 
1034  // Mutually exclusive protocols:
1035  if (flags_.ppk_only) {
1036  prepack_only(pose, !flags_.no_prepack1/*ppk_receptor*/, !flags_.no_prepack2/*ppk_peptide*/);
1037  }
1038  else if(flags_.min_only){
1039  minimize_only(pose,"dfpmin_armijo_atol", 0.01/*tolerance*/);
1040  // core::io::pdb::traced_dump_pdb(TR, pose, "./output/minimized.pdb"); // DEBUG
1041  }
1042  // Main protocol:
1044  bool passed_filter = false;
1045  core::pose::Pose current_pose = pose;
1046  while (!passed_filter) {
1047  if(flags_.lowres_abinitio){
1048  FlexPepDockingAbInitio abinitioDocking
1050  abinitioDocking.apply(pose);
1051  pose_after_lowres = pose;
1052  }
1054  FlexPepDockingLowRes lowresDocking
1056  lowresDocking.apply(pose);
1057  // pack peptide since backbone may have changed
1058  prepack_only(pose, false/*ppk_receptor*/, true/*ppk_peptide*/);
1059  pose_after_lowres = pose;
1060  }
1063  //Insert cst from cmd-line - uses these flags to operate:
1064  //option[ OptionKeys::constraints::cst_fa_file ].user()
1065  //option[ OptionKeys::constraints::cst_fa_weight ].user()
1066  // weight is applied to:
1067  // atom_pair_constraint, angle_constraint, dihedral_constraint, coordinate_constraint.
1068  hires_fpdock_protocol(pose);
1069  }
1070  if(! flags_.pep_fold_only){
1072  }
1073  passed_filter = check_filters(pose);
1074  if (!passed_filter) {
1075  pose = current_pose;
1076  TR << "Failed filters - trying again" << std::endl; // TODO: make it try again
1077  }
1078  }
1079  }
1080  // output statistics:
1081  storeJobStatistics(start_pose_4stats, pose_after_lowres, pose);
1082  basic::prof_show();
1083 } // END: FlexPepDockingProtocol::apply
1084 
1085 
1088  return "FlexPepDockingProtocol";
1089 }
1090 
1091 
1092 //////////////////////////////////////////////////////////////////////////////////
1093 // @brief mark the peptide residues in the native structure interface
1094 // If no receptor - trivially mark all residues
1095 //
1096 // @param superpos_partner[out]
1097 // An array of positions - set to true for peptide residues
1098 // @param native_interface_residues[out]
1099 // An array of positions - set to true for interface peptide residues
1100 void
1102 ( ObjexxFCL::FArray1D_bool& superpos_partner,
1103  ObjexxFCL::FArray1D_bool& native_interface_residues) const
1104 {
1105  pose::Pose native_pose;
1106  protocols::scoring::InterfaceOP native_interface;
1107  native_pose=*get_native_pose();
1108  // find interface
1109  if(! flags_.pep_fold_only) // docking mode
1110  {
1111  native_interface
1113  native_interface->distance(8); // between CB atoms, CA for Gly (to be precise, the anchor atom is set within the mini DB)
1114  native_pose.update_residue_neighbors();
1115  native_interface->calculate( native_pose );
1116  }
1117  // mark interface and peptide residues
1118  for (int i=flags_.peptide_first_res();
1119  i <= flags_.peptide_last_res(); i++)
1120  {
1121  superpos_partner(i)=true;
1122  if( flags_.pep_fold_only) { // not docking mode
1123  native_interface_residues(i) = true;
1124  }
1125  else if (native_interface->is_interface(i)) // docking mode + interface res
1126  {
1127  TR.Debug << "Peptide residue " << i-flags_.peptide_first_res()+1
1128  << " in interface" << std::endl;
1129  native_interface_residues(i)=true;
1130  }
1131  }
1132 }
1133 
1134 void
1136 ( core::pose::Pose const& start_pose,
1137  core::pose::Pose& pose_after_lowres ) const
1138 {
1139  using namespace scoring;
1141 
1142  if(!get_native_pose())
1143  {
1144  TR.Warning << "WARNING: missing '-native' flag, skipping statistics on RMSD to native" << std::endl;
1145  return;
1146  }
1147 
1148  // Score statistics are added to current job
1149  protocols::jd2::JobOP cur_job( JobDistributor::get_instance()->current_job() );
1150  // switch residue set to centroid if necessary
1152  to_centroid_mover( core::chemical::CENTROID );
1153  pose::Pose start_pose_CEN = start_pose;
1154  pose::Pose pose_after_lowres_CEN = pose_after_lowres;
1155  pose::Pose native_CEN = *get_native_pose();
1156  if(start_pose_CEN.is_fullatom()) { // TODO: actually the if is not necessary
1157  to_centroid_mover.apply(start_pose_CEN);
1158  }
1159  if(pose_after_lowres_CEN.is_fullatom()) {
1160  to_centroid_mover.apply(pose_after_lowres_CEN);
1161  }
1162  if(native_CEN.is_fullatom()) {
1163  to_centroid_mover.apply(native_CEN);
1164  }
1165  // add score statistics
1166  cur_job->add_string_real_pair( "score_lowres_start",
1167  (*scorefxn_lowres_)(start_pose_CEN) );
1168  cur_job->add_string_real_pair( "score_lowres_opt",
1169  (*scorefxn_lowres_)(pose_after_lowres_CEN) );
1170  // mark peptide residues and interface (computed from native)
1171  FArray1D_bool superpos_partner ( native_CEN.total_residue(), false );
1172  FArray1D_bool native_interface_residues ( native_CEN.total_residue(), false );
1173  markNativeInterface(superpos_partner, native_interface_residues);
1174  // add all peptide RMSD:
1178  cur_job->add_string_real_pair( "rmsCA_lowres",
1179  rmsd_no_super_subset( native_CEN, pose_after_lowres_CEN, superpos_partner, is_protein_CA ) );
1180  cur_job->add_string_real_pair( "rmsBB_lowres",
1181  rmsd_no_super_subset( native_CEN, pose_after_lowres_CEN, superpos_partner, is_protein_backbone ) );
1182  // add peptide interface-only RMSD:
1183  cur_job->add_string_real_pair( "rmsCA_intrf_lowres",
1184  rmsd_no_super_subset( native_CEN, pose_after_lowres_CEN, native_interface_residues, is_protein_CA ) );
1185  cur_job->add_string_real_pair( "rmsBB_intrf_lowres",
1186  rmsd_no_super_subset( native_CEN, pose_after_lowres_CEN, native_interface_residues, is_protein_backbone ) );
1187 }
1188 
1189 
1190 //////////////////////////////////////////////////////////////////////////////////
1191 // @brief
1192 // make statistics comparing the start pose, the final pose and the native
1193 // and updated final_pose with statistics
1194 //
1195 // @param[in] start_pose - the initial pose sent to this->apply()
1196 // @param[in,out] final_pose - the final pose optimized by this->apply()
1197 //
1198 void
1200 ( pose::Pose const& start_pose,
1201  pose::Pose& pose_after_lowres,
1202  pose::Pose& final_pose )
1203 {
1204  using namespace scoring;
1206 
1207  // Score statistics are added to current job
1208  protocols::jd2::JobOP cur_job( JobDistributor::get_instance()->current_job() );
1209  // interface_metrics for docking mode:
1210  if(! flags_.pep_fold_only) {
1211  if_metrics_ = fpdock_metrics_.calc_interface_metrics(final_pose,rb_jump_,scorefxn_); // if score only this would be performed only once
1212  cur_job->add_string_real_pair( "I_sc", if_metrics_.find("I_sc")->second );
1213  cur_job->add_string_real_pair( "I_bsa", if_metrics_.find("I_bsa")->second );
1214  cur_job->add_string_real_pair( "I_hb", if_metrics_.find("I_hb")->second );
1215  cur_job->add_string_real_pair( "I_pack", if_metrics_.find("I_pack")->second );
1216  cur_job->add_string_real_pair( "I_unsat", if_metrics_.find("I_unsat")->second );
1217  }
1218 
1219  // peptide scores with / without reference energy
1220  Real pepScore, pepScore_noref, totalScore;
1221  totalScore = (*scorefxn_)(final_pose); // making sure energies are up-to-date
1222  fpdock_metrics_.calc_pep_scores(final_pose, pepScore, pepScore_noref);
1223  cur_job->add_string_real_pair( "pep_sc", pepScore );
1224  cur_job->add_string_real_pair( "pep_sc_noref", pepScore_noref );
1225 
1226  // reweighted score (total score + interface score + peptide score)
1227  cur_job->add_string_real_pair( "reweighted_sc", totalScore + pepScore + if_metrics_.find("I_sc")->second );
1228 
1229  // Comparisons to native metrics:
1230  if(!get_native_pose()) {
1231  TR.Warning << "WARNING: missing '-native' flag, skipping statistics on RMSD to native" << std::endl;
1232  return;
1233  }
1234  // calculate and store the rms of the starting structure to the native
1235  pose::Pose native_pose( *get_native_pose() );
1236  FArray1D_bool superpos_partner ( native_pose.total_residue(), false );
1237  FArray1D_bool native_interface_residues ( native_pose.total_residue(), false );
1238  markNativeInterface(superpos_partner, native_interface_residues);
1239 
1240 
1241 
1242  // start pose statistics:
1247  cur_job->add_string_real_pair( "startRMSca",
1248  rmsd_no_super_subset( native_pose, start_pose, superpos_partner, is_protein_CA ) );
1249  cur_job->add_string_real_pair( "startRMSbb",
1250  rmsd_no_super_subset( native_pose, start_pose, superpos_partner, is_protein_backbone ) );
1251  cur_job->add_string_real_pair( "startRMSall",
1252  rmsd_no_super_subset( native_pose, start_pose, superpos_partner, is_polymer_heavyatom ) );
1253  cur_job->add_string_real_pair( "startRMSallif",
1254  rmsd_no_super_subset( native_pose, start_pose, native_interface_residues, is_polymer_heavyatom ) );
1255 
1256  // final pose statistics - all peptide residues:
1257  cur_job->add_string_real_pair( "rmsCA",
1258  rmsd_no_super_subset( native_pose, final_pose, superpos_partner, is_protein_CA ) );
1259  cur_job->add_string_real_pair( "rmsBB",
1260  rmsd_no_super_subset( native_pose, final_pose, superpos_partner, is_protein_backbone ) );
1261  if (! flags_.design_peptide ) {
1262  cur_job->add_string_real_pair( "rmsALL",
1263  rmsd_no_super_subset( native_pose, final_pose, superpos_partner, is_polymer_heavyatom ) );
1264  }
1265  else {
1266  cur_job->add_string_real_pair( "rmsALL", -1.0 ); // invalid RMS on all atoms in design mode
1267  }
1268  // final pose statistics - peptide interface residues only:
1269  cur_job->add_string_real_pair( "rmsCA_if",
1270  rmsd_no_super_subset( native_pose, final_pose, native_interface_residues, is_protein_CA ) );
1271  cur_job->add_string_real_pair( "rmsBB_if",
1272  rmsd_no_super_subset( native_pose, final_pose, native_interface_residues, is_protein_backbone ) );
1273  if(! flags_.design_peptide){
1274  cur_job->add_string_real_pair( "rmsALL_if",
1275  rmsd_no_super_subset( native_pose, final_pose, native_interface_residues, is_polymer_heavyatom ) );
1276  }
1277  else {
1278  cur_job->add_string_real_pair( "rmsALL_if", -1.0 ); // invalid RMS on all atoms in design mode
1279  }
1280 
1281  if(flags_.score_only)
1282  {
1283  if(!flags_.pep_fold_only){
1284  //fraction of native contacts
1285  cur_job->add_string_real_pair( "fnat5",
1286  fpdock_metrics_.calc_frac_native_contacts(native_pose, final_pose, 5.0 /*RMS threashold*/) );
1287  cur_job->add_string_real_pair( "fnat3.5",
1288  fpdock_metrics_.calc_frac_native_contacts(native_pose, final_pose, 3.5 /*RMS threashold*/) );
1289  }
1290  // torsion RMS data
1291  cur_job->add_string_real_pair( "startRMSphipsi",
1292  fpdock_metrics_.calc_phipsi_RMSD( native_pose, start_pose, superpos_partner) );
1293  cur_job->add_string_real_pair( "startRMSphipsi_if",
1294  fpdock_metrics_.calc_phipsi_RMSD( native_pose, start_pose, native_interface_residues) );
1295  cur_job->add_string_real_pair( "rmsPHIPSI",
1296  fpdock_metrics_.calc_phipsi_RMSD( native_pose, final_pose, superpos_partner) );
1297  cur_job->add_string_real_pair( "rmsPHIPSI_if",
1298  fpdock_metrics_.calc_phipsi_RMSD( native_pose, final_pose, native_interface_residues) );
1299 
1300  core::Size ngoodatoms;
1302  ( native_pose,
1303  final_pose,
1304  native_interface_residues,
1305  &is_polymer_heavyatom, 1 /*Angstrom*/, ngoodatoms);
1307  ( native_pose,
1308  final_pose,
1309  native_interface_residues,
1310  &is_protein_backbone, 1 /*Angstrom*/, ngoodatoms);
1312  ( native_pose,
1313  final_pose,
1314  native_interface_residues,
1315  &is_polymer_heavyatom, 1.5 /*Angstrom*/, ngoodatoms);
1317  ( native_pose,
1318  final_pose,
1319  native_interface_residues,
1320  &is_polymer_heavyatom, 2 /*Angstrom*/, ngoodatoms);
1321  cur_job->add_string_real_pair( "frac_iatoms_less_1A", frac1 );
1322  cur_job->add_string_real_pair( "frac_iatoms_less_1A_bb", frac1_bb );
1323  cur_job->add_string_real_pair( "frac_iatoms_less_1.5A", frac1_5 );
1324  cur_job->add_string_real_pair( "frac_iatoms_less_2A", frac2 );
1325  std::map<core::Size,core::Real> subsetRMS;
1326  for (int k=4; k <= flags_.peptide_nres(); k++)
1327  {
1328  subsetRMS[k] = fpdock_metrics_.best_Kmer_rms
1329  ( native_pose, final_pose,&is_polymer_heavyatom, k);
1330  std::ostringstream oss;
1331  oss << "bestRMS_" << k << "mer_all";
1332  std::string s = oss.str();
1333  cur_job->add_string_real_pair( s, subsetRMS[k] );
1334  }
1335  }
1336 
1337  // low-res stats:
1339  addLowResStatistics(start_pose, pose_after_lowres);
1340  }
1341 
1342 }
1343 
1345  utility::tag::TagPtr const tag,
1349  core::pose::Pose const &
1350  )
1351 {
1353 
1354  if(tag->hasOption( "scorefxn_lowres"))
1355  {
1356  std::string const scorefxn_lowres_key( tag->getOption<std::string>("scorefxn_lowres" ) );
1357  if ( ! data.has( "scorefxns", scorefxn_lowres_key ) ) {
1358  throw utility::excn::EXCN_RosettaScriptsOption("ScoreFunction " + scorefxn_lowres_key + " not found in DataMap.");
1359  }
1360  scorefxn_lowres_ = data.get< core::scoring::ScoreFunction* >( "scorefxns", scorefxn_lowres_key );
1361  }
1362 
1363  flags_.lowres_abinitio = tag->getOption<bool>( "lowres_abinitio", flags_.lowres_abinitio ) ;
1364  flags_.lowres_preoptimize = tag->getOption<bool>( "lowres_preoptimize", flags_.lowres_preoptimize ) ;
1365  flags_.min_only = tag->getOption<bool>( "min_only", flags_.min_only ) ;
1366  flags_.random_phi_psi_pert = tag->getOption<bool>( "random_phi_psi_pert", flags_.random_phi_psi_pert ) ;
1367  flags_.random_phi_psi_pert_size = tag->getOption<core::Size>( "random_phi_psi_pert_size", (Size)(flags_.random_phi_psi_pert_size) ) ;
1368  flags_.extend = tag->getOption<bool>( "random_phi_psi_pert", flags_.random_phi_psi_pert ) ;
1369  flags_.rb_trans_size = tag->getOption<float>( "rb_trans_size", flags_.rb_trans_size) ;
1370  flags_.rb_rot_size = tag->getOption<float>( "rb_rot_size", flags_.rb_rot_size) ;
1371  if(tag->hasOption( "rb_trans_size" ) || tag->hasOption( "rb_rot_size" ))
1372  {
1373  flags_.randomRBstart = true;
1374  }
1375  flags_.pep_refine = tag->getOption<bool>( "pep_refine", flags_.pep_refine);
1377  { // overrides obsolete rbMCM and torsionsMCM
1378  flags_.rbMCM = true;
1379  flags_.torsionsMCM = true;
1380  }
1381  flags_.peptide_loop_model = tag->getOption<bool>( "peptide_loop_model", flags_.peptide_loop_model) ;
1382  flags_.smove_angle_range =tag->getOption<float> ( "smove_angle_range", flags_.smove_angle_range) ;
1383  flags_.design_peptide = tag->getOption<bool>( "design_peptide", flags_.design_peptide) ;
1384  flags_.backrub_opt = tag->getOption<bool>( "backrub_opt", flags_.backrub_opt) ;
1385  flags_.boost_fa_atr = tag->getOption<bool>( "boost_fa_atr", flags_.boost_fa_atr) ;
1386  flags_.ramp_fa_rep = tag->getOption<bool>( "ramp_fa_rep", flags_.ramp_fa_rep) ;
1387  flags_.ramp_rama = tag->getOption<bool>( "ramp_rama", flags_.ramp_rama) ;
1389  tag->getOption<core::Size>( "rep_ramp_cycles", flags_.rep_ramp_cycles) ;
1390  flags_.mcm_cycles = tag->getOption<core::Size>( "mcm_cycles", flags_.mcm_cycles) ;
1391  flags_.score_only = tag->getOption<bool>( "extra_scoring", flags_.score_only) ;
1392  flags_.use_cen_score = tag->getOption<bool>( "use_cen_score", flags_.use_cen_score) ;
1393  flags_.min_receptor_bb = tag->getOption<bool>( "min_receptor_bb", flags_.min_receptor_bb) ;
1394  flags_.ppk_only = tag->getOption<bool>( "ppk_only", flags_.ppk_only) ;
1395  flags_.no_prepack1 = tag->getOption<bool>( "no_prepack1", flags_.no_prepack1) ;
1396  flags_.no_prepack2 = tag->getOption<bool>( "no_prepack2", flags_.no_prepack2) ;
1397  flags_.score_filter = tag->getOption<bool>( "score_filter", flags_.score_filter) ;
1398  flags_.hb_filter = tag->getOption<bool>( "hb_filter", flags_.hb_filter) ;
1399  flags_.hotspot_filter = tag->getOption<bool>( "hotspot_filter", flags_.hotspot_filter) ;
1400  flags_.frag3_weight = tag->getOption<float>( "frag3_weight", flags_.frag3_weight) ;
1401  flags_.frag5_weight = tag->getOption<float>( "frag5_weight", flags_.frag5_weight) ;
1402  flags_.frag9_weight = tag->getOption<float>( "frag9_weight", flags_.frag9_weight) ;
1403  // todo: handle frag files themselves - this is right now in FlexPepDocingAbinitio.cc
1404  flags_.pSer2Asp_centroid = tag->getOption<bool>( "pSer2Asp_centroid", flags_.pSer2Asp_centroid) ;
1405  flags_.pSer2Glu_centroid = tag->getOption<bool>( "pSer2Glu_centroid", flags_.pSer2Glu_centroid) ;
1406 
1407  if ( tag->hasOption("receptor_chain") )
1408  {
1410  ( tag->getOption<std::string>( "receptor_chain" ).at(0) );
1411  }
1412  if ( tag->hasOption( "peptide_chain" ) )
1413  {
1415  ( tag->getOption<std::string>( "peptide_chain" ).at(0) );
1416  }
1417 
1418  // TODO: handle mutually exclusive options as in FlexPepDockingFlags
1419 
1420  // read native pose: (TODO: is this set automatically in scripts?)
1421  // protocols::jd2::set_native_in_mover(*fpDock);
1422  if ( tag->hasOption( "native" ) ) {
1423  core::pose::PoseOP tmp_native_pose = new core::pose::Pose;
1425  bool centroid_input = tag->getOption<bool>( "centroid_input", false );
1426  if ( centroid_input) {
1427  core::import_pose::centroid_pose_from_pdb( *tmp_native_pose, tag->getOption<std::string>("native") );
1428  } else {
1429  core::import_pose::pose_from_pdb( *tmp_native_pose, tag->getOption<std::string>("native") );
1430  }
1431  this->set_native_pose( tmp_native_pose );
1432  }
1433 }
1434 
1435 //////////////////////////FlexPepDockingProtocolCreator//////////////////////////////
1436 
1438  return new FlexPepDockingProtocol(1, true, true);
1439 }
1440 
1443 }
1444 
1446  return "FlexPepDock";
1447 }
1448 
1449 } // end namespace flexpep_docking
1450 } // end namespace protocols