Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EnzRepackMinimize.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/EnzRepackMinimize.cc
11 /// @brief Repack/minimize class for rosetta_scripts-compatible enzdes
12 /// @author Sagar Khare (khares@uw.edu)
13 
14 // Unit headers
17 
18 //package headers
22 
23 // Project Headers
24 // AUTO-REMOVED #include <core/chemical/ResidueType.hh>
25 // AUTO-REMOVED #include <core/conformation/Residue.hh>
26 // AUTO-REMOVED #include <core/kinematics/FoldTree.hh>
31 #include <core/pose/Pose.hh>
34 
35 #include <numeric/random/random.hh>
36 
41 
42 #include <utility/tag/Tag.hh>
43 
44 #include <utility/vector0.hh>
45 #include <utility/vector1.hh>
46 
47 #include <basic/Tracer.hh>
48 
49 //Auto Headers
50 #include <boost/functional/hash.hpp>
51 
52 using namespace core;
53 using namespace core::scoring;
54 
55 static basic::Tracer TR( "protocols.enzdes.EnzRepackMinimize" );
56 
57 static numeric::random::RandomGenerator RG( 150847 ); // <- Magic number, do not change it!!!
58 
59 namespace protocols {
60 namespace enzdes {
61 
63 EnzRepackMinimizeCreator::keyname() const
64 {
65  return EnzRepackMinimizeCreator::mover_name();
66 }
67 
69 EnzRepackMinimizeCreator::create_mover() const
70 {
71  return new EnzRepackMinimize;
72 }
73 
75 EnzRepackMinimizeCreator::mover_name()
76 {
77  return "EnzRepackMinimize";
78 }
79 
80 EnzRepackMinimize::EnzRepackMinimize() :
81  protocols::moves::Mover( "EnzRepackMinimize" ),
82  cst_opt_( false ),
83  design_( false ), repack_( false ), fix_catalytic_( false ),
84  minimize_in_stages_( false ), min_rb_( true ), min_sc_( false ), min_bb_( false ),
85  min_lig_( false ), minimize_prot_jumps_( false ), backrub_( false ),
86  task_factory_(NULL),
87  n_cycles_( 1 )
88 {}
89 
91  protocols::moves::Mover ( name ),
92  cst_opt_( false ),
93  design_( false ), repack_( false ), fix_catalytic_( false ),
94  minimize_in_stages_( false ), min_rb_( true ), min_sc_( false ), min_bb_( false ),
95  min_lig_( false ), minimize_prot_jumps_( false ), backrub_( false ),
96  task_factory_(NULL),
97  n_cycles_( 1 )
98 {}
99 
101 
104 {
105  return new EnzRepackMinimize( *this );
106 }
107 
110 {
111  return new EnzRepackMinimize;
112 }
113 
114 void
116 {
117  ensure_scofx_cstfication( pose );
119  enzprot->set_fix_cataa( fix_catalytic_ );
120  enzprot->set_minimize_options(min_sc_, min_bb_,min_rb_,min_lig_);
121 
122  for (core::Size i=1;i<=n_cycles_;++i){
123  (*scorefxn_repack_)(pose);
124  if (cst_opt_) design_=true; // to enable poly-ala conversion
125  if (task_factory_ ==0) task_ = enzprot->create_enzdes_pack_task( pose, design_ );
126  else task_ = create_ptask( pose );
127  if (cst_opt_) {
128  TR<<"Starting PolyAla CstOptimization..."<<std::endl;
129  if (minimize_in_stages_) minimize_in_stages( pose, task_, true/*cst_opt*/, min_sc_, min_rb_, min_lig_ );
130  enzprot->cst_minimize(pose, task_, true/*cst_opt*/);
131  }
132  else {
133  if (design_ || repack_){
134  TR<<"Starting Design/Repack..."<<std::endl;
135  enzprot->enzdes_pack( pose, task_, scorefxn_repack_, 1/*cycles*/, false /*minimize_after_packing*/,false /*pack_unconstrained*/, false /*favor_native*/);
136  }
137  if ( min_sc_ || min_bb_ || min_lig_ || min_rb_ ){
138  TR<<"Starting Minimization..."<<std::endl;
139  if (minimize_in_stages_) minimize_in_stages( pose, task_, false/*cst_opt*/, min_sc_, min_rb_, min_lig_ );
140  enzprot->set_scorefxn(scorefxn_minimize_);
141  enzprot->set_minimize_options(min_sc_, min_bb_,min_rb_,min_lig_);
142  enzprot->cst_minimize(pose, task_, false );
143  }
144  }
145  if (backrub_){
146  core::pose::Pose old_Pose = pose;
147  design_ = false;
148  if (task_factory_ ==0) task_ = enzprot->create_enzdes_pack_task( pose, design_ );
149  else task_ = create_ptask( pose );
150  enzprot->set_minimize_options(min_sc_, false/*min_bb*/,min_rb_,min_lig_,true/*backrub*/);
151  core::kinematics::MoveMapOP movemap = enzprot->create_enzdes_movemap( pose, task_, minimize_prot_jumps_ );
153  std::vector<core::Size> residues;
154  for (core::Size i =1; i<pose.total_residue();++i) {
155  if (movemap->get_bb(i) ) residues.push_back(i);
156  }
157  TR<<"Now Backrub minimizing: min_sc "<<min_sc_<<" min_bb "<< min_bb_<<std::endl;
158  protocols::protein_interface_design::movers::BackrubDDMover br( br_scorefxn, true/*br_partner1?*/, false/*brpartner2=lig*/, 7.5/*interface distance*/, 1000/*num moves*/, 0.6/*kT*/,0.25/*sidechain move probability*/, residues/*vector of residues to backrub*/ ); //default params; residues vector will over-ride other interface detection stuff specified by other params
159  br.apply(pose);
160  pose.constraint_set( old_Pose.constraint_set()->clone() );
161  pose.fold_tree( old_Pose.fold_tree() );
163  }
165  (*scorefxn_minimize_)(pose);
166  TR<<"Finished Cyle#"<< i <<" of EnzRepackMinimize"<<std::endl;
167  }
168  TR<<"Finished EnzRepackMinimize"<<std::endl;
169 }
170 
174 }
175 
178 {
179 
180  using namespace core::pack::task;
181  TR<<"Creating packer task based on specified task operations..."<< std::endl;
183  PackerTaskOP task = task_factory_->create_task_and_apply_taskoperations( pose );
184  return task;
185 }
186 
187 void
189  core::pose::Pose & pose,
191  bool const & cstopt,
192  bool const & min_sc,
193  bool const & min_rb,
194  bool const & min_lig
195 )
196 {
198  enzprot->set_scorefxn( scorefxn_minimize() );
199 
200  enzprot->set_minimize_options( min_sc, false/*min_bb_*/,min_rb,min_lig );
201  enzprot->cst_minimize(pose, task, cstopt);
202 
203  TR<<"Finished non-bb dof minimization"<<std::endl;
204 
205  enzprot->set_minimize_options(false/*min_sc_*/, true/*min_bb_*/,min_rb_,false/*min_lig_*/);
206  enzprot->cst_minimize(pose, task, cstopt);
207 
208  TR<<"Finished bb dof minimization"<<std::endl;
209 
210 }
211 
212 void
214 {
216  if( !enzobs ) return;
217 
218  if (enzobs->cst_cache() ){ // Make sure scorefunction has cst terms if constraints (seem to ) exist
220  TR<<"Setting up Scorefunction to include constraints..."<<std::endl;
225  }
226  }
227 }
228 
229 void
231 
232  if( tag->hasOption("task_operations") ) task_factory( protocols::rosetta_scripts::parse_task_operations( tag, data ) );
233  else task_factory_ = NULL;
234 
235  n_cycles_ = tag->getOption<core::Size>( "cycles", 1 );
236 
237  minimize_in_stages_ = tag->getOption<bool>( "min_in_stages", 0 );
238  design_ = tag->getOption<bool>( "design", 0 );
239  repack_ = tag->getOption<bool>( "repack_only", 0 );
240  fix_catalytic_ = tag->getOption<bool>( "fix_catalytic", 0 );
241  cst_opt_ = tag->getOption<bool>( "cst_opt", 0 );
242  backrub_ = tag->getOption<bool>( "backrub", 0 );
243 
244  if( tag->hasOption( "minimize_rb" ) )
245  set_min_rb( tag->getOption<bool>( "minimize_rb", 1 ) );
246  if( tag->hasOption( "minimize_bb" ) )
247  set_min_bb( tag->getOption<bool>( "minimize_bb", 0 ) );
248  if( tag->hasOption( "minimize_sc" ) )
249  set_min_sc( tag->getOption<bool>( "minimize_sc", 1 ) );
250  if( tag->hasOption( "minimize_lig" ) )
251  set_min_lig( tag->getOption<bool>( "minimize_lig", 0 ) );
252  if( tag->hasOption( "minimize_prot_jumps" ) )
253  minimize_prot_jumps_ = tag->getOption<bool>( "minimize_prot_jumps", 0 );
254 
255  std::string const scorefxn_repack( tag->getOption<std::string>( "scorefxn_repack", "score12" ) );
256  std::string const scorefxn_minimize( tag->getOption<std::string>( "scorefxn_minimize", "score12" ) );
257  using namespace core::scoring;
258  scorefxn_repack_ = new ScoreFunction( *data.get< ScoreFunction * >( "scorefxns", scorefxn_repack ) );
259  scorefxn_minimize_ = new ScoreFunction( *data.get< ScoreFunction * >( "scorefxns", scorefxn_minimize ) );
260 
261  if (design_ && repack_) utility_exit_with_message("Can't both Design and Repack_Only. Check xml file");
262  if (minimize_in_stages_ && (!min_bb_) )utility_exit_with_message( "EnzRepackMinimize cant minimize in stages without minimize_bb set to 1. Check xml file." );
263 
264  //task_factory_ = protocols::rosetta_scripts::parse_task_operations( tag, data );
265 
266  TR<<"design="<<design_<< ", with repack scorefxn "<<scorefxn_repack<<" and minimize scorefxn "<<scorefxn_minimize<<std::endl;
267 
268 }
269 
270 void
272  scorefxn_repack_ = scorefxn->clone();
273 }
274 
275 void
277  scorefxn_minimize_ = scorefxn->clone();
278 }
279 
282  return scorefxn_repack_;
283 }
284 
287  return scorefxn_minimize_;
288 }
289 
290 void
292  task_factory_ = p;
293 }
294 
295 } //enzdes
296 } //protocols