Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PlaceOnLoop.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/protein_interface_design/movers/PlaceOnLoop.cc
11 /// @brief
12 /// @author Sarel Fleishman (sarelf@u.washington.edu)
13 
14 // Unit headers
17 
18 
20 #include <core/chemical/AA.hh>
21 #include <utility/tag/Tag.hh>
23 #include <utility/string_util.hh>
24 #include <basic/Tracer.hh>
26 #include <core/kinematics/Jump.hh>
29 // AUTO-REMOVED #include <basic/options/keys/hotspot.OptionKeys.gen.hh>
33 #include <core/pose/Pose.hh>
39 #include <protocols/loops/Loop.hh>
40 #include <protocols/loops/Loops.hh>
42 #include <core/id/AtomID.hh>
43 // AUTO-REMOVED #include <basic/options/option.hh>
45 // AUTO-REMOVED #include <protocols/hotspot_hashing/HotspotStub.hh>
50 #include <boost/foreach.hpp>
51 #define foreach BOOST_FOREACH
52 #include <numeric/random/random.hh>
53 #include <numeric/random/random_permutation.hh>
54 
55 #include <utility/vector0.hh>
56 #include <utility/vector1.hh>
57 #include <utility/options/IntegerVectorOption.hh>
58 
59 //Auto Headers
62 #include <basic/options/keys/OptionKeys.hh>
63 
64 
65 static numeric::random::RandomGenerator RG( 14071789 );
66 
67 namespace protocols {
68 namespace protein_interface_design {
69 namespace movers {
70 
71 using namespace core;
72 using namespace std;
73 using namespace core::scoring;
74 using namespace protocols::moves;
75 
76 static basic::Tracer TR( "protocols.protein_interface_design.movers.PlaceOnLoop" );
77 
80 {
82 }
83 
86  return new PlaceOnLoop;
87 }
88 
91 {
92  return "PlaceOnLoop";
93 }
94 
96  simple_moves::DesignRepackMover( PlaceOnLoopCreator::mover_name() ),
97  loop_begin_( 0 ), loop_end_( 0 ),
98  hires_scorefxn_( NULL ), lores_scorefxn_( NULL ),
99  chain_closing_attempts_( 100 ), host_chain_( 2 ), stub_set_( NULL ), minimize_toward_stub_( true )
100 {
101  delta_length_.clear();
102  delta_length_.push_back( 0 );
105 }
106 
108 
110  return MoverOP( new PlaceOnLoop );
111 }
112 
115  return( MoverOP( new PlaceOnLoop( *this )));
116 }
117 
118 bool
120 {
121  using namespace protocols::loops;
122 
123  core::kinematics::FoldTree const saved_ft( pose.fold_tree() );
126  loop.choose_cutpoint( pose );
127  LoopsOP loops = new protocols::loops::Loops();
128  loops->push_back( loop );
129  loops::fold_tree_from_loops( pose, *loops, f_new, true /* include terminal cutpoints */);
130  pose.fold_tree( f_new );
133  kinwrap.apply( pose );
134  if( kinwrap.get_last_move_status() != MS_SUCCESS ){
135  TR<<"Kinematic loop closure failed to close loop."<<std::endl;
136  pose.fold_tree( saved_ft );
137  return( false );
138  }
140  using namespace core::pack::task;
141  using namespace protocols::toolbox::task_operations;
144  tf->push_back( new RestrictChainToRepackingOperation( 1 ) );
145  tf->push_back( new RestrictChainToRepackingOperation( 2 ) );
146  refine.set_task_factory( tf );
147  refine.apply( pose );
148 
149  pose.fold_tree( saved_ft );
151  return( true );
152 }
153 
154 /// @details bb_csts only affect loop. Transforms loop to poly-ala
155 void
157 {
158  using namespace core::pack::task;
159  using namespace core::chemical;
160 
161  if( stub_set_() == NULL ) return;
163  for( core::Size i( 1 ); i<=pose.total_residue(); ++i ){
164  using namespace basic::options;
165  using namespace basic::options::OptionKeys;
166 
167  if( i<=loop_begin_ || i>=curr_loop_end_ )
168  ptask->nonconst_residue_task( i ).prevent_repacking();
169  if( (pose.residue( i ).aa() == aa_gly || pose.residue( i ).aa() == aa_pro ) )
170  ptask->nonconst_residue_task( i ).prevent_repacking();
171  }
172  stub_set_->pair_with_scaffold( pose, host_chain_, new protocols::filters::TrueFilter );
173  core::Size fixed_res(1);
174  if( host_chain_ == 1 ) fixed_res = pose.total_residue();
175  core::id::AtomID const fixed_atom_id = core::id::AtomID( pose.residue(fixed_res).atom_index("CA"), fixed_res );
176  stub_set_->add_hotspot_constraints_to_pose( pose, fixed_atom_id, ptask, stub_set_, 0.7/*cbforce*/, 0/*worst allowed stub bonus*/, false/*apply self energies*/, 10.0/*bump cutoff*/, true/*apply ambiguous constraints*/ );
177 }
178 
179 void
181 {
182  using namespace core::pack::task;
183  using namespace core::chemical;
184 
185  utility::vector1< bool > ala_only( num_canonical_aas, false );
186  ala_only[ aa_ala ] = true;
188  for( core::Size i( 1 ); i<=pose.total_residue(); ++i ){
189  if( i>=loop_begin_ && i<=curr_loop_end_ )
190  ptask->nonconst_residue_task( i ).restrict_absent_canonical_aas( ala_only );
191  else
192  ptask->nonconst_residue_task( i ).prevent_repacking();
193  }
195 }
196 
197 /// @details Chooses one user-defined loop length at random, changes the loop accordingly,
198 /// and tries to close the loop with that change.
199 bool
201 {
203  Pose const saved_pose( pose );
205  numeric::random::random_permutation( delta_length_.begin(), delta_length_.end(), RG );
206  bool loop_closed( false );
207  int const delta( *delta_length_.begin() );
208  TR<<"changing loop length by "<<delta<<std::endl;
209  if( delta < 0 ){
210  for( int del(-1); del>=delta; --del ){
212  curr_loop_end_--;
213  }
214  }
215  else if( delta > 0 ){
216  using namespace core::chemical;
217  using namespace core::conformation;
218 
219  ResidueTypeSet const & residue_set( pose.residue( 1 ).residue_type_set() ); // residuetypeset is noncopyable
220  ResidueCOP new_res = ResidueFactory::create_residue( residue_set.name_map( name_from_aa( aa_from_oneletter_code( 'A' ) ) ) );
221  for( core::Size leng(1); leng<=(core::Size) delta; ++leng ){
222  pose.conformation().safely_append_polymer_residue_after_seqpos( *new_res, loop_begin_ + 1, true/*build_ideal_geometry*/ );
223  curr_loop_end_++;
224  }
225  }
226 
228  ala_pose_loop( pose );
229  add_bb_csts_to_loop( pose );
231  loop_closed = minimize_toward_stub( pose );
232  else
233  loop_closed = position_stub( pose );
234 
235  return( loop_closed );
236 }
237 
238 bool
240 {
241  utility_exit_with_message( "position_stub is not yet implemented." );
242  return( false );
243 }
244 
245 /// @details set the defaults for the kinmover. Taken from Jacob's LoopRemodel
246 void
248 {
249  runtime_assert( kinematic_mover_ );
250  kinematic_mover_->set_idealize_loop_first( true );
251  kinematic_mover_->set_temperature( 0.6/*mc_kt*/ );
253  kinematic_mover_->set_vary_bondangles( true );
254  kinematic_mover_->set_sample_nonpivot_torsions( true );
255  kinematic_mover_->set_rama_check( true );
256 }
257 
258 void
260 {
261  bool const success( loop_length( pose ) );
262  if( success ) set_last_move_status( MS_SUCCESS );
264 }
265 
269 }
270 
271 void
273 {
274  host_chain_ = tag->getOption< core::Size >( "host_chain", 2 );
275  loop_begin_ = tag->getOption< core::Size >( "loop_begin" );
276  loop_end_ = tag->getOption< core::Size >( "loop_end" );
277  runtime_assert( loop_begin_ < loop_end_ );
278  runtime_assert( loop_begin_ > 1 );
279  core::Size const chain_begin( pose.conformation().chain_begin( host_chain_ ) );
280  core::Size const chain_end( pose.conformation().chain_end( host_chain_ ) );
281  runtime_assert( chain_begin < loop_begin_ && loop_begin_ < chain_end );
282  runtime_assert( chain_begin < loop_end_ && loop_end_ < chain_end );
283  minimize_toward_stub_ = tag->getOption< bool >( "minimize_toward_stub", 1 );
284  if( tag->hasOption( "stubfile" ) ){
285  std::string const stub_fname = tag->getOption< std::string >( "stubfile" );
287  stub_set_->read_data( stub_fname );
288  }
289 
290  std::string const score_hi_name = tag->getOption< std::string >( "score_high", "score12" );
291  std::string const score_lo_name = tag->getOption< std::string >( "score_low", "score4L" );
292  hires_scorefxn_ = data.get< core::scoring::ScoreFunction * >( "scorefxns", score_hi_name );
293  lores_scorefxn_ = data.get< core::scoring::ScoreFunction * >( "scorefxns", score_lo_name );
294  chain_closing_attempts_ = tag->getOption< core::Size >( "closing_attempts", 100 );
295 
296  typedef utility::vector1< std::string > StringVec;
297  std::string shorten_by(""), lengthen_by("");
298  if( tag->hasOption( "shorten_by" ) )
299  shorten_by = tag->getOption< std::string >( "shorten_by" );
300  if( tag->hasOption( "lengthen_by" ) )
301  lengthen_by = tag->getOption< std::string >( "lengthen_by" );
302  StringVec const shorten_by_keys( utility::string_split( shorten_by, ',' ) );
303  StringVec const lengthen_by_keys( utility::string_split( lengthen_by, ',' ) );
304  core::Size const loop_length( loop_end_ - loop_begin_ + 1 );
305  foreach( std::string const shorten, shorten_by_keys ){
306  if( shorten == "" ) continue;
307  int const shorten_i( -1 * atoi( shorten.c_str() ) );
308  runtime_assert( ( core::Size ) abs( shorten_i ) < loop_length );
309  delta_length_.push_back( shorten_i );
310  }
311 
312  foreach( std::string const lengthen, lengthen_by_keys ){
313  if( lengthen == "" ) continue;
314  delta_length_.push_back( atoi( lengthen.c_str() ) );
315  }
316 
317  sort( delta_length_.begin(), delta_length_.end() );
318  runtime_assert( loop_end_ - loop_begin_ + 1 + *delta_length_.begin() >= 3 );
319  unique( delta_length_.begin(), delta_length_.end() );
320  TR<<"PlaceOnLoop mover defined with kinematic mover ";
321  TR<<" will change the loop by these values: ";
322  foreach( int const i, delta_length_ ) TR<<i<<", ";
323  TR<<std::endl;
324 }
325 
326 } //movers
327 } //protein_interface_design
328 } //protocols