31 #include <basic/Tracer.hh>
32 #include <basic/options/option.hh>
33 #include <basic/options/keys/loops.OptionKeys.gen.hh>
36 #include <utility/vector1.hh>
39 #include <numeric/random/random.fwd.hh>
40 #include <numeric/random/random_permutation.hh>
43 #include <ObjexxFCL/string.functions.hh>
44 #include <ObjexxFCL/format.hh>
50 #if defined(WIN32) || defined(__CYGWIN__)
57 namespace loop_mover {
59 static numeric::random::RandomGenerator
RG(47537);
63 using namespace ObjexxFCL;
64 using namespace ObjexxFCL::fmt;
69 Mover::type(
"IndependentLoopMover");
77 Mover::type(
"IndependentLoopMover");
85 Mover::type(
"IndependentLoopMover");
93 Mover::type(
"IndependentLoopMover");
101 using namespace basic::options;
102 using namespace basic::options::OptionKeys;
114 using namespace basic::options;
115 using namespace basic::options::OptionKeys;
121 tr().Info <<
"ALL_LOOPS:" << *
loops() << std::endl;
123 Loops selected_loops;
125 tr().Info <<
"SELECTEDLOOPS:" << selected_loops << std::endl;
134 int select_best_loop_from = option[ OptionKeys::loops::select_best_loop_from ]();
138 for (
Loops::iterator it=selected_loops.v_begin(), it_end=selected_loops.v_end();
139 it != it_end; ++it ) {
142 Loop buildloop( *it );
148 tr().Info <<
"Setting extended torsions: " << buildloop << std::endl;
152 pose_initial.fold_tree( f_orig );
156 int time_start = time(NULL);
160 tr().Info <<
"Building Loop: " << buildloop << std::endl;
164 Real best_score = 10000000.0;
167 for (
int extension_attempt = 0; extension_attempt <=
grow_attempts_; extension_attempt ++ ){
170 loops()->grow_loop_away_from_sheets( pose, buildloop, 1.0 );
172 for (
int build_attempt = 0; build_attempt <
build_attempts_; build_attempt ++ ){
173 tr().Info <<
"Building Loop attempt: " << build_attempt << std::endl;
178 std::string checkname =
"loop_" + string_of( lcount ) +
"_" + string_of( extension_attempt ) +
"_" + string_of( build_attempt );
181 bool checkpoint_recovery =
false;
184 checkpoint_recovery =
true;
187 checkpoint_recovery =
true;
190 checkpoint_recovery =
true;
198 result_of_loopModel =
model_loop( pose, buildloop );
203 if ( ! checkpoint_recovery ){
204 get_checkpoints()->checkpoint( pose, curr_job_tag, checkname +
"_S",
true );
215 if ( pose_score < best_score || best_count == 0 ){
217 best_score = pose_score;
219 tr().Debug <<
"Adding a " << best_score << std::endl;
221 if ( best_count >= (
Size)select_best_loop_from )
break;
228 if ( ! checkpoint_recovery ){
229 get_checkpoints()->checkpoint( pose, curr_job_tag, checkname +
"_F",
true );
236 if ( ! checkpoint_recovery ){
237 get_checkpoints()->checkpoint( pose, curr_job_tag, checkname +
"_C",
true );
240 tr().Error <<
"Unable to build this loop - a critical error occured. Moving on .. " << std::endl;
247 if ( best_count >= (
Size)select_best_loop_from )
break;
254 tr().Info <<
"result of loop closure:0 success, 3 failure " << result_of_loopModel << std::endl;
255 if(result_of_loopModel !=
Success){
261 pose_initial = best_pose;
267 int time_end = time(NULL);
268 float time_per_build = float(time_end - time_start) / float(nfailure+1);
270 tr().Info <<
"Loopstat: "
271 <<
" " << I(3,it->start())
272 <<
" " << I(3,it->stop())
273 <<
" " << I(3,buildloop.
start() )
274 <<
" " << I(3,buildloop.
stop() )
275 <<
" " << I(3,buildloop.
size())
276 <<
" time " << F(5,1,time_per_build )
277 <<
" " << I(3,nfailure)
278 <<
" time " << F(5,1,time_per_build * nfailure )
289 using namespace basic::options;
290 using namespace basic::options::OptionKeys;
295 if ( option[ OptionKeys::loops::build_specific_loops ].user() ) {
298 option[ OptionKeys::loops::build_specific_loops ]
301 for (
Size i = 1; i <= loop_numbers.size(); ++i ) {
302 if ( loop_numbers[i] <= 0 ){
303 utility_exit_with_message(
"Specified loop numbers is 0 or below.");
306 utility_exit_with_message(
"Specified loop number is greater than the number of loops in the loop file itself.");
308 temp_loops.add_loop( ( *
loops() )[ loop_numbers[i] ] );
315 ( numeric::random::uniform() >= it->skip_rate() )
317 temp_loops.add_loop( *it );
323 std::sort( temp_loops.v_begin(), temp_loops.v_end(),
Loop_lt() );
325 for (
Size l=1; l <= temp_loops.size(); l++ ) {
326 if ( ( l == temp_loops.size() ) ||
329 comb_loops.add_loop( temp_loops[ l ] );
332 temp_loops[ l ].
start(),
333 temp_loops[ l+1 ].
stop(),
334 temp_loops[ l ].cut(),
336 temp_loops[ l ].is_extended() || temp_loops[ l+1 ].is_extended()
339 comb_loops.add_loop( combined_loop );
347 numeric::random::random_permutation( comb_loops.v_begin(), comb_loops.v_end(),
RG);
350 selected_loops = comb_loops;
355 return "IndependentLoopMover";