Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DockingProtocol.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 // ThiS file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 // (c) Copyright Rosetta Commons Member Institutions.
9 // (c) This file is part of the Rosetta software suite and is made available under license.
10 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
11 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
12 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
13 
14 /// @file DockingProtocol.cc
15 ///
16 /// @brief
17 /// @author Monica Berrondo
18 /// @author Sid Chaudhury
19 /// @author Jeff Gray
20 /// @author Modified by Daisuke Kuroda
21 
22 // Unit Headers
24 
25 // Package Headers
35 // AUTO-REMOVED #include <protocols/docking/SidechainMinMover.hh>
37 #include <protocols/docking/DockingProtocolCreator.hh> // Support the scriptor
38 
39 // Project Headers
41 
42 // AUTO-REMOVED #include <core/io/pdb/pose_io.hh>
43 // AUTO-REMOVED #include <core/io/pdb/file_data.hh>
44 
45 #include <core/pose/Pose.hh>
46 // AUTO-REMOVED #include <core/pose/PDBInfo.hh>
47 // AUTO-REMOVED #include <core/pose/datacache/CacheableDataType.hh>
48 
49 // AUTO-REMOVED #include <core/pack/task/PackerTask.hh>
50 // AUTO-REMOVED #include <core/pack/task/operation/ResFilters.hh> // ResidueLacksProperty
51 // AUTO-REMOVED #include <core/pack/task/operation/TaskOperations.hh>
52 // AUTO-REMOVED #include <core/pack/task/operation/NoRepackDisulfides.hh>
54 // AUTO-REMOVED #include <core/pack/task/operation/ResLvlTaskOperations.hh> // PreventRepackingRLT
55 // AUTO-REMOVED #include <core/pack/task/operation/OperateOnCertainResidues.hh>
56 
57 #include <core/scoring/Energies.hh>
61 // AUTO-REMOVED #include <protocols/scoring/InterchainPotential.hh>
64 
66 // AUTO-REMOVED #include <protocols/simple_moves/ScoreMover.hh>
67 // AUTO-REMOVED #include <protocols/rigid/RigidBodyMover.hh>
69 // AUTO-REMOVED #include <protocols/simple_moves/PackRotamersMover.hh>
72 // AUTO-REMOVED #include <protocols/simple_moves/RotamerTrialsMinMover.hh>
75 
77 
80 #include <protocols/jd2/util.hh>
82 
83 // Utility Headers
84 // AUTO-REMOVED #include <utility/io/izstream.hh>
85 #include <utility/file/FileName.hh>
86 #include <utility/tools/make_vector1.hh>
87 #include <utility/tag/Tag.hh> // REQUIRED FOR WINDOWS
88 
89 #include <core/types.hh>
90 #include <basic/prof.hh>
91 #include <basic/Tracer.hh>
92 #include <basic/datacache/BasicDataCache.hh>
93 // AUTO-REMOVED #include <basic/datacache/DiagnosticData.hh>
94 
95 #include <basic/options/option.hh>
96 #include <basic/options/keys/in.OptionKeys.gen.hh>
97 // AUTO-REMOVED #include <basic/options/keys/out.OptionKeys.gen.hh>
98 #include <basic/options/keys/score.OptionKeys.gen.hh>
99 #include <basic/options/keys/run.OptionKeys.gen.hh>
100 #include <basic/options/keys/cluster.OptionKeys.gen.hh>
101 #include <basic/options/keys/docking.OptionKeys.gen.hh>
102 // AUTO-REMOVED #include <basic/options/keys/packing.OptionKeys.gen.hh>
103 #include <basic/options/keys/constraints.OptionKeys.gen.hh>
104 
105 // Numeric Headers
106 
107 // ObjexxFCL Headers
108 #include <ObjexxFCL/FArray1D.hh>
109 #include <ObjexxFCL/format.hh>
110 
111 // C++ headers
112 #include <algorithm>
113 
115 #include <protocols/jd2/Job.hh>
116 //#include <protocols/jobdist/Jobs.hh>
117 #include <utility/vector0.hh>
118 #include <utility/vector1.hh>
119 
120 
121 using basic::Error;
122 using basic::Warning;
123 
124 static basic::Tracer TR("protocols.docking.DockingProtocol");
125 using namespace core;
126 
127 namespace protocols {
128 namespace docking {
129 
130 // Constructors
131 DockingProtocol::DockingProtocol()
132 {
133  user_defined_ = false;
134  init(utility::tools::make_vector1<core::SSize>(1), false, false, true, NULL, NULL);
135 }
136 
137 DockingProtocol::DockingProtocol(
138  Size const rb_jump,
139  bool const low_res_protocol_only,
140  bool const docking_local_refine,
141  bool const autofoldtree,
142  core::scoring::ScoreFunctionOP docking_score_low,
143  core::scoring::ScoreFunctionOP docking_score_high
144 ) : Mover()
145 {
146  user_defined_ = true;
147  init(utility::tools::make_vector1<core::SSize>(rb_jump), low_res_protocol_only, docking_local_refine, autofoldtree, docking_score_low, docking_score_high);
148 }
149 
151  DockJumps const movable_jumps,
152  bool const low_res_protocol_only,
153  bool const docking_local_refine,
154  bool const autofoldtree,
155  core::scoring::ScoreFunctionOP docking_score_low,
156  core::scoring::ScoreFunctionOP docking_score_high
157 ) : Mover()
158 {
159  user_defined_ = true;
160  init(movable_jumps, low_res_protocol_only, docking_local_refine, autofoldtree, docking_score_low, docking_score_high);
161 }
162 // End of constructors
163 
164 
166  DockJumps const movable_jumps,
167  bool const low_res_protocol_only,
168  bool const docking_local_refine,
169  bool const autofoldtree,
170  core::scoring::ScoreFunctionOP docking_score_low,
171  core::scoring::ScoreFunctionOP docking_score_high
172 )
173 {
174 
175  using basic::options::option;
176  using namespace basic::options::OptionKeys;
177 
178  Mover::type( "DockingProtocol" );
180 
181  // setup all the booleans with default values
182  // they will get overwritten by the options and/or passed values
183  set_default();
185  if ( user_defined_ ) {
186  low_res_protocol_only_ = low_res_protocol_only;
187  docking_local_refine_ = docking_local_refine;
188  autofoldtree_ = autofoldtree;
189  }
190 
191  // correctly set up the score functions from either passed in values or defaults
192  if ( docking_score_low() == NULL ) {
193  //docking_scorefxn_low_ = core::scoring::ScoreFunctionFactory::create_score_function( "interchain_cen" );
195  basic::options::option[ basic::options::OptionKeys::score::patch ]()
196  );
197 
198  } else {
199  docking_scorefxn_low_ = docking_score_low;
200  }
201 
202  if ( docking_score_high() == NULL ) {
206  } else {
207  docking_scorefxn_high_ = docking_score_high;
208  docking_scorefxn_pack_ = docking_score_high;
209  docking_scorefxn_output_ = docking_score_high;
210  }
211 
212  if ( option[ score::weights ].user() ){
215  }
216 
217  if ( option[ score::pack_weights ].user() ){
219  }
220 
221  // set up objects based on the boolean values defined above
222  setup_objects();
223 }
224 
225 void
227 {
228  //using namespace basic::options;
229  using namespace core::scoring;
230 
231  reporting_ = true;
232  autofoldtree_ = true;
233 
234  low_res_protocol_only_ = false;
235  docking_local_refine_ = false;
236  dock_min_ = false;
237  rt_min_ = false;
238  sc_min_ = false;
239  partners_ = "_";
240  cst_weight_ = 0.0;
241  use_csts_ = false;
242  score_cutoff_ = 1000000.0;
243  no_filters_ = false;
244  use_legacy_protocol_ = false;
246  design_ = false;
247  if_ensemble_ = false;
248 
251 
252  // initialize the ensemble movers and file strings
253  ensemble1_ = NULL;
254  ensemble2_ = NULL;
255  ensemble1_filename_ = "";
256  ensemble2_filename_ = "";
258 
259 }
260 
262 {
263  // initialize to null
264  lowres_filter_ = NULL;
265  highres_filter_ = NULL;
266 
267  // initialize constraint set mover
268  docking_constraint_ = NULL;
269 
270  // stores the sequence of the previous pose, so that the DockingProtocol can re setup the fold tree
271  previous_sequence_ = "";
272 
273  fold_tree_ = core::kinematics::FoldTree(); // apl NOTE: was NULL, but fold_tree_ is not a pointer.
274  init_task_factory_ = NULL;
275  perturber_ = NULL;
276  docking_lowres_mover_ = NULL;
277  docking_highres_mover_ = NULL;
278 
279  // Residue movers
281 
282  //generate to_all_atom mover: to_all_atom_ =
284  to_all_atom_and_repack->add_mover( new protocols::simple_moves::SwitchResidueTypeSetMover( core::chemical::FA_STANDARD ) );
285  to_all_atom_and_repack->add_mover( new protocols::simple_moves::RepackSidechainsMover( docking_scorefxn_pack_ ) );
286  to_all_atom_=to_all_atom_and_repack;
287 
289 }
290 
292 {
293  if ( !docking_local_refine_ ) {
294  if( ensemble2_filename_ != "" ){
295  if_ensemble_ = true;
296  }
297 
298  if ( !perturber_ ){
299  perturber_ = new DockingInitialPerturbation( movable_jumps_, true /*slide into contact*/ );
300  }
301  if ( !docking_lowres_mover_ ){
302  // Modified by DK
303  if( if_ensemble_ ){
305  } else {
307  }
308  }
309  if ( !no_filters_ && !lowres_filter_ ) {
311  }
312  } else {
313  perturber_ = NULL;
314  docking_lowres_mover_ = NULL;
315  }
316 
317  if ( !low_res_protocol_only_ ) {
318  if ( dock_min_ ) {
319  if ( docking_highres_mover_ ) {
320  if ( docking_highres_mover_->get_name() != "DockMinMover" ) docking_highres_mover_ = NULL;
321  }
323  }
324  else if ( use_legacy_protocol_ ) {
325  if ( docking_highres_mover_ ) {
326  if ( docking_highres_mover_->get_name() != "DockingHighResLegacy" ) docking_highres_mover_ = NULL;
327  }
328  if ( !docking_highres_mover_ ) {
330  docking_highres_mover_->set_rt_min( rt_min_ );
331  docking_highres_mover_->set_sc_min( sc_min_ );
332  docking_highres_mover_->set_partners( partners_ );
333  }
334  }
335  else {
336  if ( docking_highres_mover_ ) {
337  if ( docking_highres_mover_->get_name() != "DockMCMProtocol" ) docking_highres_mover_ = NULL;
338  }
339  if ( !docking_highres_mover_ ){
340  // uses docking_scorefxn_output because three scorefunction still exist
341  // After move to new protocol is complete, docking_scorefxn_output will be the same as docking_scorefxn_high
342  // docking_highres_mover_ = new DockMCMProtocol( movable_jumps_, docking_scorefxn_output_, docking_scorefxn_pack_ ); //JQX commented this out, see the line below
343  docking_highres_mover_ = new DockMCMProtocol( movable_jumps_, docking_scorefxn_high_, docking_scorefxn_pack_ ); //JQX added this line to match the Legacy code
344  docking_highres_mover_->set_rt_min( rt_min_ );
345  docking_highres_mover_->set_sc_min( sc_min_ );
346  docking_highres_mover_->set_partners( partners_ );
347  }
348  }
349  if ( !no_filters_ && !highres_filter_ ) {
351  }
352  } else {
353  docking_highres_mover_ = NULL;
354  }
355  if ( no_filters_ ){
356  highres_filter_ = NULL;
357  lowres_filter_ = NULL;
358  }
359 
360  // set up constraint set mover
361  if ( !use_csts_ ) {
362  docking_constraint_ = NULL;
363  } else {
364  if ( !docking_constraint_ ) {
366  }
367  }
368 
371 }
372 
373 void
375 {
376  using namespace basic::options;
377 
378  // check for movable jumps option
379  if( option[ OptionKeys::docking::multibody ].user() ) {
380  set_movable_jumps( option[ OptionKeys::docking::multibody ]() );
381  }
382 
383  // These options default to false
384  if( option[ OptionKeys::docking::low_res_protocol_only ].user() ) {
385  set_low_res_protocol_only(option[ OptionKeys::docking::low_res_protocol_only ]());
386  }
387 
388  if( option[ OptionKeys::docking::docking_local_refine ].user() ) {
389  set_docking_local_refine(option[ OptionKeys::docking::docking_local_refine ]());
390  }
391 
392  if( option[ OptionKeys::docking::dock_min ].user() ) {
393  set_dock_min(option[ OptionKeys::docking::dock_min ]());
394  }
395 
396  // Sets the member directly so sync_objects_with_flags won't be triggered prematurely.
397  // A public setter exists for this member.
398  if( option[ OptionKeys::docking::dock_rtmin ].user() ) {
399  rt_min_ = option[ OptionKeys::docking::dock_rtmin ]();
400  }
401 
402  // Sets the member directly so sync_objects_with_flags won't be triggered prematurely.
403  // A public setter exists for this member.
404  if( option[ OptionKeys::docking::sc_min ].user() ) {
405  sc_min_ = option[ OptionKeys::docking::sc_min ]();
406  }
407 
408  // This defaults to "_"
409  if( option[ OptionKeys::docking::partners ].user() ) {
410  set_partners(option[ OptionKeys::docking::partners ]());
411  }
412 
413  // Defaults to 0
414  if( option[ OptionKeys::constraints::cst_weight ].user() ) {
415  set_cst_weight(option[ OptionKeys::constraints::cst_weight ]());
416  }
417 
418  // Defaults to false
419  set_use_constraints( option[ OptionKeys::constraints::cst_file ].user() );
420 
421 
422  //set native pose if asked for
423  if ( option[ OptionKeys::in::file::native ].user() ) {
424  core::pose::PoseOP native_pose = new core::pose::Pose();
425  core::import_pose::pose_from_pdb( *native_pose, option[ OptionKeys::in::file::native ]() );
426  set_native_pose( native_pose );
427  } else {
428  set_native_pose(NULL);
429  }
430 
431  if ( option[ OptionKeys::cluster::output_score_filter ].user() ) {
432  score_cutoff_ = option[ OptionKeys::cluster::output_score_filter ]();
433  }
434 
435  if ( option[ OptionKeys::docking::no_filters ].user() ) {
436  set_no_filters(option[ OptionKeys::docking::no_filters ]);
437  }
438 
439  if ( option[ OptionKeys::docking::use_legacy_protocol ].user() ) {
440  set_use_legacy_protocol( option[ OptionKeys::docking::use_legacy_protocol ] );
441  }
442 
443  if ( option[ OptionKeys::docking::ignore_default_docking_task].user() ){
444  set_ignore_default_docking_task( option[ OptionKeys::docking::ignore_default_docking_task ]() );
445  }
446  // docking low res options
447  if ( option[ OptionKeys::docking::docking_centroid_inner_cycles ].user() ) {
448  set_inner_cycles(option[ OptionKeys::docking::docking_centroid_inner_cycles ]() );
449  }
450 
451  if ( option[ OptionKeys::docking::docking_centroid_outer_cycles ].user() ) {
452  set_outer_cycles(option[ OptionKeys::docking::docking_centroid_outer_cycles ]());
453  }
454 
455  // above cycles must be called before ensemble since the cycle number is overwritten if in ensemble mode
456  if ( option[ OptionKeys::docking::ensemble1 ].user() ) {
457  set_ensemble1(option[ OptionKeys::docking::ensemble1 ]());
458  }
459 
460  if ( option[ OptionKeys::docking::ensemble2 ].user() ) {
461  set_ensemble2(option[ OptionKeys::docking::ensemble2 ]());
462  }
463 
464  if ( option[ OptionKeys::docking::recover_sidechains ].user() ) {
465  set_recover_sidechains_filename(option[ OptionKeys::docking::recover_sidechains ]());
466  }
467 }
468 
469 void
471 {
472  using namespace basic::options;
473 
474  option.add_relevant( OptionKeys::docking::multibody );
475  option.add_relevant( OptionKeys::docking::low_res_protocol_only );
476  option.add_relevant( OptionKeys::docking::docking_local_refine );
477  option.add_relevant( OptionKeys::docking::dock_min );
478  option.add_relevant( OptionKeys::docking::dock_rtmin );
479  option.add_relevant( OptionKeys::docking::sc_min );
480  option.add_relevant( OptionKeys::docking::partners );
481  option.add_relevant( OptionKeys::docking::no_filters );
482  option.add_relevant( OptionKeys::constraints::cst_weight );
483  option.add_relevant( OptionKeys::constraints::cst_file );
484  option.add_relevant( OptionKeys::run::score_only );
485  option.add_relevant( OptionKeys::in::file::native );
486  option.add_relevant( OptionKeys::docking::use_legacy_protocol );
487  option.add_relevant( OptionKeys::docking::ignore_default_docking_task );
488  option.add_relevant( OptionKeys::docking::recover_sidechains );
489  // low res protocol options
490  option.add_relevant( OptionKeys::docking::docking_centroid_inner_cycles );
491  option.add_relevant( OptionKeys::docking::docking_centroid_outer_cycles );
492  option.add_relevant( OptionKeys::docking::ensemble1 );
493  option.add_relevant( OptionKeys::docking::ensemble2 );
494 }
495 
496 void
497 DockingProtocol::finalize_setup( pose::Pose & pose ) //setup objects requiring pose during apply
498 {
499  if( autofoldtree_ ) {
500  TR << "Setting docking foldtree" << std::endl;
501  TR << "old fold tree: " << pose.fold_tree() << std::endl;
503  TR << "new fold tree: " << pose.fold_tree() << std::endl;
504  }
505 
506  fold_tree_ = pose.fold_tree();
507 
508  // check for native and input pose
509  // input pose is used further down for the recover sidehchains mover
510  if ( !get_input_pose() ) {
511  core::pose::PoseOP input_pose = new core::pose::Pose( pose );
512  set_input_pose( input_pose );
513  }
514 
515  // if an ensemble file is defined for either partner, both partners must be defined
516  if ( ensemble1_filename_ != "" || ensemble2_filename_ != "" ) {
517  if ( ensemble1_filename_ == "" || ensemble2_filename_ == "" ) utility_exit_with_message( "Must define ensemble file for both partners");
518  runtime_assert( movable_jumps_.size() == 1 ); // ensemble mode is only allowed for traditional docking
519  core::Size const rb_jump = movable_jumps_[1];
520  Size start_res(1), end_res(1), cutpoint(pose.fold_tree().cutpoint_by_jump( rb_jump ));
521 
522  //lowres_inner_cycles_ = 25; // Should be 50 (default value for traditional docking); modified by DK
523 
524  TR << "Ensemble 1: " << ensemble1_filename_ << std::endl;
525  start_res = 1;
526  end_res = cutpoint;
527 
528  ensemble1_ = new DockingEnsemble( start_res, end_res, rb_jump, ensemble1_filename_, "dock_ens_conf1", docking_scorefxn_low_, docking_scorefxn_high_ );
529 
530  TR << "Ensemble 2: " << ensemble2_filename_ << std::endl;
531  start_res = cutpoint + 1;
532  end_res = pose.total_residue();
533 
534  ensemble2_ = new DockingEnsemble( start_res, end_res, rb_jump, ensemble2_filename_, "dock_ens_conf2", docking_scorefxn_low_, docking_scorefxn_high_ );
535 
536  // recover sidechains mover is not needed with ensemble docking since the sidechains are recovered from the partners in the ensemble file
537  recover_sidechains_ = NULL;
538 
539  // add ensemble conformer energies to low res scorefunction
540  core::scoring::ScoreFunctionOP docking_scorefxn_ens, docking_highres_ens;
541  docking_scorefxn_ens = new core::scoring::ScoreFunction( *docking_scorefxn_low_ );
542  docking_scorefxn_ens->set_weight( core::scoring::dock_ens_conf, 1.0 );
543  set_lowres_scorefxn( docking_scorefxn_ens );
544  // pass the scorefunction to the low res mover
546 
547  //docking_highres_ens = new core::scoring::ScoreFunction( *docking_scorefxn_high_ );
548  //docking_highres_ens->set_weight( core::scoring::dock_ens_conf, 1.0 );
549  //set_highres_scorefxn( docking_highres_ens, docking_scorefxn_pack_ ); // sets csts for mc and minimization, but not packing
550  // pass the score function to the high res mover
551  //docking_highres_mover_->set_scorefxn( docking_scorefxn_high_ );
552  } else { //if ensemble docking
553  if ( recover_sidechains_filename_ != "" ) {
554  if ( !recover_sidechains_ ) {
555  core::pose::Pose a_pose;
558  } //first initialization ?
559  } else if ( get_input_pose() && get_input_pose()->is_fullatom() ) {
561  } else {
562  // recover sidechains mover is not needed with ensemble docking since the sidechains are recovered from the partners in the ensemble fi
563  recover_sidechains_ = NULL;
564  }
565  } //if ensemble docking
566 
567  if ( docking_lowres_mover_ ) {
568  // pass the ensemble movers to the lowres protocol
569  if( if_ensemble_ && docking_lowres_mover_->get_name() == "DockingLowResEnsemble" ){
570  DockingLowResEnsemble* ensemble_mover = dynamic_cast< DockingLowResEnsemble* >(docking_lowres_mover_.get());
571 
572  ensemble_mover->set_ensemble1( ensemble1_ );
573  ensemble_mover->set_ensemble2( ensemble2_ );
574  }
575 
576  docking_lowres_mover_->set_inner_cycles( lowres_inner_cycles_ );
577  docking_lowres_mover_->set_outer_cycles( lowres_outer_cycles_ );
578  }
579 
580  // set relevant information to legacy high res mover
581  if ( docking_highres_mover_ ) {
582  if ( docking_highres_mover_->get_name() == "DockingHighResLegacy" && design_ ) {
583  DockingHighResLegacyOP legacy_mover = dynamic_cast< DockingHighResLegacy* >(docking_highres_mover_.get());
584  legacy_mover->design( design_ );
585  }
586  // passes the task factory down the chain and allows setting of the default docking task
587  if ( init_task_factory_ ){
588  docking_highres_mover_->set_task_factory( init_task_factory_ );
589  }
590  docking_highres_mover_->set_ignore_default_task( ignore_default_docking_task_ );
591  }
592 
593  //initialize docking filters
594  if ( highres_filter_ ) highres_filter_->set_score_cutoff( score_cutoff_ );
595 
596  if ( docking_constraint_ ) {
597  TR << "setting up the constraint set mover" << std::endl;
598  docking_constraint_->apply( pose );
599  if ( cst_weight_ == 0.0 ) cst_weight_ = 1.0;
600  // finish setting up constraints
601  }
602 
603  setup_constraints( pose );
604 }
605 
606 //destructor
608 
609 ///@brief clone operator, calls the copy constructor
612  //return( new DockingProtocol( movable_jumps_, low_res_protocol_only_, docking_local_refine_, autofoldtree_, docking_scorefxn_low_, docking_scorefxn_high_ ) ); This is bad do not clone this way.
613  return new DockingProtocol(*this);
614 }
615 
616 ///@brief fresh_instance returns a default-constructed object for the JD2
619  return new DockingProtocol();
620 }
621 
622 ///@brief This mover retains state such that a fresh version is needed if the input Pose is about to change
624  return true;
625 }
626 
627 ///@brief copy ctor
629  Mover(rhs)
630 {
632 }
633 
634 ///@brief assignment operator
636  //abort self-assignment
637  if (this == &rhs) return *this;
638  Mover::operator=(rhs);
640  return *this;
641 }
642 
644  //going through all of member data and assigning it
645  lhs.user_defined_ = rhs.user_defined_;
647  lhs.reporting_ = rhs.reporting_;
648  lhs.autofoldtree_ = rhs.autofoldtree_;
651  lhs.sc_min_ = rhs.sc_min_;
652  lhs.rt_min_ = rhs.rt_min_;
653  lhs.dock_min_ = rhs.dock_min_;
654  lhs.no_filters_ = rhs.no_filters_;
657  lhs.use_csts_ = rhs.use_csts_;
658  lhs.cst_weight_ = rhs.cst_weight_;
659  lhs.score_cutoff_ = rhs.score_cutoff_;
660  lhs.fold_tree_ = rhs.fold_tree_;
661  lhs.partners_ = rhs.partners_;
665  lhs.movable_jumps_ = rhs.movable_jumps_;
670  if( rhs.mc_ ) //not used currently but might be needed later
671  lhs.mc_ = new moves::MonteCarlo( *(rhs.mc_) );
672  if ( rhs.lowres_filter_ ) lhs.lowres_filter_ = static_cast< DockingLowResFilter * const > (rhs.lowres_filter_->clone()() );
673  if ( rhs.highres_filter_ ) lhs.highres_filter_ = static_cast< DockingHighResFilter * const > (rhs.highres_filter_->clone()() );
674  if ( rhs.docking_lowres_mover_){
675  lhs.docking_lowres_mover_ = static_cast< DockingLowRes * >( rhs.docking_lowres_mover_->clone()() );
676  }
677  if ( rhs.docking_highres_mover_){
678  lhs.docking_highres_mover_ = static_cast< DockingHighRes * >( rhs.docking_highres_mover_->clone()() );
679  }
680  if ( rhs.to_centroid_ ) lhs.to_centroid_ = static_cast< protocols::simple_moves::SwitchResidueTypeSetMover * >( rhs.to_centroid_->clone()() );
681  if ( rhs.to_all_atom_ ) lhs.to_all_atom_ = rhs.to_all_atom_->clone();
682  if( rhs.ensemble1_){
685  }
686  if( rhs.ensemble2_){
689  }
690  if( rhs.docking_constraint_ )
692  if( rhs.recover_sidechains_ )
694  if( rhs.init_task_factory_ ){
696  }
697  lhs.design_ = rhs.design_;
699 }
700 
702 {
703  docking_scorefxn_low_ = docking_scorefxn_low;
704 
705 }
706 
708 {
709  docking_scorefxn_high_ = docking_scorefxn_high;
710  docking_scorefxn_pack_ = docking_scorefxn_high;
711  docking_scorefxn_output_ = docking_scorefxn_high;
712 }
713 
715  core::scoring::ScoreFunctionOP docking_scorefxn_high,
716  core::scoring::ScoreFunctionOP docking_scorefxn_pack )
717 {
718  docking_scorefxn_high_ = docking_scorefxn_high;
719  docking_scorefxn_pack_ = docking_scorefxn_pack;
720  docking_scorefxn_output_ = docking_scorefxn_high;
721 }
722 
724  core::scoring::ScoreFunctionOP docking_scorefxn_high,
725  core::scoring::ScoreFunctionOP docking_scorefxn_pack,
726  core::scoring::ScoreFunctionOP docking_scorefxn_output )
727 {
728  docking_scorefxn_high_ = docking_scorefxn_high;
729  docking_scorefxn_pack_ = docking_scorefxn_pack;
730  docking_scorefxn_output_ = docking_scorefxn_output;
731 }
732 
733 void DockingProtocol::set_sc_min( bool sc_min )
734 {
736  sc_min_ = sc_min;
737  docking_highres_mover_->set_sc_min( sc_min );
738 }
739 
740 void DockingProtocol::set_rt_min( bool rt_min )
741 {
743  rt_min_ = rt_min;
744  docking_highres_mover_->set_rt_min( rt_min );
745 }
746 
747 void DockingProtocol::set_dock_min( bool const dock_min )
748 {
749 // assert ( !low_res_protocol_only_ ); // SJF this assert doesn't make sense b/c set_dock_min is called even if low_res_protocol_only_ is set through parse_my_tag
750  dock_min_ = dock_min;
751 }
752 
753 void DockingProtocol::set_no_filters( bool no_filters )
754 {
755  if ( no_filters != no_filters_ ){
756  no_filters_ = no_filters;
758  }
759 }
760 
761 void DockingProtocol::set_low_res_protocol_only( bool const low_res_protocol_only )
762 {
763  if ( low_res_protocol_only != low_res_protocol_only_ ){
764  low_res_protocol_only_ = low_res_protocol_only;
766  }
767 }
768 
769 void DockingProtocol::set_docking_local_refine( bool const docking_local_refine )
770 {
771  if ( docking_local_refine != docking_local_refine_ ){
772  docking_local_refine_ = docking_local_refine;
774  }
775 }
776 
777 void DockingProtocol::set_use_legacy_protocol( bool const use_legacy_protocol )
778 {
779  if ( use_legacy_protocol != use_legacy_protocol_ ){
780  use_legacy_protocol_ = use_legacy_protocol;
782  }
783 
784 }
785 
787 {
788  if ( cst_weight != cst_weight_ ){
789  cst_weight_ = cst_weight;
790  runtime_assert( cst_weight_ != 0.0 );
792  }
793 }
794 
795 void DockingProtocol::set_use_constraints( bool const use_csts )
796 {
797  if ( use_csts != use_csts_ ){
798  use_csts_ = use_csts;
800  }
801 }
802 
804 {
806  docking_highres_mover_->set_interface_definition_task_operation( interface_definition );
807 }
808 
810 {
812  docking_highres_mover_->set_additional_task_operarations( additional_task_operations );
813 }
814 
816 {
818  docking_highres_mover_->add_additional_task_operaration( task_operation );
819 }
820 
822 {
824  return docking_highres_mover_->get_additional_task_operarations();
825 }
826 
827 
829 {
830  assert ( !low_res_protocol_only_ );
831  if ( !docking_highres_mover_ ){
833  }
834 }
835 
836 /// @brief setup the constrainta for each application of the docking protocol
838 {
839  if ( cst_weight_!=0.0 ) {
840  if ( !pose.constraint_set() ) {
841  TR << "No ConstraintSet has been created, skipping cst_weight. Use cst_file instead and set up desired ConstraintSet" << std::endl;
842  if( lowres_filter_ ) lowres_filter_->set_use_constraints( false );
843  } else {
844  if( lowres_filter_ ) lowres_filter_->set_use_constraints( true );
846  }
847  }
848  else{
849  if( lowres_filter_ ) lowres_filter_->set_use_constraints( false );
850  }
851 }
852 
853 /// @brief add distance constraint to the docking score functions
855 {
856  // Add constraints to the low resolution docking mover if applicable
857  if ( docking_lowres_mover_ ) {
859  docking_scorefxn_cst->set_weight( core::scoring::atom_pair_constraint, cst_weight_ );
860  set_lowres_scorefxn( docking_scorefxn_cst );
861  // pass the scorefunction to the low res mover
863  }
864 
865  // Add constraints to the high resolution docking mover if applicable
866  if ( docking_highres_mover_ ) {
867  core::scoring::ScoreFunctionOP docking_highres_cst = new core::scoring::ScoreFunction( *docking_scorefxn_output_ ); // needs to use the non-min score function to match assemble_domains test with constraints
868  docking_highres_cst->set_weight( core::scoring::atom_pair_constraint, cst_weight_ );
869  set_highres_scorefxn( docking_highres_cst, docking_scorefxn_pack_ ); // sets csts for mc and minimization, but not packing
870  // pass the score function to the high res mover
872  }
873 }
874 
875 ////////////////////////////////////////////////////////////////////////////////
876 /// @begin Docking apply
877 ///
878 /// @brief main docking protocol
879 ///
880 /// @detailed
881 /// Main function for docking. Includes the following steps:
882 /// 0) prepack mode: prepare a starting structure for later runs
883 /// OR:
884 /// 1) perturbation of decoy (see docking_perturb_decoy): changes
885 /// orientation of docking partners
886 /// 2) low-resolution search:
887 /// refine structure with rigid-body, centroid-mode MC cycles
888 /// 3) high-resolution search:
889 /// further refinement of structure in fullatom mode
890 void
892 {
893  bool passed_lowres_filter = true;
894  bool passed_highres_filter = true;
895  std::map < std::string, core::Real > lowres_scores;
896 
897  if ( !get_native_pose() ) {
898  TR << "Danger Will Robinson! Native is an impostor!" << std::endl;
899  core::pose::PoseOP native_pose = new core::pose::Pose(pose);
900  set_native_pose( native_pose );
901  }
902 
905  }
906 
907  if ( previous_sequence_.compare( pose.sequence() ) != 0 ){
909  previous_sequence_ = pose.sequence();
910  }
911 
913  finalize_setup( pose );
915  }
916 
917  pose.fold_tree( fold_tree_ );
918  show(TR);
919 
920  basic::prof_reset();
922 
923  // Low resolution docking
924  if ( docking_lowres_mover_ ) {
925  // convert to centroid mode
926  to_centroid_->apply( pose );
927  if ( docking_constraint_ ) {
928  TR << "setting up the constraint set mover" << std::endl;
929  docking_constraint_->apply( pose );
930  if ( cst_weight_ == 0.0 ) cst_weight_ = 1.0;
931  // finish setting up constraints
932  setup_constraints( pose );
933  }
934 
935  TR << pose.fold_tree() << std::endl;
936  // make starting perturbations based on command-line flags over each movable jump
937  if ( perturber_ ) {
938  perturber_->apply( pose );
939  TR << "finished initial perturbation" << std::endl;
940  }
941 
942  // add scores to jd2 output
943  if ( reporting_ && get_native_pose() ) job->add_string_real_pair("st_rmsd", calc_Lrmsd( pose, *get_native_pose(), movable_jumps_ ));
944 
945  docking_lowres_mover_->apply( pose );
946 
947  // Perform additional low resolution steps if they have been specified
949  {
950  additional_low_resolution_steps_->apply( pose );
951  }
952 
953  // add scores to jd2 output
954  if( reporting_ ) {
955  if ( ensemble1_ ) job->add_string_real_pair("conf_num1", ensemble1_->get_current_confnum() );
956  if ( ensemble2_ ) job->add_string_real_pair("conf_num2", ensemble2_->get_current_confnum() );
957  if ( get_native_pose() ) {
958  // calculate and store the rms no matter which mode was used
959  job->add_string_real_pair("rms", calc_Lrmsd( pose, *get_native_pose(), movable_jumps_ ));
960  job->add_string_real_pair("cen_rms", calc_Lrmsd( pose, *get_native_pose(), movable_jumps_ ));
961  }
962  // store the low res scores for output
964  }
965  if ( lowres_filter_ ) {
966  passed_lowres_filter = lowres_filter_->apply( pose );
967  if ( !passed_lowres_filter ) lowres_filter_->report( TR, pose );
968  }
969  }
970 
971  // High resolution docking
972  if ( passed_lowres_filter && docking_highres_mover_ ) {
973  if ( !pose.is_fullatom() ) {
974  // Convert pose to high resolution and recover sidechains
975  to_all_atom_->apply( pose );
976  if ( docking_constraint_ ) {
977  TR << "setting up the constraint set mover" << std::endl;
978  docking_constraint_->apply( pose );
979  if ( cst_weight_ == 0.0 ) cst_weight_ = 1.0;
980  // finish setting up constraints
981  setup_constraints( pose );
982 
983  }
984  (*docking_highres_mover_->scorefxn())( pose );
985  jd2::write_score_tracer( pose, "Docking_to_all_atom" );
986  if ( recover_sidechains_ ) {
987  recover_sidechains_->apply( pose );
988  (*docking_highres_mover_->scorefxn())( pose );
989  jd2::write_score_tracer( pose, "Docking_recovered_sidechains" );
990  } else {
991  if ( ensemble1_ ) {
992  ensemble1_->recover_conformer_sidechains( pose );
993  }
994  if ( ensemble2_ ) {
995  ensemble2_->recover_conformer_sidechains( pose );
996  }
997  }
998  }
999  docking_highres_mover_->apply( pose );
1000  ( *docking_scorefxn_output_ )( pose );
1001  if ( highres_filter_ ) passed_highres_filter = highres_filter_->apply( pose );
1002 
1003  if ( reporting_ ) {
1004  // calculate and store the rms no matter which mode was used
1005  // this will overwrite the "rms" column from low res if it was calculated
1006  if ( get_native_pose() ) job->add_string_real_pair("rms", calc_Lrmsd( pose, *get_native_pose(), movable_jumps_ ) );
1007 
1008  // output low res scores if low res was run
1009  if ( lowres_scores.size() > 0 ) {
1010  for ( std::map< std::string, core::Real >::const_iterator pair=lowres_scores.begin(); pair!=lowres_scores.end(); ++pair ) {
1011  if ( pair->first == "dock_ens_conf" ) job->add_string_real_pair( "cen_dock_ens_conf", pair->second );
1012  else if ( pair->first != "total_score" ) job->add_string_real_pair( pair->first, pair->second );
1013  }
1014  }
1015 
1016  // @TODO metrics doesn't need to always take scorefunctions (for example, not necessary for irms or fnat)
1017  job->add_string_real_pair("I_sc", calc_interaction_energy( pose, docking_scorefxn_output_, movable_jumps_ ) );
1018  if ( get_native_pose() ) {
1019  job->add_string_real_pair("Irms", calc_Irmsd(pose, *get_native_pose(), docking_scorefxn_output_, movable_jumps_ ));
1020  job->add_string_real_pair("Fnat", calc_Fnat( pose, *get_native_pose(), docking_scorefxn_output_, movable_jumps_ ));
1021  }
1022 // pose.energies().show_total_headers( std::cout );
1023 // pose.energies().show_totals( std::cout );
1024 // TR << pose.energies().total_energies()[ core::scoring::total_score ] << std::endl;
1025 // TR << pose.energies().total_energies()[ core::scoring::dock_ens_conf ] << std::endl;
1026  if ( ensemble1_ && ensemble2_ )
1027  job->add_string_real_pair("conf_score",
1029  - ensemble1_->highres_reference_energy()
1030  - ensemble2_->highres_reference_energy() );
1031  }
1032  }
1033 
1034  if ( !passed_lowres_filter || !passed_highres_filter ){
1036  }
1037  else{
1039  }
1040 
1041  basic::prof_show();
1042 }
1043 
1044 
1045 //getters for const access to movers and data of docking protocol
1047  return to_centroid_;
1048 }
1050  return to_all_atom_ ;
1051 }
1053  return docking_lowres_mover_;
1054 }
1056  return docking_highres_mover_;
1057 }
1059  return perturber_;
1060 }
1061 
1062 //Allow a developer to set a custom high resolution mover
1064 {
1066 
1067  // If docking_highres_mover_ has been configured with custom scorefxns, we will tell DockingProtocol.
1068  if ( docking_highres_mover_->scorefxn() && docking_highres_mover_->scorefxn_pack() )
1069  {
1070  set_highres_scorefxn( docking_highres_mover_->scorefxn(), docking_highres_mover_->scorefxn_pack() );
1071  }
1072  else if ( docking_highres_mover_->scorefxn() && ! docking_highres_mover_->scorefxn_pack() )
1073  {
1075  }
1076 }
1077 
1079 {
1081  {
1083  }
1084  additional_low_resolution_steps_->add_mover( additional_low_resolution_mover );
1085 }
1086 
1087 /// @details Show the complete setup of the docking protocol
1088 void
1089 DockingProtocol::show( std::ostream & out ) {
1092  }
1093  out << *this;
1094 }
1095 
1096 std::ostream & operator<<(std::ostream& out, const DockingProtocol & dp )
1097 {
1098  using namespace ObjexxFCL::fmt;
1099 
1100  // All output will be 80 characters - 80 is a nice number, don't you think?
1101  std::string line_marker = "///";
1102  out << "////////////////////////////////////////////////////////////////////////////////" << std::endl;
1103  out << line_marker << A( 47, "Rosetta 3 Docking Protocol" ) << space( 27 ) << line_marker << std::endl;
1104  out << line_marker << space( 74 ) << line_marker << std::endl;
1105  // Display the movable jumps that will be used in docking
1106  out << line_marker << " Dockable Jumps: ";
1107 
1108  core::Size spaces_so_far = 23;
1109  bool first = true;
1110  for ( DockJumps::const_iterator it = dp.movable_jumps_.begin() ; it != dp.movable_jumps_.end() ; ++it ){
1111  if (!first) {
1112  out << ", ";
1113  spaces_so_far += 2;
1114  }
1115  else first = false;
1116 
1117  out << I( 1, *it );
1118  spaces_so_far += 1;
1119  }
1120  core::Size remaining_spaces = 80 - spaces_so_far;
1121  if ( remaining_spaces > 0 ) out << space( 80 - spaces_so_far );
1122  out << line_marker << std::endl;
1123 
1124  // Display the state of the low resolution docking protocol that will be used
1125  out << line_marker << " Low Resolution Docking Protocol: " << ( ( dp.docking_lowres_mover_ ) ? ( " on " ) : ( "off " ) );
1126  out << space( 35 ) << line_marker << std::endl;
1127 
1128  // Display the state of the low resolution docking protocol that will be used
1129  out << line_marker << " High Resolution Docking Protocol: " << ( ( dp.docking_highres_mover_ ) ? ( " on " ) : ( "off " ) );
1130  out << space( 35 ) << line_marker << std::endl;
1131 
1132  // Display the state of the filters (on or off)
1133  out << line_marker << " Low Resolution Filter: " << ( ( dp.lowres_filter_ ) ? ( " on " ) : ( "off " ) );
1134  out << space( 45 ) << line_marker << std::endl;
1135  out << line_marker << " High Resolution Filter: " << ( ( dp.highres_filter_ ) ? ( " on " ) : ( "off " ) );
1136  out << space( 45 ) << line_marker << std::endl;
1137 
1138  // Close the box I have drawn
1139  out << "////////////////////////////////////////////////////////////////////////////////" << std::endl;
1140  return out;
1141 }
1142 
1143 void
1145 {
1146  using namespace core::scoring;
1147 
1148  if( tag->hasOption("docking_score_low" ) ){
1149  std::string const score_low( tag->getOption<std::string>( "docking_score_low" ) );
1150  ScoreFunctionOP scorelo = new ScoreFunction( *data.get< ScoreFunction * >( "scorefxns", score_low ) );
1151  set_lowres_scorefxn(scorelo);
1152  }
1153  if( tag->hasOption("docking_score_high" ) ){
1154  std::string const score_high( tag->getOption<std::string>( "docking_score_high" ) );
1155  ScoreFunctionOP scorehi = new ScoreFunction( *data.get< ScoreFunction * >( "scorefxns", score_high ));
1156  set_highres_scorefxn(scorehi);
1157  }
1158  //get through partners
1159  if( tag->hasOption( "partners" ) ){
1160  std::string const partners( tag->getOption<std::string>( "partners") );
1161  set_partners(partners);
1162  }
1163  //initialize other flags to control behavior
1164  //do high res step or not
1165  set_low_res_protocol_only( tag->getOption<bool>( "low_res_protocol_only", 0 ) );
1166  //skip the low res step if true
1167  set_docking_local_refine( tag->getOption<bool>( "docking_local_refine", 0 ) );
1168  //minimze final full atom structure?
1169  set_dock_min( tag->getOption<bool>( "dock_min", 0 ) );
1170  //ignore the default docking task and define your own
1171  set_ignore_default_docking_task( tag->getOption<bool>( "ignore_default_docking_task", 0 ) );
1172  if( tag->hasOption( "task_operations" ) ){
1174  }
1175 
1176 }//end parse_my_tag
1177 
1178 
1181 {
1183 }
1184 
1187  return new DockingProtocol();
1188 }
1189 
1192 {
1193  return "DockingProtocol";
1194 }
1195 } //docking
1196 } //protocols