Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DoubleLayerKinematicAbinitio.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 KinematicTaskCenter
11 /// @brief this class will be handled to a SampleProtocol as a control instance
12 /// @detailed responsibilities:
13 /// know which chainbreaks to penalize and close
14 /// know which jumps to use during sampling, which (if any) to keep after loop-closing
15 /// supply a JumpMover if jumps should be moved
16 /// supply a MoveMap
17 /// supply a "StrictMoveMap": the protocol should not move anything that is dissallowed in strict_movemap(),
18 /// it should try to move just stuff in movemap()
19 /// should this class also know how to ramp score terms ?
20 /// handle the titration of constraints ?
21 /// @author Oliver Lange
22 
23 // Unit Headers
25 
26 // Package Headers
29 
30 // Project Headers
31 #include <core/pose/Pose.hh>
32 
33 #include <core/kinematics/util.hh>
35 #include <protocols/loops/Loop.hh>
36 // AUTO-REMOVED #include <core/id/NamedAtomID.hh>
37 
38 // AUTO-REMOVED #include <core/conformation/ResidueFactory.hh>
39 
40 
41 #include <basic/options/option.hh>
42 
43 // AUTO-REMOVED #include <core/conformation/util.hh> //idealize
44 
45 // AUTO-REMOVED #include <protocols/loops/util.hh>
46 
47 // ObjexxFCL Headers
48 #include <ObjexxFCL/string.functions.hh>
49 
50 // Utility headers
51 #include <numeric/random/random.hh>
52 // AUTO-REMOVED #include <utility/io/izstream.hh>
53 // AUTO-REMOVED #include <utility/io/ozstream.hh>
54 // AUTO-REMOVED #include <utility/io/util.hh>
55 #include <basic/Tracer.hh>
56 
57 
58 //// C++ headers
59 // AUTO-REMOVED #include <fstream>
60 
61 
62 // option key includes
63 
64 #include <basic/options/keys/loops.OptionKeys.gen.hh>
65 
66 #include <utility/vector1.hh>
67 
68 
69 
70 static basic::Tracer tr("protocols.general_abinitio",basic::t_info);
71 static numeric::random::RandomGenerator RG(19879234);
72 
73 namespace protocols {
74 namespace abinitio {
75 
76 using namespace core;
77 
79 
82  return "DoubleLayerKinematicAbinitio";
83 }
84 
85 ///////////////////////////////////////////////////////////////////////
86 /// @brief Select loop set at random using skip rate
88  loops::Loops& loops_out
89 ) const
90 {
91  loops_out.clear();
92  int ntries = 0;
93  while (loops_out.size() == 0 && ntries++ < 50) {
94  for ( loops::Loops::const_iterator it = rigid_loops_.begin(), eit = rigid_loops_.end();
95  it != eit; ++it ) {
96  if ( RG.uniform() >= it->skip_rate() ) {
97  loops_out.push_back( *it );
98  }
99  }
100  }
101  if ( loops_out.size() == 0 ) {
102  loops_out = rigid_loops_;
103  }
104 } // void LoopRebuild::select_loops
105 
106 
107 
108 //@brief create a new fold-tree and movemap --- a KinematicControl object
109 // a basic generalized protocol:
110 // loops are determined: if loops present only loops move, otherwise everything moves
111 // get jumps from JumpDef ( as in JumpingFoldCst, for instance beta-sheet jumps )
112 // combine jumps with additional jumps that keep the rigid portions together ( looprlx-type )
113 // set movemap to allow only sampling of flexible parts. call sampling protocol
115  using namespace basic::options;
116  using namespace basic::options::OptionKeys;
117 
118  // select loops
119  loops::Loops rigid_core;
120  if ( rigid_loops_.size() > 0 ) {
121  select_core_loops( rigid_core );
122  }
123  tr.Debug << rigid_core << std::endl;
124 
125  KinematicControlOP current_kinematics( NULL );
126  if ( rigid_core.size() && coordinate_constraint_weight_ > 0.0 ) {
127  current_kinematics = new CoordinateConstraintKC( false /*ramp*/, coordinate_constraint_weight_ );
128  } else {
129  current_kinematics = new KinematicControl;
130  }
131  loops::Loops flexible_part( rigid_core.invert( pose.total_residue() ) );
132 
133  bool loop_file_is_present = option[ OptionKeys::loops::mm_loop_file ].user();
134  loops::Loops mmloops( loop_file_is_present ) ;
135 
136  if( !loop_file_is_present ) {
137  mmloops = flexible_part;
138  }
139 
140  //figure out movemap!
142  movemap->set_jump( true ); //why is that here ?
143 
144  if ( mmloops.size() && coordinate_constraint_weight_ == 0.0 ) {
145  rigid_core.switch_movemap( *movemap, id::BB, false );
146  mmloops.switch_movemap( *movemap, id::BB, true );
147  flexible_part.switch_movemap( *movemap, id::BB, true );
148  } else {
149  movemap->set_bb( true );
150  }
151 
152 
153  //figure out flexible jumps - jump-movers
154  bool success( true );
155  current_kinematics->set_final_fold_tree( pose.fold_tree() );
156  success = parse_jump_def( current_kinematics, movemap );
157 
158  current_kinematics->set_movemap( movemap );
159  // change fold-tree such that only loop parts can move
160  if ( rigid_core.size() ) {
161  success &= add_rigidity_jumps( rigid_core, current_kinematics );
162  if ( !success ) {
163  tr.Warning << "[WARNING] was not able to fix rigid regions with jumps...retry" << std::endl;
164  return NULL;
165  }
166  }
167 
168  pose.fold_tree( current_kinematics->sampling_fold_tree() );
169 
170  set_extended_torsions_and_idealize_loops( pose, extended_loops_ );
171 
172  if ( rigid_core.size() && coordinate_constraint_weight_ != 0.0 ) {
173  success = add_coord_cst( rigid_core, pose );
174  }
175  return current_kinematics;
176 }
177 
178 
179 //@brief sampling: simple version: get new kinematics (movemap+jumps) and call sampling protocol.
180 //overwrite this guy if you want to do more stuff ... i.e., extend loops if things didn't work out in the first place.
182  bool success( false );
183 
184  Size fail( 0 );
185  current_kinematics_ = NULL;
186  while ( fail++ <= 10 && !current_kinematics_ ) {// get new setup
187  //this may add constraints to the pose ...or should this be handled via the KinematicControl object?!
188  current_kinematics_ = new_kinematics( pose );
189  }
190 
191  //debug output
192  if ( current_kinematics_ && tr.Info.visible() ) {
193  tr.Info << "kinematic choice:\n";
195  current_kinematics_->sampling_fold_tree(),
196  current_kinematics_->movemap(),
197  tr.Info );
198  tr.Info << "\n" << jumping::JumpSample( current_kinematics_->sampling_fold_tree() );
199  tr.Info << "\nfinal_fold-tree:\n";
200  core::kinematics::simple_visualize_fold_tree( current_kinematics_->final_fold_tree(), tr.Info );
201  }
202 
203  // if setup valid...
204  if ( current_kinematics_ ) {
205  // sample with this setup
206 
207  // first sample only extended in stage1
208  kinematics::MoveMapOP extended_movemap = new kinematics::MoveMap( current_kinematics()->movemap() );
209  extended_movemap->set_bb( false );
210  extended_loops_.switch_movemap( *extended_movemap, id::BB, true );
211 
212  KinematicControlOP stage1_kinematics = new KinematicControl( *current_kinematics() );
213  stage1_kinematics->set_movemap( extended_movemap );
214  stage1_sampler_->set_kinematics( stage1_kinematics );
215  stage1_sampler_->set_current_tag( get_current_tag() + "_presampled" );
216  stage1_sampler_->apply( pose );
217 
218  sampling_protocol()->set_kinematics( current_kinematics() );
219  sampling_protocol()->apply( pose );
220  success = ( sampling_protocol()->get_last_move_status() == moves::MS_SUCCESS );
221  }
222  // done...
223  return success;
224 }
225 
226 }
227 }