Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
WidthFirstSlidingWindowLoopClosure.cc
Go to the documentation of this file.
1 
2 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
3 // vi: set ts=2 noet:
4 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @file
12 /// @brief
13 /// @detailed
14 /// @author Oliver Lange
15 ///
16 
17 
18 // Unit Headers
20 
21 // Package Headers
22 // AUTO-REMOVED #include <protocols/loops/Loops.hh>
28 
30 // Project Headers
31 #include <core/pose/Pose.hh>
32 // AUTO-REMOVED #include <core/pose/util.hh>
33 
36 
38 // AUTO-REMOVED #include <core/scoring/rms_util.hh>
39 
41 #include <core/fragment/Frame.hh>
43 #include <core/fragment/FragSet.hh>
44 // AUTO-REMOVED #include <core/fragment/FragCache.hh> // for FragStore
45 
46 // AUTO-REMOVED
47 
48 #include <basic/options/option.hh> // for quick-test from run:dry_run
49 // AUTO-REMOVED #include <basic/options/keys/in.OptionKeys.gen.hh>
50 //#include <basic/options/keys/out.OptionKeys.gen.hh> //for frag_file ... temporary!
51 #include <basic/options/keys/run.OptionKeys.gen.hh>
52 #include <basic/options/keys/fast_loops.OptionKeys.gen.hh>
53 
54 // ObjexxFCL Headers
55 
56 // Utility headers
57 #include <basic/Tracer.hh>
58 
60 #include <utility/vector1.hh>
61 
62 //Auto Headers
63 
64 
65 //numeric headers
66 
67 
68 static basic::Tracer tr("protocols.loops.loop_closure.ccd.WidthFirstSlidingWindowLoopClosure");
69 
70 namespace protocols {
71 namespace loops {
72 namespace loop_closure {
73 namespace ccd {
74 
75 using namespace core;
76 using namespace pose;
77 using namespace fragment;
78 
80  fragment::FragSetCOP fragset,
81  scoring::ScoreFunctionOP scorefxn,
83 ) : SlidingWindowLoopClosure( fragset, scorefxn, movemap )
84 {
85  set_defaults();
86 }
87 
90 {
91  set_defaults();
92 }
93 
96  return "WidthFirstSlidingWindowLoopClosure";
97 }
98 
100  using namespace basic::options;
101  using namespace basic::options::OptionKeys;
102 
104  window_acceptance_ratio_ = option[ fast_loops::window_accept_ratio ]();
105  nr_scored_sampling_passes_ = option[ fast_loops::nr_scored_sampling_passes ]();
106  min_breakout_good_loops_ = option[ fast_loops::min_breakout_good_loops ]();
107  min_breakout_fast_loops_ = option[ fast_loops::min_breakout_fast_loops ]();
108  min_good_loops_ = option[ fast_loops::min_good_loops ]();
109  min_fast_loops_ = option[ fast_loops::min_fast_loops ]();
110  vdw_delta_ = option[ fast_loops::vdw_delta ]();
111  give_up_ = option[ fast_loops::give_up ]();
112  nr_scored_fragments_ = option[ fast_loops::nr_scored_fragments ]();
113  chainbreak_max_ = basic::options::option[ basic::options::OptionKeys::fast_loops::chainbreak_max ]();
114  tr.Info << "WidthFirstSlidingWindowLoopClosure::defaults " << std::endl;
115 }
116 
118  using namespace basic::options;
119  using namespace basic::options::OptionKeys;
120 
121  option.add_relevant( fast_loops::window_accept_ratio );
122  option.add_relevant( fast_loops::nr_scored_sampling_passes );
123  option.add_relevant( fast_loops::nr_scored_fragments );
124  option.add_relevant( fast_loops::min_breakout_good_loops );
125  option.add_relevant( fast_loops::min_breakout_fast_loops );
126  option.add_relevant( fast_loops::min_good_loops );
127  option.add_relevant( fast_loops::min_fast_loops );
128  option.add_relevant( fast_loops::vdw_delta );
129  option.add_relevant( fast_loops::give_up );
130 }
131 
132 void
134  if ( bQuickTest() ) return; //let's say we found a good loop
135 
136  if( basic::options::option[ basic::options::OptionKeys::run::test_cycles ]() ){
137  min_loop_size_ = 6;
138  max_loop_size_ = 7;
139  min_good_loops_ = 1;
142  vdw_delta_ = 200;
143  score_delta_ = 200;
144  }
145 
146  const Real REALLY_BAD_SCORE ( 1000000000.0 );
148 
149  if ( bKeepFragments_ ) {
151  }
152 
153 
154  tr.Debug << "Trying loop-sizes: " << loop_ << std::endl;
155  Size const actual_max_loop_size( loop_.size() );
156  Size min_breakout_good_loops( std::max( min_breakout_good_loops_, min_good_loops_ ) );
157  tr.Info << "breakout good loops " << min_breakout_good_loops_ << " min_good_loops_ " << min_good_loops_
158  << "breakout fast loops " << min_breakout_fast_loops_ << " min_fast_loops_ " << min_fast_loops_ << std::endl;
159  tr.Debug << "Trying loop-sizes: "
160  << " " << std::min( actual_max_loop_size, min_loop_size_ )
161  << " " << " - "
162  << " " << std::min( actual_max_loop_size, max_loop_size_ )
163  << " " << std::min( actual_max_loop_size, max_loop_size_ ) - std::min( actual_max_loop_size, min_loop_size_ )
164  << " " << std::endl;
165 
166  tr.Debug << "LOOP: " << loop_ << std::endl;
167 
168  Size fast_loop_count( 0 );
169  Size good_loop_count( 0 );
170  Size scored_frags_attempted( 0 );
171 
173 
174  //we need to move this into Base class ... right now it has effect to set scorefxn_ as well...
175  setup_frag_scorefxn( *frag_scorefxn );
176  tr.Debug << "Trying loop-sizes: " << loop_ << std::endl;
177  tr.Info << "---------------- LOOP SAMPLING based on this scorefunction: ----------------\n";
178  if ( tr.Info.visible() ) frag_scorefxn->show( tr.Info, more_cut );
179  tr.Info << std::endl;
180 
181  tr.Debug << "Trying loop-sizes: " << loop_ << std::endl;
182  tr.Info << "---------------- LOOP SELECTION based on this scorefunction: ----------------\n";
183  if ( tr.Info.visible() ) scorefxn_->show( tr.Info, more_cut );
184  tr.Info << std::endl;
185 
186  loops::remove_cutpoint_variants( more_cut, true );
188 
189  loops::remove_cutpoint_variants( less_cut, true );
191 
192  tr.Debug << "MOREFOLDTREE: " << more_cut.fold_tree();
193  tr.Debug << "LESSFOLDTREE: " << less_cut.fold_tree();
194  if ( evaluator_ && tr.Debug.visible() ) evaluate_pose( more_cut, *evaluator_, tr.Debug );
195  if ( evaluator_ && tr.Debug.visible() ) evaluate_pose( less_cut, *evaluator_, tr.Debug );
196 
197  { //take initial loop-conformation as closing candidate
198  tr.Debug << "CAPTURE INITIAL POSE LOOPS" << std::endl;
199  using namespace fragment;
200  FrameOP closure_frame = new Frame( loop_.start(), new FragData( new BBTorsionSRFD, loop_.size() ) );
201  FrameList closure_frames;
202  closure_frame->steal( more_cut );
203 
204  CcdLoopClosureMover fast_ccd( loop_, movemap_ );
205  fast_ccd.apply( more_cut );
206  if ( fast_ccd.success() ) {
207  closure_frame->steal( more_cut );
208  }
209 
210  closure_frames.push_back( closure_frame );
211 
212  good_loop_count+=process_fragments( closure_frames, more_cut, less_cut );
213  fast_loop_count = good_loop_count;
214  tr.Debug << "INITIAL POSE yielded " << good_loop_count << " valuable conformations " << std::endl;
215  } //scope
216 
217  // pose::Pose best_pose = more_cut;
218  fragment::FrameList closure_frames;
219 
220  // try different loop sizes
221  WindowList windows;
222  for ( Size loop_size = std::min( actual_max_loop_size, min_loop_size_ );
223  loop_size <= std::min( actual_max_loop_size, max_loop_size_ ); ++loop_size ) {
224  tr.Debug << "loop-size: " << loop_size << std::endl;
225  // try different sliding windows, sorted by loop_fraction in window
226  generate_window_list( loop_size, windows ); //generates a list of windows sorted by loop-fraction
227  }
228  windows.sort();
229  windows.reverse();
230 
231  WindowList probable_windows; //fill these with windows that give success with the fast ShortLoopClosure
232 
233 
234  for ( WindowList::const_iterator it = windows.begin(), eit = windows.end();
235  it != eit && fast_loop_count < min_breakout_fast_loops_ && good_loop_count < min_breakout_good_loops;
236  ++it ) {
237 
238  fragment::FrameList closure_frames;
239  // close this loop
240  Loop const current_loop = it->second;
241  tr.Debug << "attempt closure on " << current_loop << std::endl;
242 
243  tr.Info << " unscored (vdw only) fragment sampling... " << current_loop << std::endl;
244  ShortLoopClosure fast_closure( fragset_, current_loop, movemap_ );
245  fast_closure.set_cycles( short_frag_cycle_ratio_ ); //determines number of closure attempts and frag_cycles per attempt
246  fast_closure.ramp_chainbreak();
247  if ( fast_closure.apply( more_cut ) ) {
248  closure_frames.push_back( fast_closure.closure_fragments() );
249  Size new_loops = process_fragments( closure_frames, more_cut, less_cut );
250  if ( 1.0*new_loops > ( window_acceptance_ratio_ * fast_closure.nr_fragments() ) ) {
251  tr.Info << "good window keep this for scored sampling stage" << std::endl;
252  probable_windows.push_back( *it );
253  }
254  fast_loop_count += new_loops;
255  }
256  }
257 
258  //I don't really see why this is useful... also with min_fast_loops_ = 0 this could be problematic...
259  //if ( fast_loop_count < min_fast_loops_ ) {
260  // min_breakout_good_loops = min_fast_loops_; //if we don't have enough fast loops -- try to get at least as many good loops...
261  //}
262 
263  tr.Info << "finished unscored sampling: loops found: " << fast_loop_count << " (needs " << min_fast_loops_
264  << " ) good windows: " << probable_windows.size() << " min_breakout_good_loops " << min_breakout_good_loops << std::endl;
265  for ( Size attempt_count = 0; attempt_count < nr_scored_sampling_passes_; attempt_count++ ) {
266  if ( good_loop_count >= min_breakout_good_loops ) break;
267  if ( scored_frags_attempted > give_up_ && good_loop_count == 0 ) break;
268 
269  for ( WindowList::const_iterator it = probable_windows.begin(),
270  eit = probable_windows.end(); it != eit; ++it ) {
271 
272  if ( good_loop_count >= min_breakout_good_loops ) break;
273  if ( scored_frags_attempted > give_up_ && good_loop_count == 0 ) break;
274  scored_frags_attempted += nr_scored_fragments_;
275 
276  fragment::FrameList closure_frames;
277 
278  Loop const current_loop = it->second;
279 
280  tr.Info << "scored fragment sampling on ... " << current_loop << std::endl;
281  LoopClosure scored_closure( fragset_, frag_scorefxn, current_loop, movemap_ );
282  scored_closure.set_cycles( scored_frag_cycle_ratio_ );
283  scored_closure.set_nr_fragments( nr_scored_fragments_ ); //make only 5 fragment per window ... but reiterate windows a couple of times
284  scored_closure.ramp_chainbreak();
285  // if ( bIdealLoopClosing() ){
286  // note this apply doesn't change the more_cut pose
287 
288  if ( scored_closure.apply( more_cut ) ) closure_frames.push_back( scored_closure.closure_fragments() );
289 
290  good_loop_count += process_fragments( closure_frames, more_cut, less_cut );
291  tr.Info << "process fragments... GoodLoops: " << good_loop_count << std::endl;
292 
293  } // probable_windows // if ( bIdealLoopClosing() ){
294  } // for ( attempt_count ) ... window-scans
295 
296  tr.Info << "finished sampling... Good scored Loops: " << good_loop_count << " required: " << min_good_loops_
297  << "good loops: " << fast_loop_count+good_loop_count << " ( " << min_fast_loops_ << " ) " << std::endl;
298 
299  if ( !best_fragment_.is_valid() || ( good_loop_count < min_good_loops_ && (fast_loop_count + good_loop_count) < min_fast_loops_ ) ) {
300  tr.Warning << "WARNING: no good loop found !" << std::endl;
301  throw( EXCN_Loop_not_closed() );
302  }
303 } //sample_loops
304 
305 } // namespace ccd
306 } // namesapce loop_closure
307 } // namespace loops
308 } // namespace protocols