Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EnzdesMovers.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file src/protocols/enzdes/EnzdesMovers.hh
11 /// @brief a collection of movers that are used at different stages in enzyme design
12 /// @author Sinisa Bjelic sinibjelic@gmail.com, Florian Richter, floric@u.washington.edu
13 
16 
17 // AUTO-REMOVED #include <protocols/enzdes/EnzdesFixBBProtocol.hh>
27 // AUTO-REMOVED #include <protocols/moves/DataMap.hh>
28 #include <protocols/moves/Mover.hh>
29 #include <utility/tag/Tag.hh>
30 
34 // AUTO-REMOVED
35 // AUTO-REMOVED #include <core/kinematics/MoveMap.hh>
36 #include <basic/options/option.hh>
37 #include <core/pose/Pose.hh>
49 // AUTO-REMOVED #include <core/scoring/constraints/AtomPairConstraint.hh>
51 #include <basic/Tracer.hh>
52 #include <core/id/AtomID.hh>
53 
54 #include <utility/string_util.hh>
55 // AUTO-REMOVED #include <utility/io/izstream.hh>
57 
58 // option key includes
59 #include <basic/options/keys/enzdes.OptionKeys.gen.hh>
60 
61 #include <utility/vector0.hh>
62 #include <utility/vector1.hh>
63 
64 
65 namespace protocols {
66 namespace enzdes {
67 
68 static basic::Tracer mv_tr("protocols.enzdes.PredesignPerturbMover");
69 //PredesignPerturbMoverCreator
70 
71 EnzdesConstraintReporter::EnzdesConstraintReporter() : utility::pointer::ReferenceCount(),
72  ligand_seqpos_( 0 )
73 {}
74 
76 
78  utility::pointer::ReferenceCount(),
79  constrained_lig_atoms_( src.constrained_lig_atoms_ ),
80  constrained_nonligand_atoms_( src.constrained_nonligand_atoms_ ),
81  ligand_seqpos_( src.ligand_seqpos_ )
82 {}
83 
84 
85 void
87  core::pose::Pose const & pose
88 )
89 {
90  using namespace core::scoring::constraints;
91 
92  //Get a set of constraints for a ligand.
93  //It is a vector of ResidueConstraints.
94  ConstraintSetCOP constraint_set;
95  constraint_set=pose.constraint_set();
96 
97  // Each residue constraint is a map container
98  // of Size and ConstraintsOP, defining a residue number
99  //and constraints object respectively.
101  rpc_start = constraint_set->residue_pair_constraints_begin(ligand_seqpos_),
102  rpc_end=constraint_set->residue_pair_constraints_end(ligand_seqpos_);
103  rpc_start != rpc_end; ++rpc_start ) {
104  //Constraints object is a pointer vector of constraint objects.
105  // Each contraint object contains type of constraints.
106  ConstraintsOP constraints;
107  constraints=rpc_start->second;
108 
110  iter = constraints->begin(),
111  iter_end = constraints->end();
112  iter != iter_end; ++iter ) {
113  mv_tr.Info <<(*iter)->type() << std::endl;
114  if ( (*iter)->type() == "MultiConstraint" || (*iter)->type() == "AmbiguousConstraint" ) {
115  add_constrained_atoms_from_multiconstraint( dynamic_cast <MultiConstraint const * > ((*iter)()) );
116  } else if ( ((*iter)->type()) == "AtomPair") {
117  add_constrained_atoms_from_atom_pair_constraint( dynamic_cast <AtomPairConstraint const * > ((*iter)()) );
118  } // else, ignore this constraint
119  }
120  }
121 }
122 
123 void
125  core::scoring::constraints::MultiConstraintCOP real_multi_constraint )
126 {
127  core::scoring::constraints::ConstraintCOPs multi_constraint_members;
128  multi_constraint_members=real_multi_constraint->member_constraints();
129 
130  for (core::scoring::constraints::ConstraintCOPs::const_iterator
131  MC_it=multi_constraint_members.begin();
132  MC_it!=multi_constraint_members.end(); MC_it++) {
133  if ( ((*MC_it)->type()) == "AtomPair") {
134  assert( dynamic_cast <core::scoring::constraints::AtomPairConstraint const * > ((*MC_it)()) );
135  add_constrained_atoms_from_atom_pair_constraint( dynamic_cast <core::scoring::constraints::AtomPairConstraint const * > ((*MC_it)()) );
136  } else if ( ((*MC_it)->type()) == "MultiConstraint" || ((*MC_it)->type()) == "AmbiguousConstraint" ) {
137  assert( dynamic_cast <core::scoring::constraints::MultiConstraint const * > ((*MC_it)()) );
138  add_constrained_atoms_from_multiconstraint( (dynamic_cast <core::scoring::constraints::MultiConstraint const * > ((*MC_it)())) );
139  } // else, ignore this constraint
140  }
141 }
142 
143 void
146 )
147 {
148  // if ligand equals residue of atom1 then assign atom1
149  // otherwise asign the other atom
150  if ( atom_pair_constraint->atom(1).rsd() == ligand_seqpos_ ) {
151  add_constrained_lig_atom( atom_pair_constraint->atom(1).atomno() );
152  add_constrained_nonligand_atom( atom_pair_constraint->atom(2) );
153  } else {
154  add_constrained_lig_atom( atom_pair_constraint->atom(2).atomno() );
155  add_constrained_nonligand_atom( atom_pair_constraint->atom(1) );
156  }
157 }
158 
159 
160 void
162  core::Size atom_no
163 )
164 {
166  it = constrained_lig_atoms_.begin();
167  it != constrained_lig_atoms_.end(); it++){
168  if ( (*it) == atom_no) return;
169  }
170  constrained_lig_atoms_.push_back(atom_no);
171  if ( mv_tr.Info.visible()) {
172  mv_tr.Info << "Constrained ligand atom: " << std::endl;
173  mv_tr.Info << atom_no << std::endl;
174  }
175 }
176 
177 void
179  core::id::AtomID const & atid
180 )
181 {
183  it = constrained_nonligand_atoms_.begin();
184  it != constrained_nonligand_atoms_.end(); it++){
185  if ( (*it) == atid ) return;
186  }
187  constrained_nonligand_atoms_.push_back( atid );
188  if ( mv_tr.Info.visible()) {
189  mv_tr.Info << "Constrained non-ligand atom: res " << std::endl;
190  mv_tr.Info << atid.rsd() << " atom " << atid.atomno() << std::endl;
191  }
192 }
193 
194 
197 {
198  return new PredesignPerturbMover;
199 }
200 
203 {
205 }
206 
209 {
210  return "PredesignPerturbMover";
211 }
212 
213 //-------------PredesignPerturbMover-----------------//
214 
216  protocols::rigid::RigidBodyPerturbMover()
217 {
218  trans_magnitude(basic::options::option[basic::options::OptionKeys::enzdes::trans_magnitude]);
219  rot_magnitude(basic::options::option[basic::options::OptionKeys::enzdes::rot_magnitude]);
220  dock_trials_ = basic::options::option[basic::options::OptionKeys::enzdes::dock_trials];
221 }
222 
224 
225 void
227  core::pose::Pose &pose,
229 {
231 
232  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i) {
233  if( task -> design_residue(i) && !(cst_cache && cst_cache->contains_position(i)) )
234  positions_to_replace_.push_back(i);
235  }
236 
238  pose, positions_to_replace_, true, true, true );
239 }
240 
241 void
243  core::pose::Pose &pose,
244  core::pose::Pose const &old_Pose )
245 {
246  core::Size ires;
247  for(core::Size i=1, i_end=positions_to_replace_.size(); i<=i_end; ++i) {
248  ires=positions_to_replace_[i];
249  pose.replace_residue( ires, old_Pose.residue(ires), true);
250  }
251 }
252 
253 void
255  core::pose::Pose const & pose
256 )
257 {
259 }
260 
263 {
264  if ( constraint_reporter_.constrained_lig_atoms().size() != 0 ) {
266  } else { // Use geometric center of atoms
267  core::Vector geometric_center( 0.0 );
269  for ( core::Size ii(1); ii <= res.natoms(); ++ii) {
270  geometric_center += res.xyz(ii);
271  }
272  geometric_center /= res.natoms();
273  return geometric_center;
274  }
275 }
276 
279  core::pose::Pose const &pose)
280 {
281  assert( constraint_reporter_.constrained_lig_atoms().size() != 0 );
282 
283  core::Vector geometric_center( 0.0 );
286  it != constraint_reporter_.constrained_lig_atoms().end(); ++it ){
287  geometric_center+=pose.residue( constraint_reporter_.ligand_resno() ).xyz(*it);
288  }
289 
290  geometric_center /= constraint_reporter_.constrained_lig_atoms().size();
291 
292  return geometric_center;
293 }
294 
295 void
297  core::pose::Pose & pose
298 )
299 {
300  //make a poly ala of the designable
302  core::pose::Pose org_Pose(pose);
304  if ( task_factory_ !=0 ) task = task_factory_->create_task_and_apply_taskoperations( pose );
305  else
306  task = enzprot -> create_enzdes_pack_task( pose, true );
307  set_docking_pose( pose, task );
308 
310  pose,
312  2.0 /* temperature, from RosettaLigand paper */);
313  MCpredock->reset( pose );
314  MCpredock->reset_counters();
315 
317 
318  //itereate through all constraints in the pose and check for the constrained atoms
319  //ligand is always connected through the last jump
320  mv_tr.Info << "starting predocking ... " << std::endl;
321  for( core::Size i=1; i <= dock_trials_; ++i ){
323 
324  core::kinematics::Jump flexible_jump = pose.jump( pose.num_jump() );
325  core::kinematics::Stub downstream_stub = pose.conformation().downstream_jump_stub( pose.num_jump() );
326  flexible_jump.set_rb_center( dir_, downstream_stub, rot_center_ );
327 
328  flexible_jump.gaussian_move( dir_, trans_mag_, rot_mag_ );
329  pose.set_jump( pose.num_jump(), flexible_jump );
330  MCpredock->boltzmann(pose);
331 
332  }
333  MCpredock->show_counters();
334  MCpredock->recover_low( pose );
335  mv_tr.Info << "... done predocking" << std::endl;
336  //put back the old pose
337  reinstate_pose( pose, org_Pose );
338 }
339 
341 {
343 }
344 
345 
346 void
348  utility::tag::TagPtr const tag,
349  protocols::moves::DataMap & datamap,
352  core::pose::Pose const & pose)
353 {
354  trans_magnitude( tag -> getOption< core::Real >( "trans_magnitude", 0.1 ) );
355  rot_magnitude( tag -> getOption< core::Real >( "rot_magnitude", 2.0 ) );
356  dock_trials_ = tag -> getOption< core::Size >( "dock_trials", 100 );
358  if( tag->hasOption("task_operations") ) task_factory_ = ( protocols::rosetta_scripts::parse_task_operations( tag, datamap ) );
359  else task_factory_ = NULL;
360 
361 }
362 
365 {
366  return protocols::moves::MoverOP( new PredesignPerturbMover( *this ) );
367 }
368 
371 {
373 }
374 
377 {
378  return "PredesignPerturbMover";
379 }
380 
381 //-------RepackLigandSiteWithoutLigandMover----------//
382 
384  : sfxn_(NULL), lig_seqpos_(0), enzcst_io_(NULL), calculate_silent_Es_(false)
385 {
386  silent_Es_.clear();
387 }
388 
391  bool calculate_silent_Es
392  ) : sfxn_(sfxn), lig_seqpos_(0), enzcst_io_(NULL), calculate_silent_Es_(calculate_silent_Es)
393 {
394  silent_Es_.clear();
395 }
396 
398 
399 void
402 {
403  sfxn_ = sfxn;
404 }
405 
406 void
409 {
410  enzcst_io_ = enzcst_io;
411 }
412 
413 void
415  bool calculate )
416 {
417  calculate_silent_Es_ = calculate;
418 }
419 
420 void
422  core::pose::Pose & pose )
423 {
424  runtime_assert( sfxn_ );
425  //tmp hack
426  //the constraints can be a headache in this situation, so well completely take them out for now
427  // the problem is that some constrained interactions can be covalent, and the EnzConstraintIO
428  // object at the moment can't separately take out the constraints and the covalent connections
429  core::scoring::ScoreFunctionOP tmpsfxn = sfxn_->clone();
430  tmpsfxn->set_weight(core::scoring::coordinate_constraint, 0.0 );
431  tmpsfxn->set_weight(core::scoring::atom_pair_constraint, 0.0 );
432  tmpsfxn->set_weight(core::scoring::angle_constraint, 0.0 );
433  tmpsfxn->set_weight(core::scoring::dihedral_constraint, 0.0 );
434  sfxn_ = tmpsfxn;
435  //tmp hack over
436 
437  if( lig_seqpos_ == 0 ){
439  if( all_ligands.size() != 1 ) utility_exit_with_message( "Pose has more or less than one ligand. This mover atm can only hadndle poses with one ligand.");
440  lig_seqpos_ = all_ligands[1];
441  }
442  core::pose::PoseOP startpose;
443  utility::vector1< core::Size > special_res;
444  if( calculate_silent_Es_ ) startpose = new core::pose::Pose( pose );
445 
446  //1. if there are constraints between protein and ligand, we should take them out.
447  if( enzcst_io_ ){
448  if( calculate_silent_Es_ ) special_res = enzcst_io_->ordered_constrained_positions( pose );
449  enzcst_io_->remove_constraints_from_pose( pose, true /* keep covalent*/, false /*fail on missing*/ );
450  }
451  core::Real start_score( (*sfxn_)( pose ) );
452  if( enzcst_io_ ){
453  enzcst_io_->remove_constraints_from_pose( pose, false /* keep covalent*/, false /*fail on missing*/ );
454  }
455 
456  //2. construct the proper task
457  DetectProteinLigandInterfaceOP detect_enzdes_interface = new DetectProteinLigandInterface();
458  detect_enzdes_interface->set_design(false);
459  core::pack::task::TaskFactory taskfactory;
461  taskfactory.push_back( detect_enzdes_interface);
462  ptask_ = taskfactory.create_task_and_apply_taskoperations( pose );
463 
464  //3. shoot the ligand into space
466  (*sfxn_)( pose );
467  //pose.dump_pdb( "rlswlm_after_rigid.pdb");
468 
469  //4. repack
471  packer->apply( pose );
472  //pose.dump_pdb( "rlswlm_after_repack.pdb");
473 
474  //5. if requested, do more shit
475  if( calculate_silent_Es_ ){
476  //5a. Ediff
477  core::Real end_score( (*sfxn_)( pose ) );
478  //std::cerr << "start score=" << start_score <<", int score=" << int_score << ", end_score=" << end_score << std::endl;
479  silent_Es_.push_back( core::io::silent::SilentEnergy("nlr_dE", end_score - start_score, 1, 12 ) );
480 
481  //5b. rmsd of repackable region
482  ObjexxFCL::FArray1D_bool pack_region( ptask_->total_residue(), false );
483  for( core::Size i = 1; i <= ptask_->total_residue(); ++i ){
484  if( ptask_->residue_task( i ).being_packed() && pose.residue( i ).is_protein() ) pack_region( i ) = true;
485  }
486  core::Real pack_region_rmsd( core::scoring::rmsd_no_super_subset( *startpose, pose, pack_region, core::scoring::is_protein_sidechain_heavyatom ) );
487  silent_Es_.push_back( core::io::silent::SilentEnergy("nlr_totrms", pack_region_rmsd, 1, 12 ) );
488 
489  //5c. rmsds of any eventual special residues
490  for( core::Size i =1; i <= special_res.size(); ++i){
491  if( pose.residue_type( special_res[i] ).is_ligand() ) continue;
492  ObjexxFCL::FArray1D_bool pack_region( ptask_->total_residue(), false );
493  pack_region( special_res[i] ) = true;
494  core::Real spec_res_rmsd( core::scoring::rmsd_no_super_subset( *startpose, pose, pack_region, core::scoring::is_protein_sidechain_heavyatom ) );
495  std::string title( "nlr_SR"+utility::to_string( i )+"_rms");
496  silent_Es_.push_back( core::io::silent::SilentEnergy(title, spec_res_rmsd, 1, 14 ) );
497  }
498  }
499  //6. finally let's remove the ligand from the pose for completeness
500  if( enzcst_io_ ){
501  if( enzcst_io_->contains_position( pose, lig_seqpos_ ) ){
502  enzcst_io_->remove_position_from_template_res( pose, lig_seqpos_ );
503  //for now we'll wipe out the cst cache
504  toolbox::match_enzdes_util::get_enzdes_observer( pose )->set_cst_cache( NULL );
505  }
506  }
508  (*sfxn_)( pose ); //make sure energies are up to date
509  //pose.dump_pdb( "rlswlm_after_repackdel.pdb");
510 }
511 
514  return "RepackLigandSiteWithoutLigandMover";
515 }
516 
517 
518 void
520  core::pose::Pose & pose ) const
521 {
523  trans_mover.step_size( 666 );
524  trans_mover.apply( pose );
525 }
526 
529  return ptask_;
530 }
531 
532 } //enzdes
533 } //protocols
534