Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EnzdesBaseProtocol.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 protocols/enzdes/EnzdesBaseProtocol.cc
11 ///
12 /// @brief
13 /// @author Florian Richter, floric@u.washington.edu
14 
15 
16 //unit headers
18 
19 //package headers
30 #include <protocols/ligand_docking/ligand_functions.hh> //for minimizing ligand torsions
31 
32 
33 //project headers
36 // AUTO-REMOVED #include <core/conformation/Conformation.hh>
40 // AUTO-REMOVED #include <core/io/pdb/file_data.hh>
41 // AUTO-REMOVED #include <core/io/pdb/pose_io.hh>
45 #include <core/pose/Pose.hh>
46 #include <core/pose/PDBInfo.hh>
47 #include <basic/options/option.hh>
49 #include <core/scoring/Energies.hh>
55  //needed for adding variant types in cst opt
57 #include <basic/Tracer.hh>
58 
61 
63 // AUTO-REMOVED #include <utility/string_util.hh>
64 
65 #include <utility/io/izstream.hh>
66 
67 
68 // option key includes
69 
70 #include <basic/options/keys/score.OptionKeys.gen.hh>
71 #include <basic/options/keys/packing.OptionKeys.gen.hh>
72 #include <basic/options/keys/enzdes.OptionKeys.gen.hh>
73 #include <basic/options/keys/docking.OptionKeys.gen.hh>
74 #include <basic/options/keys/in.OptionKeys.gen.hh>
75 
78 #include <core/pose/util.hh>
79 #include <utility/vector0.hh>
80 #include <utility/vector1.hh>
81 
82 
83 
84 namespace protocols{
85 namespace enzdes{
86 
87 static basic::Tracer tr("protocols.enzdes.EnzdesBaseProtocol");
88 
90  LigandBaseProtocol(),
91  bb_min_allowed_dev_(0.5),
92  loop_bb_min_allowed_dev_(0.5),
93  lig_superposition_file_read_(false),
94  rb_min_(true),
95  exclude_protein_protein_hack_elec_(true)
96 {
97 
98  Mover::type( "EnzdesFixBBProtocol" );
100  //cst_io_ = new toolbox::match_enzdes_util::EnzConstraintIO(restype_set_);
101  //catalytic_res_.clear();
102  atoms_to_superimpose_on_.clear();
103  bb_min_allowed_dev_ = basic::options::option[ basic::options::OptionKeys::enzdes::bb_min_allowed_dev];
104  loop_bb_min_allowed_dev_ = basic::options::option[ basic::options::OptionKeys::enzdes::loop_bb_min_allowed_dev];
105  include_all_design_targets_in_design_interface_ = basic::options::option[ basic::options::OptionKeys::enzdes::include_catres_in_interface_detection];
106 
107  // std::string score_patch = basic::options::option[ basic::options::OptionKeys::score::patch ];
108 
109  // if( score_patch == "" ) reduced_sfxn_ = core::scoring::ScoreFunctionFactory::create_score_function( "enzdes_polyA_min" );
110  // else reduced_sfxn_ = core::scoring::ScoreFunctionFactory::create_score_function( "enzdes_polyA_min", score_patch );
111  using namespace basic::options;
112  using namespace core::scoring;
113  reduced_sfxn_ = ScoreFunctionFactory::create_score_function( "enzdes_polyA_min", option[ OptionKeys::score::patch ]() );
114 
115  if( basic::options::option[basic::options::OptionKeys::enzdes::chi_min].user() )chi_min_ = true;
116  else chi_min_= false;
117 
118  if( basic::options::option[basic::options::OptionKeys::enzdes::bb_min].user() )bb_min_ = true;
119  else bb_min_= false;
120 
121  bb_backrub_ = false; //not really used here so false, but can be set to true using the set_minimize_options function
122 
123  if( basic::options::option[basic::options::OptionKeys::enzdes::min_all_jumps].user() )min_all_jumps_ = true;
124  else min_all_jumps_ = false;
125 
126  if( basic::options::option[basic::options::OptionKeys::enzdes::minimize_ligand_torsions].user() ){
129  lig_min_stddev_= basic::options::option[basic::options::OptionKeys::enzdes::minimize_ligand_torsions].value();
130  }
131  else {
132  if( basic::options::option[basic::options::OptionKeys::enzdes::minimize_all_ligand_torsions].user() ){
135  lig_min_stddev_= basic::options::option[basic::options::OptionKeys::enzdes::minimize_ligand_torsions].value();
136  }
137  else {
140  lig_min_stddev_= 0.0;
141  }
142  }
143  if( basic::options::option[basic::options::OptionKeys::enzdes::fix_catalytic_aa].user() ) fix_catalytic_aa_ = true;
144  else fix_catalytic_aa_= false;
145 
146  //if( basic::options::option[basic::options::OptionKeys::score::weights].user() ){
147  // std::string weights_tag = basic::options::option[basic::options::OptionKeys::score::weights];
148  // scorefxn_->initialize_from_file( basic::database::full_name( "scoring/weights/"+weights_tag+".wts" ) );
149  //}
150  if ( basic::options::option[ basic::options::OptionKeys::score::weights ].user() ) {
151  scorefxn_ = core::scoring::getScoreFunction(); // This call handles the database vs working directory resolution -- DONT SUBVERT OR DUPLICATE IT
152  }
153  else {
154  scorefxn_ = ScoreFunctionFactory::create_score_function( "enzdes", option[ OptionKeys::score::patch ]() );
155  /* if( score_patch == "" ) scorefxn_ = core::scoring::ScoreFunctionFactory::create_score_function("enzdes");
156  else scorefxn_ = core::scoring::ScoreFunctionFactory::create_score_function("enzdes", score_patch);
157  */
158 
159  }
160 
161  if (scorefxn_->has_zero_weight( core::scoring::coordinate_constraint ) ){
163  }
164  else{
166  }
167  if (scorefxn_->has_zero_weight( core::scoring::atom_pair_constraint ) ){
169  }
170  else{
172  }
173  if (scorefxn_->has_zero_weight( core::scoring::angle_constraint ) ){
175  }
176  else{
178  }
179  if (scorefxn_->has_zero_weight( core::scoring::dihedral_constraint ) ){
181  }
182  else{
184  }
185 
186  if( basic::options::option[basic::options::OptionKeys::enzdes::favor_native_res].user() || basic::options::option[ basic::options::OptionKeys::in::file::pssm ].user() ){
187  if (scorefxn_->has_zero_weight( core::scoring::res_type_constraint ) ){
189  }
190  else{
192  }
193  }
195 
197 
198  if( basic::options::option[ basic::options::OptionKeys::docking::ligand::old_estat ].user() ){
199  exclude_protein_protein_hack_elec_ = basic::options::option[ basic::options::OptionKeys::docking::ligand::old_estat ];
200  }
202  core::scoring::methods::EnergyMethodOptions options( scorefxn_->energy_method_options() );
203  options.exclude_protein_protein_hack_elec( true );
204  scorefxn_->set_energy_method_options( options );
205  }
206 
207 
208  //set the native pose if requested
209  if( basic::options::option[basic::options::OptionKeys::in::file::native].user() ){
210  core::pose::PoseOP natpose = new core::pose::Pose();
211  core::import_pose::pose_from_pdb( *natpose, basic::options::option[basic::options::OptionKeys::in::file::native].value() );
212  (*scorefxn_)( *natpose);
213  this->set_native_pose( natpose );
214  }
215 
216  //increase the chainbreak weight. 1.0 is apparently not enough for some constraints
217  //scorefxn_->set_weight( core::scoring::chainbreak, 10.0 );
218 
219 } //EnzdesBaseProtocol constructor
220 
221 
224  return "EnzdesBaseProtocol";
225 }
226 
229 {
230  using namespace core;
231  utility::vector1< Size > to_return;
232  protocols::toolbox::match_enzdes_util::EnzdesCacheableObserverCOP enz_obs( toolbox::match_enzdes_util::get_enzdes_observer( pose ) ); // toolbox::match_enzdes_util::get_enzdes_observer() for const pose can return NULL
233  if( enz_obs ) {
234  toolbox::match_enzdes_util::EnzdesCstCacheCOP cstcache (enz_obs->cst_cache() );
235  if( cstcache ) to_return = cstcache->enzcst_io()->ordered_constrained_positions( pose );
236  }
237 
238  if( to_return.size() == 0 ){
239  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i){
240  if( pose.residue_type( i ).is_ligand() ) to_return.push_back( i );
241  }
242  }
243  return to_return;
244 }
245 
246 std::set< core::Size > const &
248 {
249  design_targets_.clear();
250 
251  for(core::Size i = 1; i <= pose.total_residue(); ++i){
252  if( enzutil::is_catalytic_seqpos( pose, i ) ) design_targets_.insert( i ); //Changed to is_catalytic_seqpos to avoid problems with running parser with no constraints -mdsmith
253  }
254  //if no positions are constrained, we'll put the ligands into the array
255  if( design_targets_.size() == 0 ){
256  for(core::Size i = 1; i <= pose.total_residue(); ++i){
257  if( pose.residue_type(i).is_ligand() ) design_targets_.insert( i );
258  }
259  }
260  return design_targets_;
261 }
262 
263 
264 void
266 {
267 
268  using namespace basic::options;
269  using namespace basic::options::OptionKeys;
270 
271  option.add_relevant( in::file::native );
272  option.add_relevant( in::file::s );
273  option.add_relevant( in::file::l );
274  option.add_relevant( OptionKeys::score::weights );
275  option.add_relevant( OptionKeys::score::patch );
276  option.add_relevant( OptionKeys::packing::soft_rep_design );
277 
282 
283  option.add_relevant( OptionKeys::enzdes::detect_design_interface );
284  option.add_relevant( OptionKeys::enzdes::include_catres_in_interface_detection );
285  option.add_relevant( OptionKeys::enzdes::fix_catalytic_aa );
286  option.add_relevant( OptionKeys::enzdes::ex_catalytic_rot );
287  option.add_relevant( OptionKeys::enzdes::cst_min );
288  option.add_relevant( OptionKeys::enzdes::chi_min );
289  option.add_relevant( OptionKeys::enzdes::bb_min );
290  option.add_relevant( OptionKeys::enzdes::bb_min_allowed_dev );
291  option.add_relevant( OptionKeys::enzdes::loop_bb_min_allowed_dev );
292  option.add_relevant( OptionKeys::enzdes::enz_debug );
293  option.add_relevant( OptionKeys::enzdes::no_packstat_calculation );
294  option.add_relevant( OptionKeys::enzdes::compare_native );
295  option.add_relevant( OptionKeys::enzdes::favor_native_res );
296  option.add_relevant( OptionKeys::docking::ligand::old_estat );
297 
298 }
299 
300 
303  core::pose::Pose & pose,
304  bool design
305 ){
306 
307  using namespace core::pack::task;
308  using namespace basic::options;
309 
310  //make sure the design targets are up to date
311  design_targets( pose );
312 
313  DetectProteinLigandInterfaceOP detect_enzdes_interface = new DetectProteinLigandInterface();
314  detect_enzdes_interface->set_design(design);
316  detect_enzdes_interface->set_design_target_res( design_targets_ );
317  }
318  TaskFactory taskfactory;
320  taskfactory.push_back( detect_enzdes_interface);
321  if( design ) { // upweight ligand interactions and remove bad aromatic rotamers during design only
322  taskfactory.push_back( new ProteinLigandInterfaceUpweighter() );
323  taskfactory.push_back( new toolbox::task_operations::LimitAromaChi2Operation() );
324  }
326  taskfactory.push_back( new AddRigidBodyLigandConfs() );
327  }
328  if( basic::options::option[basic::options::OptionKeys::enzdes::detect_design_interface].user() ){
330  catpack->set_fix_catalytic_aa( this->fix_catalytic_aa_ );
331  taskfactory.push_back( catpack );
332  }
333  if( basic::options::option[basic::options::OptionKeys::enzdes::run_ligand_motifs].user() ){
334  taskfactory.push_back( new AddLigandMotifRotamers() );
335  }
336 
337  PackerTaskOP task = taskfactory.create_task_and_apply_taskoperations( pose );
338  task->append_rotamerset_operation( unboundrot_ );
339 
340  setup_sequence_recovery_cache( pose, *task );
341  return task;
342 
343 } //create_enzdes_pack_task
344 
345 void
347  core::pose::Pose & pose,
348  core::pack::task::PackerTask const & task
349 ) const
350 {
351  //Initiate sequence recovery cache in the enzdes observer
352  //Set wt sequence at the same time. That is the first and only time
353  //that the wt sequence gets initiated
354  if ( ! toolbox::match_enzdes_util::get_enzdes_observer( pose ) -> get_seq_recovery_cache() ){
356  toolbox::match_enzdes_util::get_enzdes_observer( pose ) -> get_seq_recovery_cache() -> set_sequence( pose );
357  }
358 
359  //keep track of what residues we are designing
360  std::set < core::Size > designing_residues;
361  for(core::Size jj=1; jj<=pose.total_residue(); ++jj) {
362  if (pose.residue(jj).is_protein() && task.being_designed(jj) ) {
363  designing_residues.insert( jj );
364  }
365  }
366  //update or initiate what residues are designed in the EnzdesSeqRecoveryCache
367  toolbox::match_enzdes_util::get_enzdes_observer( pose ) -> get_seq_recovery_cache()
368  -> set_designable_residues( designing_residues );
369 }
370 
371 ///@details This function will modify the fold tree and add constraints to the pose if used with the bb_min and minimize_ligand_torsions options. Be WARNED!
374  core::pose::Pose & pose,
376  bool min_all_jumps
377 ) const
378 {
380  movemap->set_jump( false );
381  movemap->set_chi( false );
382  movemap->set_bb( false );
383  core::Size jump_id (pose.num_jump()); //default jump-id last
384  utility::vector1< bool > allow_move_bb(pose.total_residue(), false );
385 
386  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i) {
387  if ( task->pack_residue(i) && pose.residue(i).is_polymer() ){
388  if(chi_min_ ) movemap->set_chi(i, true);
389  if(bb_min_ ) {
390  allow_move_bb[i] = true;
391  }
392  }
393  }
394 
395  if (rb_min_) {
396  for (core::Size i = 1;i<=pose.num_jump();++i){
397  if (min_all_jumps) movemap->set_jump( i, true );
398  else {
399  core::Size upstream_jump_res, downstream_jump_res;
400  upstream_jump_res = pose.fold_tree().upstream_jump_residue( i );
401  downstream_jump_res = pose.fold_tree().downstream_jump_residue( i );
402  if ( pose.residue( upstream_jump_res ).is_ligand() || pose.residue( downstream_jump_res ).is_ligand() ) {
403  movemap->set_jump( i, true );
404  jump_id= i;
405  }
406  }
407  }
408  }
409 
410  //for the minimization to work properly, each residue that is minimized has to be part of a stretch of at least 4 other residues
411  //so we need to allow a couple of more residues to move
412  //core::Real initial_cbreak;
413  if( bb_min_ || bb_backrub_ ){
414  core::Size window = 4;
415 
417  tr.Info << "Doing a pose minimization... the backbone is allowed to move at positions: ";
418  for(core::Size i = 1; i <= pose.total_residue(); ++i){
419  if( allow_move_bb[i] && pose.residue(i).is_polymer() ){
420  movemap->set_bb(i, true);
421  tr.Info << i <<", ";
422  }
423  }
424  tr.Info << std::endl;
425  if (bb_min_) setup_bbmin_ft_and_csts( pose, allow_move_bb, jump_id ); //NOTE: this will modify fold tree and constraints set of the pose
426  }
427 
428  //allow ligand minimization if requested
430  core::Size const lig_id = get_ligand_id(pose, jump_id);
431  using namespace protocols::ligand_docking;
432  core::Real lig_min_stddev = lig_min_stddev_;
433  bool minimize_all_ligand_torsions = minimize_all_ligand_torsions_;
434  if (lig_min_stddev==0.0){
435  tr.Info<< "**WARNING!! ligand minimization requested without specifying allowed deviation value!! Setting it to 10.0 degrees and allowing all torsions to minimize"<<std::endl;
436  lig_min_stddev= 10.0;
437  minimize_all_ligand_torsions = true;
438  }
439  constrain_ligand_torsions(pose,lig_min_stddev,minimize_all_ligand_torsions); //NOTE: this will modify the constraints set of the pose
440  movemap->set_chi(lig_id, true);
441  }
442 return movemap;
443 }
444 
445 void
447 core::pose::Pose & pose,
448 utility::vector1< bool > allow_move_bb,
449 core::Size jump_id ) const
450 {
451  core::Size const lig_id = jump_id !=0 ? get_ligand_id(pose, jump_id): 0;
452  //restraining function for Calphas. should allow fairly liberal movement ~0.1A from the original position,
453  //but severly limits movement beyond this
456 
457  //note flo feb '11 reordering the foldtree will change residue types and can thus have an
458  //effect on constraints, which is a nasty bug bc different constraints will be enforced.
459  //to prevent this, we clone the constraint set from the old pose to the new.
460  //prolly not the cheapest way to do stuff, but wutevs..
461  if( pose.constraint_set()->has_constraints() ){
462  core::pose::Pose init_pose = pose;
463  reorder_foldtree_around_mobile_regions( pose, jump_id, allow_move_bb, lig_id );
464  pose.constraint_set( init_pose.constraint_set()->remapped_clone( init_pose, pose ) );
465  }
466  else reorder_foldtree_around_mobile_regions( pose, jump_id, allow_move_bb, lig_id );
467 
468  core::scoring::dssp::Dssp ss_pose(pose);
469  utility::vector1< bool > allow_move_bb_loop(pose.total_residue(), false );
470  utility::vector1< bool > allow_move_bb_ss(pose.total_residue(), false );
471  for (core::Size i=1; i<=pose.total_residue(); ++i){
472  if( !pose.residue(i).is_protein() ) continue;
473  if(ss_pose.get_dssp_secstruct(i) == ' ' && allow_move_bb[i]){
474  allow_move_bb_loop[i]=true;
475  } else if(allow_move_bb[i]){
476  allow_move_bb_ss[i]=true;
477  }
478  }
479  restrain_protein_Calphas(pose, allow_move_bb_ss, ss_ca_restr_func );
480  restrain_protein_Calphas(pose, allow_move_bb_loop, loop_ca_restr_func );
481 }
482 
483 void
485  core::pose::Pose & pose,
488  core::Size cycles,
489  bool minimize_after_packing,
490  bool pack_unconstrained,
491  bool favor_native
492 ) const
493 {
494 
495  if( pack_unconstrained ) remove_enzdes_constraints( pose, true );
496 
497  if( favor_native ){
498  toolbox::match_enzdes_util::get_enzdes_observer( pose )->setup_favor_native_constraints( pose, task, *(this->get_native_pose()) );
499  }
500 
501  core::pack::task::PackerTaskCOP usetask = task;
503 
504  for( core::Size cycle = 1; cycle <= cycles; ++cycle){
505 
506  //soft_rep we'll only do this if the task is to be designed and not the last cycle,
507  //because we really don't want any clashes
508  bool soft_rep ( basic::options::option[basic::options::OptionKeys::packing::soft_rep_design] && usetask->design_any() && (cycle < cycles ) );
509 
510  if( soft_rep ) packsfxn = soft_scorefxn_;
511  else packsfxn = scorefxn;
513 
514  enzdes_pack->apply(pose);
515 
516  if(minimize_after_packing) cst_minimize(pose, task);
517 
518  usetask = enzutil::recreate_task( pose, *task );
519 
520  } //cycle loop
521 
522 
523  if( basic::options::option[basic::options::OptionKeys::enzdes::favor_native_res].user() && favor_native){
524  toolbox::match_enzdes_util::get_enzdes_observer( pose )->remove_favor_native_constraints( pose );
525  }
526 
527  if( pack_unconstrained) add_pregenerated_enzdes_constraints( pose );
528 
529  (*scorefxn)( pose );
530 
531  if( task->design_any() ){
533  if( cstio ) cstio->update_pdb_remarks_for_backbone_params( pose );
534  }
535 
536 } //design function
537 
538 
539 void
541  core::pose::Pose & pose,
542  bool allow_missing_remark_blocks
543 ) const {
544 
545  AddOrRemoveMatchCsts cstmover;
546  cstmover.set_cst_action( ADD_NEW );
547  cstmover.set_accept_blocks_missing_header( allow_missing_remark_blocks );
548  cstmover.apply( pose );
549 
550  tr.Info << "Catalytic residues (pose numbering) are: ";
551  for( core::Size i = 1; i <= pose.total_residue(); ++i){
552  if( is_catalytic_position( pose, i ) ) tr.Info << i << " ";
553  }
554  tr.Info << std::endl;
555 
556 } //setup enzdes constraints function
557 
558 
559 void
561  core::pose::Pose & pose,
562  bool keep_covalent
563 ) const
564 {
565  AddOrRemoveMatchCsts cstmover;
566  cstmover.set_cst_action( REMOVE );
567  cstmover.set_keep_covalent( keep_covalent );
568  cstmover.apply( pose );
569 }
570 
571 void
573  core::pose::Pose & pose
574 ) const
575 {
576  AddOrRemoveMatchCsts cstmover;
577  cstmover.set_cst_action( ADD_PREGENERATED );
578  cstmover.apply( pose );
579 }
580 
581 
582 void
584  core::pose::Pose & pose,
586  bool cst_opt
587 ) const
588 {
589 
590 
591  core::pose::Pose old_Pose = pose; //copy old pose
592  core::scoring::ScoreFunctionOP min_scorefxn;
593  //core::scoring::constraints::ConstraintSetOP saved_constraints;
594 
595  if(cst_opt){
596 
597  min_scorefxn = reduced_sfxn_;
598 
599 
600  utility::vector1< core::Size >positions_to_replace;
601 
602  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i) {
603 
604  if( task->pack_residue(i) && ( ! is_catalytic_position( pose, i ) ) ) positions_to_replace.push_back( i );
605  }
606 
607  protocols::toolbox::pose_manipulation::construct_poly_ala_pose( pose, positions_to_replace, true, true, true );
608 
609  }
610 
611  else { min_scorefxn = scorefxn_; }
612 
613  if(basic::options::option[basic::options::OptionKeys::enzdes::enz_debug] ){
614  //debug stage: only interested in constraints minimization for now
615  //restrict move map to only move ligand along jump and the three
616  //catalytic res
617  min_scorefxn = reduced_sfxn_->clone();
618  min_scorefxn->reset();
619  min_scorefxn->set_weight(core::scoring::chainbreak, 1.0);
620  min_scorefxn->set_weight(core::scoring::omega, 0.0 );
621  min_scorefxn->set_weight(core::scoring::coordinate_constraint, 1.0);
622  min_scorefxn->set_weight(core::scoring::atom_pair_constraint, 1.0);
623  min_scorefxn->set_weight(core::scoring::angle_constraint, 1.0);
624  min_scorefxn->set_weight(core::scoring::dihedral_constraint, 1.0);
625 
626  }
627 
628  //temporarily set chainbreak score very high, to prevent chainbreaks from opening
629  //this has sometimes been observed in case of highly constrained systems
630  core::Real orig_cbreak_weight = min_scorefxn->weights()[ core::scoring::chainbreak ];
631  if( orig_cbreak_weight < 10.0 ) min_scorefxn->set_weight( core::scoring::chainbreak, 10.0);
632 
633  //create movemap
635  //setting up move map done, now do minimization
636  protocols::simple_moves::MinMoverOP dfpMinTightTol = new protocols::simple_moves::MinMover( movemap, min_scorefxn, "dfpmin_armijo_nonmonotone_atol", 0.02, true /*use_nblist*/ );
637  dfpMinTightTol->apply(pose);
638 
639  min_scorefxn->set_weight( core::scoring::chainbreak, orig_cbreak_weight);
640  (*min_scorefxn)( pose );
641 
642  MinimizeStoredRBConfs stored_rb_min( min_scorefxn );
643  stored_rb_min.apply( pose );
644  //core::Real post_cbreak = pose.energies().total_energies()[ core::scoring::chainbreak ];
645  //std::cerr << "chainbreak score postmin " << post_cbreak << std::endl;
646 
647 
648  //now we have to reinstate the orginial pose, so the task is still valid
649  if(cst_opt){
650 
651  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i) {
652 
653  if ( task->pack_residue(i) && ( !is_catalytic_position( pose, i ) ) ){
654  pose.replace_residue( i, old_Pose.residue(i), true );
655  }
656  }
657  }
658 
660 
661  pose.constraint_set( old_Pose.constraint_set()->clone() );
662  pose.fold_tree( old_Pose.fold_tree() );
663  if (bb_min_){
664  //put back the right variants
665  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i) {
666 
667  if( !pose.residue_type( i ).variants_match( old_Pose.residue_type( i ) ) ){
668 
669  utility::vector1< std::string > const new_var_types( pose.residue_type( i ).variant_types() );
670  utility::vector1< std::string > const old_var_types( old_Pose.residue_type( i ).variant_types() );
671  for( utility::vector1< std::string >::const_iterator newvars = new_var_types.begin(); newvars != new_var_types.end(); ++newvars ){
672  if( !old_Pose.residue_type( i ).has_variant_type( *newvars ) ) core::pose::remove_variant_type_from_pose_residue( pose, *newvars, i );
673  }
674 
675  for( utility::vector1< std::string >::const_iterator oldvars = old_var_types.begin(); oldvars != old_var_types.end(); ++oldvars ){
676  if( !pose.residue_type( i ).has_variant_type( *oldvars ) ) core::pose::add_variant_type_to_pose_residue( pose, *oldvars, i );
677  }
678 
679 
680  } //if variants don't match
681  }
682  } //if bb_min
683  (*min_scorefxn)( pose ); //just to be safe
684  } //if bb_min || minimize_ligand
685  if(basic::options::option[basic::options::OptionKeys::enzdes::enz_debug] ){
686  pose.dump_scored_pdb("aftermin_pose.pdb", *min_scorefxn);
687  }
688 
689 }
690 
691 bool
693 {
694  return enzutil::is_catalytic_seqpos( pose, seqpos );
695 }
696 
697 void
699 
705 
706 }
707 
708 void
710 
717 
720  scorefxn_->set_weight(core::scoring::angle_constraint, 0.0 );
723 
724 }
725 
726 
727 bool
729  core::pose::Pose & pose,
730  bool check_bb_clashes,
732 ){
733 
734  if( !lig_superposition_file_read_ ) read_ligand_superposition_file(basic::options::option[basic::options::OptionKeys::enzdes::change_lig].value() );
735 
736  utility::vector1< core::Size > ligs_to_exchange;
737  for( core::Size i = 1; i <= pose.total_residue(); ++i ){
738  if( pose.residue(i).name3() == res_to_superimpose_.first ) ligs_to_exchange.push_back( i );
739  }
740 
741  core::conformation::Residue new_res( restype_set_->name_map( res_to_superimpose_.second ), true );
742 
743  for( utility::vector1< core::Size >::const_iterator pos_it = ligs_to_exchange.begin();
744  pos_it != ligs_to_exchange.end(); ++pos_it )
745  {
746 
747  pose.replace_residue( *pos_it, new_res, atoms_to_superimpose_on_ );
748 
749  //we should probably do this
751 
752  // if we don't care for backbone clashes, we are already done
753  if( check_bb_clashes ){
754 
755  //otherwise, we now have to check for bb_clashes with the new residue
756 
758  get_non_bb_clashing_rotamers( pose, *pos_it, scofx, accepted_rotamers );
759 
760  //DEBUG SHIT
761  //core::pose::Pose debugpose = pose;
762  //core::Size dei(0);
763  //for( utility::vector1< core::conformation::ResidueOP >::iterator rot_it = accepted_rotamers.begin(); rot_it != accepted_rotamers.end(); ++rot_it ){
764  //dei++;
765  //debugpose.replace_residue( *pos_it, **rot_it, true );
766  //debugpose.dump_pdb( "rodebug"+utility::to_string( dei ) );
767  //}
768  //DEBUG SHIT over
769 
770  if( accepted_rotamers.size() == 0 ) return false;
771 
772  tr << "There are " << accepted_rotamers.size() << " rotamers that don't clash with the backbone." << std::endl;
773 
774  //we should put one of the non_clashing rotamers into the pose, just to make sure...
775  pose.replace_residue( *pos_it, *accepted_rotamers[1], true );
776  }
777 
778  //now we also have to change the remarks
779  core::pose::Remarks & remarks = pose.pdb_info()->remarks();
780  for( std::vector< core::pose::RemarkInfo >::iterator rem_it = remarks.begin(); rem_it != remarks.end(); ++rem_it ){
781 
782  std::string chainA(""), resA(""),chainB(""),resB("");
783  core::Size cst_block(0), exgeom_id(0);
784  int seqposA(0), seqposB(0);
785  if( toolbox::match_enzdes_util::split_up_remark_line( rem_it->value, chainA, resA, seqposA, chainB, resB, seqposB, cst_block, exgeom_id ) ){
786 
787  bool line_changed( false );
788 
789  if( resA == res_to_superimpose_.first ){
790  if( seqposA == (int) *pos_it || seqposA == 0 ) {
791  resA = res_to_superimpose_.second;
792  line_changed=true;
793  }
794  }
795  else if( resB == res_to_superimpose_.first ){
796  if( seqposB == (int) *pos_it || seqposB == 0 ) {
797  resB = res_to_superimpose_.second;
798  line_changed=true;
799  }
800  }
801 
802  if( line_changed ){
803  rem_it->value = toolbox::match_enzdes_util::assemble_remark_line( chainA, resA, seqposA, chainB, resB, seqposB, cst_block, exgeom_id );
804  }
805  }
806  }
807  } //lig_positions to exchange
808 
809 
810  return true;
811 
812 } //exchange_ligands_in_pose
813 
814 
817  return reduced_sfxn_;
818 }
819 
822  return reduced_sfxn_;
823 }
824 
827  core::pose::Pose const & pose
828 ) const
829 {
830  core::Real return_val(0.0);
831  using namespace core::scoring;
832 
833  for( std::set< core::Size >::const_iterator des_it = design_targets_.begin();
834  des_it != design_targets_.end(); ++des_it ){
835 
836  return_val += pose.energies().residue_total_energy( *des_it );
837  }
838 
839  return return_val;
840 }//design targets score
841 
842 
843 void
845  core::pose::Pose const & pose,
846  core::id::SequenceMapping const & //smap
847 )
848 {
849  //cst_io_->remap_resid( smap );
850  design_targets( pose );
851 }
852 
853 
854 
855 void
857  core::pose::Pose const & orig_pose,
860 )
861 {
862 
863  ligrot_poses.clear();
864 
865  //std::cerr << "staring generate explictligrot function, looking for residues of type " << basic::options::option[ basic::options::OptionKeys::enzdes::process_ligrot_separately ].value() << std::endl;
866 
867  for( core::Size i = 1; i <= orig_pose.total_residue(); ++ i ){
868 
869  if( orig_pose.residue( i ).name3() != basic::options::option[ basic::options::OptionKeys::enzdes::process_ligrot_separately ].value() ) continue;
870 
872  get_non_bb_clashing_rotamers( orig_pose, i, scofx, accepted_rotamers );
873 
874  for( utility::vector1< core::conformation::ResidueCOP >::const_iterator rot_it = accepted_rotamers.begin();
875  rot_it != accepted_rotamers.end(); ++rot_it ){
876 
877  core::pose::PoseOP lig_pose = new core::pose::Pose( orig_pose );
878  lig_pose->replace_residue( i, **rot_it, true );
879 
880  ligrot_poses.push_back( lig_pose );
881 
882  }
883  //std::cerr << "There are " << accepted_rotamers.size() << " non_bb clashing residues at positon " << i << std::endl;
884  }
885 
886 } //generate_explicit_ligand_rotamer_poses
887 
888 void
890 {
891 
893  atoms_to_superimpose_on_.clear();
894 
895  bool switch_info_found( false );
896 
897  utility::io::izstream filedata( filename.c_str() );
898  std::istringstream line_stream;
899  std::string line("");
900 
901  if ( !filedata ) {
902  std::cerr << "ERROR:: Unable to open ligand superposition info file: "
903  << filename << std::endl;
904  std::exit( 1 );
905  }
906 
907  while( !filedata.eof() ) {
908  std::string key("");
909  getline(filedata,line);
910  line_stream.clear();
911  line_stream.str(line);
912  line_stream >> key;
913 
914  if( key == "SWITCH_NAME" ){
915 
916  line_stream >> res_to_superimpose_.first >> res_to_superimpose_.second;
917  switch_info_found = true;
918 
919  }
920 
921  if( key == "SUPERIMPOSE" ){
922 
923  std::string buf1(""), buf2("");
924  line_stream >> buf1 >> buf2;
925  atoms_to_superimpose_on_.push_back( std::pair< std::string, std::string > ( buf1, buf2 ) );
926 
927  }
928  }
929 
930  if( !switch_info_found ){
931  utility_exit_with_message("Error: "+filename+" does not specify which residues to switch!");
932  }
933 
934  if( atoms_to_superimpose_on_.size() < 3 ){
935  utility_exit_with_message("Error: "+filename+" specifies less than 3 atoms to superimpose on, unambiguous superposition not possible");
936  }
937 
938  tr << "read superposition info from " << filename << " ...";
940 
941 } //read_ligand_superposition_file
942 
943 void
945 
946  scorefxn_ = scorefxn->clone();
947 
948 }
949 
950 }//namespace enzdes
951 }//namespace protocols