Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ResolutionSwitcher.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 
24 // Unit Headers
26 
27 // Package Headers
28 #include <protocols/moves/Mover.hh>
29 
30 // Project Headers
32 // AUTO-REMOVED #include <core/chemical/ChemicalManager.hh>
33 
34 
36 
37 #include <core/pose/Pose.hh>
38 
41 
45 
47 
49 
52 // Utility Headers
53 // AUTO-REMOVED #include <utility/vector1.hh>
54 #include <basic/Tracer.hh>
55 
56 // option key includes
57 
58 // AUTO-REMOVED #include <basic/options/keys/residues.OptionKeys.gen.hh>
59 
62 #include <core/pose/util.hh>
64 #include <utility/vector0.hh>
65 #include <utility/vector1.hh>
66 
67 
68 
69 
70 static basic::Tracer tr("protocols.general_abinitio",basic::t_info);
71 
72 namespace protocols {
73 namespace abinitio {
74 
75 using namespace core;
76 
77 
78 //@brief utility function
80  core::pose::Pose& pose,
81  utility::vector1< bool >& needToRepack,
82  core::pose::Pose const& fa_input_pose
83 ) {
84  // copy sidechain torsions from input pose
85  if( pose.total_residue() != fa_input_pose.total_residue() ){
86  utility_exit_with_message("Mismatch of pose lenght in copy_side_chains(..): " );
87  }
88  tr.Debug << "copy side chains for residues with * / missing density residues with - ";
89  for ( core::Size i=1; i<=pose.total_residue(); ++i ) {
90  // if there is missing density in the sidechain, then we need to repack
91  // check this my making sure that no SC atom is more than 20A (?) away from CA
92  //needToRepack[i] = true;
93  numeric::xyzVector< core::Real> ca_pos = fa_input_pose.residue(i).atom("CA").xyz();
94  for ( Size j=1; j<=fa_input_pose.residue(i).natoms(); ++j ) {
95  if ( (ca_pos - fa_input_pose.residue(i).atom(j).xyz()).length() > 20 ) {
96  tr.Debug << "-" << i << " ";
97  needToRepack[ i ] = true;
98  break; //one bad atom is enough
99  }
100  }
101  //copy sidechains only for non-loop regions
102  if ( !needToRepack[ i ] ) {
103  tr.Debug << "*" << i << " ";
104  bool const lower_cut ( pose.residue( i ).has_variant_type( chemical::CUTPOINT_LOWER ) );
105  bool const upper_cut ( pose.residue( i ).has_variant_type( chemical::CUTPOINT_UPPER ) );
106  pose.replace_residue(i, fa_input_pose.residue(i), true /*orient backbone*/ );
109  }
110  } //for 1..total_residue
111  tr.Debug << " that have not moved from template" << std::endl;
112  return true;
113 } //copy_side_chains
114 
116  core::pose::Pose const& pose,
117  bool /*input pose*/,
118  bool start_centroid,
119  bool apply_to_centroid
120 ) : apply_to_centroid_( apply_to_centroid ),
121  init_pose_( pose ),
122  init_fa_( pose.is_fullatom() ),
123  start_centroid_( start_centroid ),
124  scorefxn_fa_( NULL ),
125  repack_buffer_( 0 ),
126  map_cst_from_centroid_to_fa_( true )
127 {}
128 
129 //@brief return the pose to start the simulation -- based on the flags it will be centroid or full-atom
131  if ( start_centroid_ ) {
132  if ( init_fa_ ) {
133  pose::Pose pose( init_pose_ );
135  return pose;
136  } else return init_pose_;
137  } else if ( init_fa_ ) {
138  return init_pose_;
139  } else {
140  utility_exit_with_message("don't have full-atom pose to start");
141  return init_pose_; //to make compiler happy.
142  //or switch to full-atom?
143  }
144 }
145 
146 //@brief switch the pose from its end-of-sampling-resolution to full-atom
147 // copy sidechains from initial pose if torsions have not moved
149  tr.Debug << "resolution_switch" << std::endl;
150  bool const bCopySideChains( start_centroid_ || apply_to_centroid_ ); //we assume that start and apply pose are fullatom that side-chains are fine!
151  utility::vector1< bool > needToRepack( pose.total_residue() , false );
152  if ( apply_to_centroid_ ) {
153  //puts full-atom sidechains on loop regions
154  tr.Debug <<" change to full-atom pose " << std::endl;
156  pose.conformation().detect_bonds();//apl fix this !
157  }
158 
159  if ( init_fa_ ) {//find residues that have moved --- test for missing density is in copy_side_chains!
160  for ( Size i=1; i<=pose.total_residue(); ++i ) {
161  if ( std::abs(init_pose_.phi( i ) - pose.phi( i ) ) > 10
162  || std::abs(init_pose_.psi( i ) - pose.psi( i ) ) > 10 ) {
163  tr.Trace << "residue " << i << " has moved " << std::endl;
164  for ( Size j = std::max( 1, (int)i-(int) repack_buffer_); j <= pose.total_residue() && j <= i + repack_buffer_; j++ ) {
165  needToRepack[ j ] = true;
166  } //saftey buffer for repacking: 1 residues on each side of moved stuff
167  }
168  }
169  }
170 
171  if ( bCopySideChains && init_fa_ ) {
172  copy_side_chains( pose, needToRepack, init_pose_ );
173  }
174 
176  scorefxn_fa_->set_weight( scoring::coordinate_constraint , 1.0 );
177  runtime_assert( pose.is_fullatom() );
178  // repack loop + missing-density residues
180  taskstd->restrict_to_repacking();
181  taskstd->or_include_current(true);
182  if ( init_fa_ ) {
183  taskstd->restrict_to_residues( needToRepack );
184  }
185  if ( !init_pose().is_fullatom() ) {
187  //&& basic::options::option[ basic::options::OptionKeys::residues::patch_selectors ].user()
188  // && basic::options::option[ basic::options::OptionKeys::residues::patch_selectors ]()[ 1 ] == "CENTROID_HA" ) {
189  // tr.Warning << "[ WARNING ] ResolutionSwitcher cannot copy constraints if CENTROID_HA is selected... HA has other atom-number... " << std::endl
190  // << "clean way would be to make the constraint set independent of numbers as in Templates.cc " << std::endl;
191  // utility_exit_with_message("[ WARNING ] ResolutionSwitcher cannot copy constraints if CENTROID_HA is selected.");
192  pose.constraint_set( init_pose().constraint_set()->remapped_clone( init_pose(), pose ) );
193  }
194  } else {
195  pose.constraint_set( init_pose().constraint_set()->clone() );
196  }
198  pack1.apply( pose );
199 
200  // quick SC minimization
202  core::optimization::MinimizerOptions options( "dfpmin_armijo_nonmonotone", 1e-5, true, false );
204  mm.set_bb( false );
205  mm.set_chi( true );
206  mzr.run( pose, mm, *scorefxn_fa_, options );
207 
208 }
209 
212  return "ResolutionSwitcher";
213 }
214 
215 
216 
217 }
218 }