Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LoopMover_SlidingWindow.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/loop_build/LoopMover_SlidingWindow.cc
11 /// @brief kinematic loop closure main protocols
12 /// @author Mike Tyka
13 
14 //// Unit Headers
15 #include <protocols/loops/util.hh>
18 #include <protocols/loops/Loops.hh>
22 //
23 //
24 //// Rosetta Headers
26 
28 #include <core/id/TorsionID.hh>
31 #include <basic/options/option.hh>
32 #include <core/pose/Pose.hh>
33 #include <core/scoring/Energies.hh>
36 
37 #include <basic/Tracer.hh> // tracer output
39 
40 //Utility Headers
41 #include <numeric/random/random.hh>
42 
43 // C++ Headers
44 #include <iostream>
45 #include <map>
46 #include <string>
47 
48 // option key includes
49 
50 #include <basic/options/keys/loops.OptionKeys.gen.hh>
51 
52 #include <core/pose/util.hh>
54 #include <utility/vector1.hh>
55 
56 
57 namespace protocols {
58 namespace loop_build {
59 
60 static basic::Tracer TR("protocols.loop_build.LoopMover_SlidingWindow");
61 ///////////////////////////////////////////////////////////////////////////////
62 using namespace core;
63 
64 static numeric::random::RandomGenerator RG(10003);
65 
66 
68  IndependentLoopMover()
69 {
71  scorefxn()->set_weight( scoring::chainbreak, 1.0*10.0/3.0);
72 
73  protocols::moves::Mover::type("LoopMover_SlidingWindow");
75 }
76 
77 
80 ) : IndependentLoopMover( loops_in )
81 {
83  scorefxn()->set_weight( scoring::chainbreak, 1.0*10.0/3.0);
84 
85  protocols::moves::Mover::type("LoopMover_SlidingWindow");
87 }
88 
89 
90 
94 ) : IndependentLoopMover( loops_in )
95 {
96  if( scorefxn ){
97  set_scorefxn( scorefxn );
98  } else {
100  scorefxn()->set_weight( scoring::chainbreak, 1.0*10.0/3.0);
101  }
102 
103  protocols::moves::Mover::type("LoopMover_SlidingWindow");
105 }
106 
107 
109  core::pose::Pose & pose,
110  protocols::loops::Loop const & loop
111 ){
112  using namespace kinematics;
113  using namespace scoring;
114  using namespace protocols::simple_moves;
115  using namespace basic::options;
116  using namespace basic::options::OptionKeys;
117  using namespace numeric::random;
118 
119 
120  // store starting fold tree and cut pose
121  kinematics::FoldTree f_orig=pose.fold_tree();
122  kinematics::FoldTree f_empty;
123  f_empty.simple_tree( pose.total_residue() );
124  core::pose::Pose closedpose = pose;
125  set_single_loop_fold_tree( pose, loop );
126  closedpose.fold_tree( f_empty );
127 
128  // generate movemap after fold_tree is set
129  kinematics::MoveMapOP mm_one_loop = new kinematics::MoveMap();
130  set_move_map_for_centroid_loop( loop, *mm_one_loop );
131 
132  core::Size const nres = pose.total_residue();
133  // special case ... vrt res at last position
134  //bool chainbreak_present = ( loop.start() != 1 && loop.stop() != nres );
135  //chainbreak_present &= (loop.stop() != nres-1 || pose.residue( nres ).aa() != core::chemical::aa_vrt );
136  bool chainbreak_present = ( loop.start() != 1 && loop.stop() != nres &&
137  !pose.residue( loop.start() ).is_lower_terminus() &&
138  !pose.residue( loop.stop() ).is_upper_terminus() );
139 
140  // set loop.cut() variant residue for chainbreak score if chanbreak is present
141  if( chainbreak_present ){
144  }
145 
146  // either extend or at least idealize the loop (just in case).
147  if( loop.is_extended() ) set_extended_torsions( pose, loop );
148  else idealize_loop( pose, loop );
149 
150  core::fragment::FragSetOP fragset_small_;
151 
152  if( frag_libs_.size() == 0 ){ utility_exit_with_message("Fragments needed for LoopMover_SlidingWindow"); }
153  else if( frag_libs_.size() == 1 ){ fragset_small_ = frag_libs_[0]; }
154  else { fragset_small_ = frag_libs_[ frag_libs_.size() - 2]; }
155 
156 
158 
159  if ( option[ OptionKeys::loops::alternative_closure_protocol ]() ) {
161  }else{
163  }
164 
165  closure_protocol->scored_frag_cycle_ratio( option[ OptionKeys::loops::scored_frag_cycles ]() );
166  closure_protocol->short_frag_cycle_ratio( option[ OptionKeys::loops::short_frag_cycles ]() );
167 
168  closure_protocol->set_bIdealLoopClosing( false );
169  closure_protocol->set_chainbreak_max( option[ OptionKeys::loops::chainbreak_max_accept ]() );
170 
172  closure_protocol,
173  pose,
174  *get_checkpoints(),
175  get_current_tag(),
176  f_empty
177  );
178 
179  // Check chain break !
180  if( chainbreak_present ){
181  ( *scorefxn() )( pose );
182  core::Real chain_break_score = std::max( (float)pose.energies().total_energies()[ scoring::chainbreak ],
184 
185  core::Real chain_break_tol = option[ basic::options::OptionKeys::loops::chain_break_tol ]();
186  tr().Info << "Chainbreak: " << chain_break_score << " Max: " << chain_break_tol << std::endl;
187 
188  if( chain_break_score > (chain_break_tol*10) ) return loops::loop_mover::ExtendFailure; // if we have a really bad chain break, go and extend
189  if( chain_break_score > chain_break_tol ) return loops::loop_mover::Failure; // if we only have a slight chainbreak problem, try again
190  }
191 
192  // return to original fold tree
194  pose.fold_tree( f_orig );
195 
197 }
198 
201  return "LoopMover_SlidingWindow";
202 }
203 
204 basic::Tracer & LoopMover_SlidingWindow::tr() const
205 {
206  return TR;
207 }
208 
209 } // namespace loop_build
210 } // namespace protocols