58 #include <basic/options/option.hh>
59 #include <basic/options/keys/run.OptionKeys.gen.hh>
60 #include <basic/options/keys/out.OptionKeys.gen.hh>
61 #include <basic/options/keys/fast_loops.OptionKeys.gen.hh>
64 #include <ObjexxFCL/format.hh>
67 #include <basic/Tracer.hh>
69 #include <utility/io/ozstream.hh>
76 #include <utility/vector1.hh>
83 namespace ObjexxFCL {
namespace fmt { } }
using namespace ObjexxFCL::fmt;
90 namespace loop_closure {
97 static basic::Tracer
tr(
"protocols.loops.loop_closure.ccd.SlidingWindowLoopClosure");
104 SlidingWindowLoopClosure::SlidingWindowLoopClosure(
108 ) : scorefxn_( scorefxn ),
111 ss_info_( new core::fragment::SecondaryStructure( *fragset ) )
144 bQuickTest_ = basic::options::option[ basic::options::OptionKeys::run::dry_run ]();
147 tr.Info <<
"SlidingWindowLoopClosure::defaults " << std::endl;
152 using namespace core::io::silent;
153 using namespace basic::options;
154 if ( option[ basic::options::OptionKeys::out::file::silent ].user() ) {
158 }
else silent_file = option[ basic::options::OptionKeys::out::file::silent ]+silent_file;
175 using namespace kinematics;
176 tr.Debug <<
" SlidingWindowLoopClosure init... " << std::endl;
177 FoldTree
const& f_more( more_cut.
fold_tree() );
178 FoldTree
const& f_less( less_cut.
fold_tree() );
179 if( f_more.num_cutpoint() != f_less.num_cutpoint() + 1 ){
180 utility_exit_with_message(
" Failure in SlidingWindowLoopClosure.cc : more_cut should have one more cutpoint then less_cut. ");
185 for (
Size i = 1; i <= static_cast< Size >( f_more.num_cutpoint() ) && !cutpoint ; i++ ) {
186 Size const seqpos( f_more.cutpoint( i ) );
187 if ( !f_less.is_cutpoint( seqpos ) ) cutpoint = seqpos;
190 if( cutpoint == 0){ utility_exit_with_message(
"Failure in: SlidingWindowLoopClosure.cc: cutpoint seq num is 0 " ); }
192 tr.Debug <<
" remove cutpoint: " << cutpoint << std::endl;
201 Size min_loop_begin ( cutpoint + 1 );
202 Size max_loop_end ( cutpoint );
205 && !f_more.is_jump_point( min_loop_begin - 1 )
209 max_loop_end < f_more.nres()
210 && !f_more.is_jump_point( max_loop_end + 1 )
216 if( min_loop_begin > max_loop_end ){ utility_exit_with_message(
" Failure in SlidingWindowLoopClosure.cc : min_loop_begin > max_loop_end "); };
218 return Loop( min_loop_begin, max_loop_end, cutpoint );
225 using namespace scoring;
226 using namespace basic::options;
227 using namespace basic::options::OptionKeys;
233 tr.Debug <<
" get fragsample scorefunction... " << std::endl;
235 option[ OptionKeys::fast_loops::fragsample_score ]()
237 if ( option[ OptionKeys::fast_loops::fragsample_patch ].user() ) {
238 score_tmp_->apply_patch_from_file( option[ OptionKeys::fast_loops::fragsample_patch ] );
240 scorefxn = *score_tmp_;
242 tr.Debug <<
" get filter scorefunction... " << std::endl;
243 if ( option[ OptionKeys::fast_loops::overwrite_filter_scorefxn ].user() ) {
252 if ( option[ OptionKeys::fast_loops::patch_filter_scorefxn ].user() ) {
253 tr.Debug <<
" patch filter scorefunction... " << std::endl;
254 scorefxn_->apply_patch_from_file( option[ OptionKeys::fast_loops::patch_filter_scorefxn ] );
262 tr.Debug <<
" is there a filter_cst_ evaluator?.. " << std::endl;
263 if ( !
filter_cst_ && option[ OptionKeys::fast_loops::filter_cst_file ].user() ) {
273 apply( more_cut, more_cut );
278 return "SlidingWindowLoopClosure";
300 tr.Debug <<
"Trying loop-sizes: " <<
loop_ << std::endl;
301 tr.Info <<
"---------------- LOOP SAMPLING based on this scorefunction: ----------------\n";
302 if (
tr.Info.visible() ) frag_scorefxn->show(
tr.Info, more_cut );
303 tr.Info << std::endl;
305 tr.Debug <<
"Trying loop-sizes: " <<
loop_ << std::endl;
306 tr.Info <<
"---------------- LOOP SELECTION based on this scorefunction: ----------------\n";
307 if (
tr.Info.visible() )
scorefxn_->show(
tr.Info, more_cut );
308 tr.Info << std::endl;
316 tr.Debug <<
"MOREFOLDTREE: " << more_cut.
fold_tree();
317 tr.Debug <<
"LESSFOLDTREE: " << less_cut.
fold_tree();
333 if( basic::options::option[ basic::options::OptionKeys::run::test_cycles ]() ){
351 Size attempt_count = 0;
355 tr.Debug <<
"Trying loop-sizes: "
362 tr.Debug <<
"LOOP: " <<
loop_ << std::endl;
364 Size good_loop_count( 0 );
367 using namespace fragment;
369 FrameList closure_frames;
370 closure_frame->steal( more_cut );
373 fast_ccd.
apply( more_cut );
375 closure_frame->steal( more_cut );
378 closure_frames.push_back( closure_frame );
392 tr.Debug <<
"MOREFOLDTREE: " << more_cut.
fold_tree();
393 tr.Debug <<
"LESSFOLDTREE: " << less_cut.
fold_tree();
399 loop_size <= std::min( actual_max_loop_size,
max_loop_size_ ); ++loop_size ) {
400 tr.Debug <<
"loop-size: " << loop_size << std::endl;
407 for ( WindowList::const_iterator it = windows.begin(),
408 eit = windows.end(); it != eit; ++it ) {
413 Loop const current_loop = it->second;
414 tr.Debug <<
"attempt closure on " << current_loop <<
" # :" << attempt_count << std::endl;
417 tr.Info <<
"scored fragment sampling... " << current_loop << std::endl;
426 if ( loop_size <= 10 ) {
427 tr.Info <<
"short loop: unscored fragment sampling... " << std::endl;
435 tr.Info <<
"process fragments... GoodLoops: " << good_loop_count << std::endl;
436 if ( good_loop_count >= min_breakout_good_loops )
break;
443 tr.Warning <<
"WARNING: no good loop found !" << std::endl;
450 using namespace fragment;
453 tr.Error <<
"Cannot apply best fragment because it is not valid or there is none." << std::endl;
467 FragStore< Real > chainbreak_store(
"chainbreak");
468 FragStore< Real > overlap_store(
"overlap");
469 FragStore< Real > rms_store(
"loop_rms");
477 std::string frag_file=basic::options::option[ basic::options::OptionKeys::out::file::silent ]()+
"_best_frags";
478 utility::io::ozstream frag_stream;
479 frag_stream.open_append( frag_file );
483 Real const size_fraction( 1.0*(*it).frame().length() /
loop_.
size());
485 << RJ( 10, vdw_store.retrieve( *it ) )<<
" "
486 << RJ( 10, score_store.retrieve( *it ) )<<
" "
487 << RJ( 10, chainbreak_store.retrieve( *it) )<<
" "
488 << RJ( 10, overlap_store.retrieve( *it ) )<<
" "
489 << RJ( 10, rms_store.retrieve( *it ) )<<
" "
490 << RJ( 10, size_fraction ) <<
" "
508 Pose const& more_cut,
509 Pose const& loop_pose
511 using namespace fragment;
515 FragStore< Real > chainbreak_store(
"chainbreak");
516 FragStore< Real > overlap_store(
"overlap");
517 FragStore< Real > rms_store(
"loop_rms");
519 Size good_loop_count( 0 );
528 orig_pose = more_cut;
529 work_pose = loop_pose;
531 orig_pose = more_cut;
532 work_pose = more_cut;
539 for ( FragID_Iterator it = frame_in.begin(),
540 eit = frame_in.end(); it != eit; ++it ) {
541 if ( !it->is_valid() )
continue;
542 if ( it->apply(
movemap(), work_pose ) ) {
546 if (
bIdealLoopClosing() && !basic::options::option[ basic::options::OptionKeys::run::test_cycles ]() ) {
547 it->apply(
movemap(), orig_pose );
553 if ( check_rmsd > 0.1 ) {
554 tr.Debug <<
"skip loop: bad check_rms in loop building RMSD: "<< check_rmsd << std::endl;
573 tr.Info <<
"good loop "<< ct <<
" " << score <<
" " << start_score <<
" vdw: " << vdw_score <<
" " << vdw_start_score << std::endl;
575 vdw_store.store( *it, vdw_score-vdw_start_score);
576 score_store.store( *it, score );
577 chainbreak_store.store( *it, chainbreak_scores );
579 rms_store.store( *it, loop_rmsd );
588 tr.Debug <<
"...but on bad loop " << score <<
" " << start_score <<
" vdw: " << vdw_score <<
" " << vdw_start_score
589 <<
"chainbreak: " << chainbreak_scores << std::endl;
594 tr.Debug << ct <<
" LoopScore: " << score <<
" Best: " <<
best_score_ << std::endl;
596 tr.Debug << ct <<
" discard loop-fragment ... score: " << score <<
" chainbreak_scores: " << chainbreak_scores << std::endl;
600 return good_loop_count;
606 for (
Size ii= std::max( 0, - (
int)
loop_.
cut() + (
int) loop_size ) ; ii<= loop_size; ++ii ) {
607 runtime_assert( (
int)
loop_.
cut() - (
int) loop_size + ii + 1 > 0 );
608 Size const loop_begin(
loop_.
cut() - loop_size + ii + 1);
610 tr.Debug <<
"add-window: " << loop_begin <<
"-" << loop_end << std::endl;
611 runtime_assert( loop_begin <=
loop_.
cut()+1);
612 runtime_assert( loop_end >=
loop_.
cut() );
613 runtime_assert( loop_end == loop_begin + loop_size - 1 );
616 for (
Size i = loop_begin; i <= loop_end; ++i ) {
619 window_list.push_back( std::make_pair( f/(1.0*loop_size)-loop_size*1.0,
Loop( loop_begin, loop_end,
loop_.
cut() ) ) );