Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
KinematicTaskControl.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
28 
29 // Project Headers
30 #include <core/pose/Pose.hh>
31 
32 #include <core/kinematics/util.hh>
33 // AUTO-REMOVED #include <core/kinematics/MoveMap.hh>
34 // AUTO-REMOVED #include <core/id/NamedAtomID.hh>
35 
36 // AUTO-REMOVED #include <core/conformation/ResidueFactory.hh>
37 
38 
39 // AUTO-REMOVED #include <basic/options/option.hh>
40 
41 #include <core/conformation/util.hh> //idealize
42 
43 #include <protocols/loops/Loop.hh>
44 
45 // ObjexxFCL Headers
46 // AUTO-REMOVED #include <ObjexxFCL/string.functions.hh>
47 
48 // Utility headers
49 #include <numeric/random/random.hh>
50 // AUTO-REMOVED #include <utility/io/izstream.hh>
51 // AUTO-REMOVED #include <utility/io/ozstream.hh>
52 // AUTO-REMOVED #include <utility/io/util.hh>
53 #include <basic/Tracer.hh>
54 // AUTO-REMOVED #include <basic/options/keys/OptionKeys.hh>
55 
56 
57 //// C++ headers
58 // AUTO-REMOVED #include <fstream>
59 
62 #include <protocols/loops/Loops.hh>
63 #include <utility/vector1.hh>
64 
65 
66 static basic::Tracer tr("protocols.general_abinitio",basic::t_info);
67 static numeric::random::RandomGenerator RG(198121234);
68 
69 namespace protocols {
70 namespace abinitio {
71 
72 using namespace core;
73 
74 void
76 }
77 
79 
80 //@brief basic apply for the generalized protocol:
83  tr.Debug << "KinematicTaskControl settings: "
84  << " return_full_atom " <<( !return_centroid() ? "yes" : "no" )
85  << " add side-chains " << ( sampling_protocol_->return_centroid() ? "yes" : "no" )
86  << std::endl;
87  //resoltuion switch: if pose is fullatom ---> make it centroid but keep full-atom copy for the retrieval of side-chains later on.
88  res_switch_ = new ResolutionSwitcher(
89  pose,
90  b_input_is_fullatom_,
91  sampling_protocol_->start_from_centroid(),
92  sampling_protocol_->return_centroid()
93  );
94  //needs the full-atom scorefxn for repacking later
95  res_switch().set_scorefxn( fullatom_scorefxn() ); //needed for repacking
96 
97  //-------------------------------------------------
98  // the actual work
99  bool success( true );
100  // start pose ( centroid or fullatom based on the initialization of res_switch )
101  pose = res_switch().start_pose();
102  if ( tr.Debug.visible() ) output_debug_structure( pose, "start_pose" );
103  //* do sampling:
104 
105  sampling_protocol_->set_current_job( get_current_job() );
106  sampling_protocol_->set_current_tag( get_current_tag() );
107 
108  success = inner_loop( pose );
109 
110  set_current_tag( sampling_protocol_->get_current_tag() );
111 
112  if ( !success ) tr.Warning << "[WARNING] no success in sampler... could be the loop-closing " << std::endl;
113  // apply res_switch to get back to a full-atom pose ( copies side-chains in unmoved regions )
114  if ( tr.Debug.visible() ) output_debug_structure( pose, "before resolution switch ");
115 
116  if ( !return_centroid() ) res_switch().apply( pose );
117  tr.Debug << "return from KinematicTaskControl" << std::endl;
118  if (! (success && (res_switch().get_last_move_status() == moves::MS_SUCCESS) ) ) set_last_move_status( moves::FAIL_RETRY );
119 }
120 
123  return "KinematicTaskControl";
124 }
125 
126 //@brief sampling: simple version: get new kinematics (movemap+jumps) and call sampling protocol.
127  //overwrite this guy if you want to do more stuff ... i.e., extend loops if things didn't work out in the first place.
129  bool success( false );
130 
131  Size fail( 0 );
132  current_kinematics_ = NULL;
133  while ( fail++ <= 10 && !current_kinematics_ ) {// get new setup
134  //this may add constraints to the pose ...or should this be handled via the KinematicControl object?!
135  current_kinematics_ = new_kinematics( pose );
136  }
137 
138  //debug output
139  if ( current_kinematics_ && tr.Info.visible() ) {
140  tr.Info << "kinematic choice:\n";
142  current_kinematics_->sampling_fold_tree(),
143  current_kinematics_->movemap(),
144  tr.Info );
145  tr.Info << "\n" << jumping::JumpSample( current_kinematics_->sampling_fold_tree() );
146  tr.Info << "\nfinal_fold-tree:\n";
147  core::kinematics::simple_visualize_fold_tree( current_kinematics_->final_fold_tree(), tr.Info );
148  }
149 
150  // if setup valid...
151  if ( current_kinematics_ ) {
152  // sample with this setup
153  sampling_protocol_->set_kinematics( current_kinematics() );
154  sampling_protocol_->apply( pose );
155  success = ( sampling_protocol_->get_last_move_status() == moves::MS_SUCCESS );
156  }
157  // done...
158  return success;
159 }
160 
162 
163  // if no loops, we want to have extended structure everywhere.
164  // it is a by-value parameter -- as intenden the change is kept local
165 
166  if ( loops.size() == 0 ) loops.add_loop( 1, pose.total_residue(), 0 );
167  tr.Debug << "extend structure for " << loops << std::endl;
168  for ( loops::Loops::const_iterator it = loops.begin(), eit = loops.end(); it != eit; ++it ) {
169  Size const end_extended ( std::min( (int) it->stop(), (int) pose.total_residue() ) );
170  for ( Size pos = std::max( 1, (int) it->start()); pos<=end_extended; pos++ ) {
172  }
173  Real const init_phi ( -150.0 );
174  Real const init_psi ( 150.0 );
175  Real const init_omega( 180.0 );
176  //special thing for residue 1 since idealize has a bug for residue 1
177  // if ( it->start() == 1 ) {
178 // core::conformation::ResidueOP new_rsd( conformation::ResidueFactory::create_residue( pose.residue_type( 1 ) ) );
179 // pose.replace_residue( 1, *new_rsd , false /*orient backbone*/ );
180 // }
181 
182  for ( Size pos = it->start(); pos <= end_extended; pos++ ) {
183  if( pos != it->start() ) pose.set_phi( pos, init_phi );
184  if( pos != end_extended ) pose.set_psi( pos, init_psi );
185  if( ( pos != it->start() ) && ( pos != end_extended ) ) pose.set_omega( pos, init_omega );
186  }
187  }
188 }
189 
190 
191 }
192 }