35 #include <utility/file/FileName.hh>
39 #include <basic/options/option.hh>
52 #include <basic/Tracer.hh>
54 #include <numeric/model_quality/rms.hh>
57 #include <utility/exit.hh>
58 #include <numeric/random/random.hh>
64 #if defined(WIN32) || defined(__CYGWIN__)
70 #include <basic/options/keys/loops.OptionKeys.gen.hh>
71 #include <basic/options/keys/constraints.OptionKeys.gen.hh>
75 #include <utility/vector0.hh>
76 #include <utility/vector1.hh>
77 #include <ObjexxFCL/format.hh>
91 static basic::Tracer
TR(
"protocols.looprelax_protocols");
96 static numeric::random::RandomGenerator
RG(431111);
100 using namespace protocols::loops;
106 scorefxn_( scorefxn ),
107 Loops_in_( Loops_in )
110 Mover::type(
"LoopRebuild");
126 using namespace basic::options;
127 using namespace basic::options::OptionKeys;
130 bool passed_score_filter(
false );
131 int const n_score_filter_fail_tol( 2 );
132 int n_score_filter_fail( 0 );
133 int n_loop_fail_tol( 2 );
134 int loop_build_round( 1 );
153 TR.Debug <<
"Loop file size (after filtering) : " <<
Loops_in_.
size() << std::endl;
156 init_pose_obj = pose;
158 bool loop_done(
false );
159 while( !passed_score_filter && n_score_filter_fail < n_score_filter_fail_tol ){
160 n_score_filter_fail++;
163 pose = init_pose_obj;
168 while( !loop_done && loop_nfail <= n_loop_fail_tol ) {
170 for(
int i = 0; i < loop_build_round; ++i ) {
175 if (!loop_done)
TR.Error <<
"build_random_loops() returned failure." << std::endl;
177 passed_score_filter =
true;
180 success = (loop_done && passed_score_filter);
181 if (!
success)
TR.Error <<
"LoopRebuild::apply() returned false" << std::endl;
186 return "LoopRebuild";
192 using namespace basic::options;
193 using namespace basic::options::OptionKeys;
196 static bool init = {
false };
199 rmsd_tol = option[ OptionKeys::loops::rmsd_tol ]();
200 if( rmsd_tol <= 0 ) rmsd_tol = 10000.0;
209 using namespace basic::options;
210 using namespace basic::options::OptionKeys;
213 static bool init = {
false };
217 chain_break_tol = option[ OptionKeys::loops::chain_break_tol ]();
220 return chain_break_tol;
227 using namespace basic::options;
228 using namespace basic::options::OptionKeys;
231 std::vector< int > free_res;
233 TR.Debug <<
"Loop res " << it->start() <<
" " << it->stop() << std::endl;
234 for (
int k = (
int)it->start(); k <= (
int)it->stop(); ++k )
235 free_res.push_back(k);
238 std::vector<int> inter_res;
242 std::vector< int > folded_loops;
249 for (
int loop_counter = 0; loop_counter < num_desired_loops; ++loop_counter ){
256 int selected_loop, def_loop_begin, def_loop_end, combine_number;
257 bool loops_combined(
false );
258 bool extend_this_loop = option[ OptionKeys::loops::extended ].user();
259 bool use_selected_loop =
261 inter_res, def_loop_begin, def_loop_end, cutpoint, extend_this_loop,
262 loops_combined, combine_number, loop_counter );
264 if ( !use_selected_loop )
continue;
268 int n_chain_break_fail( 1 );
269 bool is_chain_break(
true );
270 bool rmsd_acceptable(
false );
271 int barcst_extend_begin( 0 );
272 int barcst_extend_end( 0 );
273 int total_combine( 0 );
274 if ( loops_combined ) total_combine = combine_number;
275 int backward_combine( 0 );
279 barcst_extend_begin = static_cast <
int> ( numeric::random::uniform() * 2 );
280 barcst_extend_end = static_cast <
int> ( numeric::random::uniform() * 2 );
286 int final_loop_begin=0;
287 int final_loop_end=0;
288 int time_start = time(NULL);
289 float time_per_build = 0.0;
290 int nclosurefail = 0;
293 while( is_chain_break || !rmsd_acceptable ) {
297 TR.Error <<
"Failed to rebuild loop " << nfail <<
" times! Aborting." << std::endl;
312 def_loop_end =
Loops_in_[ selected_loop + total_combine + 1 ].stop();
313 extend_this_loop |=
Loops_in_[ selected_loop + total_combine + 1 ].is_extended();
316 }
else if ( selected_loop - backward_combine > 1 ){
317 def_loop_begin =
Loops_in_[ selected_loop - backward_combine - 1 ].start();
318 extend_this_loop |=
Loops_in_[ selected_loop - backward_combine - 1 ].is_extended();
328 barcst_extend_begin = static_cast <
int> ( numeric::random::uniform() * 2 );
329 barcst_extend_end = static_cast <
int> ( numeric::random::uniform() * 2 );
335 int loop_begin = def_loop_begin - 1;
336 int loop_end = def_loop_end;
337 if( loop_begin < 1 ) loop_begin = 1;
338 if( loop_end > nres ) loop_end = nres;
342 loop_begin, loop_end, def_loop_begin, def_loop_end,
343 nres, selected_loop, total_combine,
347 if( option[ OptionKeys::loops::extended_beta ].user() ){
348 Real expfactor = exp( - option[ OptionKeys::loops::extended_beta ]() * fabs( (
double) loop_begin - loop_end ) );
349 bool stochastic_extend_this_loop = ( numeric::random::uniform() < expfactor );
350 extend_this_loop = extend_this_loop || stochastic_extend_this_loop;
357 n_chain_break_fail, is_chain_break,
358 barcst_extend_begin, barcst_extend_end );
361 if( ! rmsd_acceptable ){ nclosurefail++;
TR.Info <<
"WARNING: Loop Built, rms not acceptable - trying again" << std::endl; }
362 if( is_chain_break ){ nrmsfail++;
TR.Info <<
"WARNING: Chain_break_remains - tryign again" << std::endl; }
364 final_loop_begin = loop_begin;
365 final_loop_end = loop_end;
368 int time_end = time(NULL);
369 time_per_build = float(time_end - time_start) / float(nfail);
371 using namespace ObjexxFCL::fmt;
373 <<
" " << I(3,def_loop_begin)
374 <<
" " << I(3,def_loop_end )
375 <<
" " << I(3,final_loop_begin )
376 <<
" " << I(3,final_loop_end )
377 <<
" " << I(3,final_loop_end - final_loop_begin )
378 <<
" time " << F(5,1,time_per_build )
380 <<
" " << I(3,nclosurefail )
381 <<
" " << I(3,nrmsfail)
396 int const & loop_begin,
397 int const & loop_end,
400 using namespace core::id;
405 for (
int i = loop_begin; i <= loop_end; ++i ) {
422 int const & loop_begin,
423 int const & loop_end,
425 bool const & extend_this_loop
427 using namespace kinematics;
428 using namespace scoring;
429 using namespace optimization;
430 using namespace protocols::simple_moves;
431 using namespace basic::options;
432 using namespace basic::options::OptionKeys;
441 Loop myloop( loop_begin+1, loop_end, 0 );
443 cutpoint = myloop.
cut();
445 int cut_orig = cutpoint;
446 TR.Info <<
"Loop and cutpoint: " << loop_begin
449 << (extend_this_loop ?
" extended " :
" nonextended" ) << std::endl;
454 while (cutpoint != nres &&
457 Loop myloop( loop_begin, loop_end );
459 cutpoint = myloop.
cut();
465 while (cutpoint != nres &&
468 cutpoint = loop_begin +
int(
float(loop_end - loop_begin) * uniform() );
472 TR <<
" Unable to rebuild loop [" << loop_begin <<
", " << loop_end <<
"] " << std::endl;
475 if (cutpoint != cut_orig)
476 TR <<
" Changing cutpoint to " << cutpoint <<
"" << std::endl;
479 int const loop_size( loop_end - loop_begin + 1 );
486 int base_cycles( std::max( 15, static_cast<int>( 5*loop_size*cycle_ratio )));
487 cycles3 =
loop_model() ? 2*base_cycles:base_cycles;
490 cycles3 = std::max( 30, static_cast<int>( 10*loop_size*cycle_ratio));
493 TR <<
"Number of cycles: cycles2 and cycles3 " << cycles2 <<
" " << cycles3 << std::endl;
500 for (
int i = loop_begin; i <= loop_end; ++i )
501 allow_repack[ i ] =
true;
502 this_packer_task->restrict_to_residues( allow_repack );
506 bool chainbreak_present = ( loop_begin != 1 && loop_end != nres );
512 if( chainbreak_present ){
532 movemap->set_bb_true_range(loop_begin, loop_end);
534 std::vector< FragmentMoverOP > fragmover;
535 for ( std::vector< core::fragment::FragSetOP >::const_iterator
537 it != it_end; it++ ) {
539 cfm->set_check_ss(
false );
540 cfm->enable_end_bias_check(
false );
541 fragmover.push_back( cfm );
544 if( !option[OptionKeys::loops::no_randomize_loop] ){
546 for (
int i = loop_begin; i <= loop_end; ++i ) {
547 for ( std::vector< FragmentMoverOP >::const_iterator
548 it = fragmover.begin(),it_end = fragmover.end(); it != it_end; it++ ) {
549 (*it)->apply( pose );
556 small_mover->angle_max(
'H', 2.0 );
557 small_mover->angle_max(
'E', 2.0 );
558 small_mover->angle_max(
'L', 3.0 );
562 shear_mover->angle_max(
'H', 2.0 );
563 shear_mover->angle_max(
'E', 2.0 );
564 shear_mover->angle_max(
'L', 3.0 );
568 refine_mover->add_mover( small_mover );
569 refine_mover->add_mover( shear_mover );
572 AtomTreeMinimizer mzr;
574 bool const use_nblist(
true ), deriv_check(
false );
575 MinimizerOptions options(
"linmin", dummy_tol, use_nblist, deriv_check );
582 mc_->set_temperature( temperature );
609 if( option[OptionKeys::loops::coord_cst ]() > 0.0 ){
611 for(
int ir=loop_begin; ir <= loop_end; ir++ ){
612 Real middlefactor = 1.0 - (float(std::min( std::abs(ir - loop_begin), std::abs(loop_end - ir) ))/ float(std::abs(loop_end-loop_begin))) * 2 * 0.8;
618 start_pose.residue(ir).xyz(
"CA" ),
621 new_csts->add_constraint( newcst );
626 float final_constraint_weight = option[ basic::options::OptionKeys::constraints::cst_weight ]();
635 if( has_constraints ){
649 int starttime = time(NULL);
654 TR <<
"***** CCD CLOSURE *****" << std::endl;
656 core::Real const gamma = std::pow( (final_temp/init_temp), (1.0/(cycles2*cycles3)) );
658 for(
int c2 = 1; c2 <= cycles2; ++c2 ) {
659 mc_->recover_low( pose );
663 if( has_constraints ) {
664 if( c2 != cycles2 ) {
675 for(
int c3 = 1; c3 <= cycles3; ++c3 ){
676 temperature *= gamma;
677 mc_->set_temperature( temperature );
678 for ( std::vector< FragmentMoverOP >::const_iterator
679 it = fragmover.begin(),it_end = fragmover.end(); it != it_end; it++ ) {
680 (*it)->apply( pose );
681 if( chainbreak_present )
fast_ccd_close_loops( pose, loop_begin, loop_end, cutpoint, mm_one_loop );
682 mzr.run( pose, mm_one_loop, *
scorefxn_, options );
683 mc_->boltzmann( pose,
"ccd_closure" );
690 if(
false && chainbreak_present ){
691 mc_->recover_low( pose );
692 TR <<
"--" << std::endl;
696 fast_ccd_close_loops( pose, std::max(cutpoint-3,loop_begin), std::min(cutpoint+3,loop_end), cutpoint, mm_one_loop );
704 TR <<
"***** DOING CCD MOVES *****" << std::endl;
705 float const final_chain_break_weight = 5.0;
706 float const delta_weight( final_chain_break_weight/cycles2 );
713 for (
int c2 = 1; c2 <= cycles2; ++c2 ) {
714 mc_->recover_low( pose );
717 if( has_constraints ) {
718 if( c2 != cycles2 ) {
724 if ( chainbreak_present ) {
734 for (
int c3 = 1; c3 <= cycles3; ++c3 ) {
737 if(( !chainbreak_present || uniform()*cycles2 > c2 ))
741 if( !option[OptionKeys::loops::refine_only ]() ){
742 for ( std::vector< FragmentMoverOP >::const_iterator
743 it = fragmover.begin(),it_end = fragmover.end(); it != it_end; it++ ) {
746 if( ((*it)->fragments()->max_frag_length() == 1 ) && (uniform() < option[OptionKeys::loops::skip_1mers ]() ) )
continue;
747 if( ((*it)->fragments()->max_frag_length() == 3 ) && (uniform() < option[OptionKeys::loops::skip_3mers ]() ) )
continue;
748 if( ((*it)->fragments()->max_frag_length() == 9 ) && (uniform() < option[OptionKeys::loops::skip_9mers ]() ) )
continue;
750 (*it)->apply( pose );
754 refine_mover->apply( pose );
759 if( ! option[OptionKeys::loops::skip_ccd_moves ]() ){
763 mc_->boltzmann( pose,
"ccd_moves" );
765 mzr.run( pose, mm_one_loop, *
scorefxn_, options );
769 if(
false && chainbreak_present ){
770 mc_->recover_low( pose );
771 TR <<
"--" << std::endl;
775 fast_ccd_close_loops( pose, std::max(cutpoint-3,loop_begin), std::min(cutpoint+3,loop_end), cutpoint, mm_one_loop );
783 int looptime = time(NULL) - starttime;
784 TR <<
"FragCount: " << frag_count << std::endl;
785 TR <<
"Looptime " << looptime << std::endl;
788 pose =
mc_->lowest_score_pose();
790 TR <<
"-------------------------" << std::endl;
791 mc_->show_counters();
802 int const & loop_begin,
803 int const & loop_end,
804 int const & cutpoint,
808 int const ccd_cycles = { 100 };
809 Real const ccd_tol = { 0.01 };
810 bool const rama_check = {
false };
811 Real const max_rama_score_increase = { 2.0 };
812 Real const max_total_delta_helix = { 10.0 };
813 Real const max_total_delta_strand = { 50.0 };
814 Real const max_total_delta_loop = { 75.0 };
817 Real forward_deviation, backward_deviation;
818 Real torsion_delta, rama_delta;
825 ccd_tol, rama_check, max_rama_score_increase, max_total_delta_helix,
826 max_total_delta_strand, max_total_delta_loop, forward_deviation,
827 backward_deviation, torsion_delta, rama_delta );
830 for (
int i=loop_begin; i<=loop_end; ++i) {
832 if ( ss_i !=
'L' && ss_i !=
'H' && ss_i !=
'E')
843 std::vector< int > & folded_loops,
844 std::vector< int > & inter_res,
848 bool & extend_this_loop,
849 bool & are_loops_combined,
850 int & combine_interval,
857 core::Real const num_of_loops_to_combine( numeric::random::uniform()*(num_loops - 1)*loop_combine_rate );
859 TR <<
"LoopsToCombine: " << num_of_loops_to_combine <<
" " << num_loops << std::endl;
867 selected_loop = (
int)( numeric::random::uniform()*num_loops + 1);
869 }
while( std::find( folded_loops.begin(), folded_loops.end(), selected_loop ) !=
870 folded_loops.end() );
871 folded_loops.push_back(selected_loop);
873 loop_begin =
Loops_in_[selected_loop].start();
874 loop_end =
Loops_in_[selected_loop].stop();
875 cutpoint =
Loops_in_[selected_loop].cut();
876 extend_this_loop |=
Loops_in_[selected_loop].is_extended();
878 if (loop_begin <= 0) loop_begin = 1;
879 if (loop_end >= nres) loop_end = nres;
887 combine_interval = 1;
889 if ( selected_loop < num_loops - combine_interval && num_of_loops_to_combine > 0 ) {
890 int const longer_loop_size (
Loops_in_[ selected_loop + combine_interval ].
stop() -
893 int const terminal_loop(12);
894 int const internal_loop(25);
895 if( (
int)
Loops_in_[ selected_loop + combine_interval ].
stop() >= nres ||
897 loop_limit = terminal_loop;
898 else loop_limit = internal_loop;
904 if ( numeric::random::uniform() < num_of_loops_to_combine/(num_loops-1+1e-10 ) ) {
906 loop_begin =
Loops_in_[selected_loop].start();
907 loop_end =
Loops_in_[selected_loop].stop() + combine_interval;
908 TR.Info <<
"Combining loops: " << loop_begin <<
" " << loop_end << std::endl;
910 if( longer_loop_size > loop_limit ){
911 if( numeric::random::uniform() < 0.5 ){
912 loop_begin = loop_end - (loop_limit - 1);
914 loop_end = loop_begin + (loop_limit - 1);
918 for (
int ll = 0; ll < combine_interval; ++ll ){
919 for (
int k = (
int)
Loops_in_[ selected_loop +ll ].stop();
921 inter_res.push_back(k);
923 folded_loops.push_back(selected_loop+ll+1);
927 are_loops_combined =
true;
935 int rand_extension = 0;
943 if ( loop_begin > 1 )
944 loop_begin = loop_begin - static_cast <
int> ( numeric::random::uniform() * rand_limit )
946 if ( loop_end != nres )
947 loop_end = loop_end + static_cast <
int> ( numeric::random::uniform() * rand_limit )
950 }
while ( numeric::random::uniform() < 0.3 );
952 if ( loop_end - loop_begin < 0 ){
956 loop_begin = std::max( 1, loop_begin );
957 loop_end = std::min( nres, loop_end );
966 using namespace basic::options;
967 using namespace basic::options::OptionKeys;
969 static core::Real score_filter_cutoff = { 1.0 };
970 static bool init = {
false };
973 score_filter_cutoff = option[OptionKeys::loops::score_filter_cutoff ]();
976 return score_filter_cutoff;
982 using namespace basic::options;
983 using namespace basic::options::OptionKeys;
986 static bool init = {
false };
989 loop_model = option[ OptionKeys::loops::loop_model ];
999 using namespace basic::options;
1000 using namespace basic::options::OptionKeys;
1002 static bool ccd_closure_exist = {
false };
1003 static bool init = {
false };
1006 ccd_closure_exist = option[ OptionKeys::loops::ccd_closure];
1009 return ccd_closure_exist;
1015 using namespace basic::options;
1016 using namespace basic::options::OptionKeys;
1018 static bool desired_loops_exist = {
false };
1019 static bool init = {
false };
1022 desired_loops_exist = option[ OptionKeys::loops::loops_subset];
1025 return desired_loops_exist;
1031 using namespace basic::options;
1032 using namespace basic::options::OptionKeys;
1034 static bool init =
false;
1035 static int desired_loop = 1;
1038 desired_loop = option[ OptionKeys::loops::num_desired_loops]();
1041 return desired_loop;
1047 using namespace basic::options;
1048 using namespace basic::options::OptionKeys;
1050 static bool init = {
false };
1054 loop_combine_rate = option[ OptionKeys::loops::loop_combine_rate ]();
1057 return loop_combine_rate;
1063 using namespace basic::options;
1064 using namespace basic::options::OptionKeys;
1066 static bool combine_loop = {
true };
1067 static bool init = {
false };
1070 combine_loop = option[ OptionKeys::loops::no_combine_if_fail];
1073 return combine_loop;
1080 int & barcst_extend_begin,
1081 int & barcst_extend_end,
1084 int const & old_loop_begin,
1085 int const & old_loop_end,
1087 int const & selected_loop,
1088 int const & total_combine,
1089 int const & backward_combine
1094 int barcst_begin ( old_loop_begin );
1095 int barcst_end ( old_loop_end );
1097 barcst_extend_begin = std::min( 5, barcst_extend_begin );
1098 barcst_extend_end = std::min( 5, barcst_extend_end );
1101 barcst_begin -= barcst_extend_begin;
1102 barcst_end += barcst_extend_end;
1103 while ( barcst_begin < 1 ) barcst_begin++;
1104 while ( barcst_end > nres ) barcst_end--;
1107 if ( selected_loop - backward_combine > 1 )
1108 while ( barcst_begin <= (
int)
Loops_in_[ selected_loop - backward_combine -1 ].
stop() + 1 )
1110 if ( selected_loop + total_combine != num_loop )
1111 while ( barcst_end >= (
int)
Loops_in_[ selected_loop + total_combine +1 ].
start() - 1 )
1116 if( barcst_end == nres && barcst_end - barcst_begin > 10 )
1117 barcst_begin = barcst_end - 10;
1118 if( barcst_begin == 1 && barcst_end - barcst_begin > 10 )
1119 barcst_end = barcst_begin + 10;
1123 if ( barcst_end - barcst_begin < 2 && barcst_begin != 1 && barcst_end != nres ){
1128 loop_begin = barcst_begin;
1129 loop_end = barcst_end;
1134 TR.Debug <<
"barcode_extend_stems(): loop_begin = " << loop_begin <<
1135 " loop_end =" << loop_end <<
1137 for (
int i=loop_begin; i<= loop_end; ++i )
1139 TR.Debug << std::endl;
1145 using namespace basic::options;
1146 using namespace basic::options::OptionKeys;
1148 static bool init = {
false };
1149 static bool short_loop = {
false };
1152 short_loop = option[ OptionKeys::loops::shorten_long_terminal_loop];
1163 int const & loop_begin,
1164 int const & loop_end,
1165 int & n_chain_break_fail,
1166 bool & is_chain_break,
1167 int & barcst_extend_begin,
1168 int & barcst_extend_end
1170 static int n_small_chain_break_fail = { 1 };
1171 static bool barcst_flip_flop = {
true };
1172 static bool barcst_small_flip_flop = {
true };
1173 is_chain_break =
false;
1181 (*scorefxn_)( pose );
1182 if ( loop_begin != 1 && loop_end != nres ){
1188 TR.Debug <<
"loop_begin and loop_end " << loop_begin <<
" " << loop_end <<
" " << chain_break_score << std::endl;
1190 TR.Debug <<
"*****\n*****\n*****\n";
1192 TR.Debug <<
"*****\n*****\n*****\n";
1195 TR.Info <<
"Chainbreak: " << chain_break_score <<
" Max: " << chain_break_tol << std::endl;
1196 if ( chain_break_score > chain_break_tol ){
1197 is_chain_break =
true;
1198 n_chain_break_fail++;
1200 if( chain_break_score <= 10* chain_break_tol )
1201 n_small_chain_break_fail++;
1204 if ( chain_break_score > 10* chain_break_tol ) {
1205 if( barcst_flip_flop ){
1209 barcst_extend_begin++;
1210 barcst_flip_flop =
false;
1212 barcst_extend_end++;
1213 barcst_flip_flop =
true;
1216 else if ( n_small_chain_break_fail % 3 == 0 ) {
1217 if( barcst_small_flip_flop ){
1218 barcst_extend_begin++;
1219 barcst_small_flip_flop =
false;
1221 barcst_extend_end++;
1222 barcst_small_flip_flop =
true;
1237 using ObjexxFCL::FArray2D;
1238 FArray2D< core::Real > p1a( 3, natoms );
1239 FArray2D< core::Real > p2a( 3, natoms );
1244 int atom_count( 0 );
1249 for(
int k = 0; k < 3; ++k ){
1250 p1a( k+1, atom_count ) = vec1[ k ];
1251 p2a( k+1, atom_count ) = vec2[ k ];
1254 core::Real rmsd( numeric::model_quality::rms_wrapper( natoms, p1a, p2a ) );
1255 TR.Debug <<
"RMSd change " << rmsd << std::endl;
1256 if ( rmsd <= rmsd_tol )
return true;
1264 using namespace basic::options;
1265 using namespace basic::options::OptionKeys;
1267 static bool init = {
false };
1271 cycle_ratio = option[ OptionKeys::loops::looprlx_cycle_ratio ]();
1282 extend_loops = basic::options::option[ basic::options::OptionKeys::loops::extended ];
1312 std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
1313 std::string::size_type pos = str.find_first_of(delimiters, lastPos);
1315 while (std::string::npos != pos || std::string::npos != lastPos) {
1316 tokens.push_back(str.substr(lastPos, pos - lastPos));
1317 lastPos = str.find_first_not_of(delimiters, pos);
1318 pos = str.find_first_of(delimiters, lastPos);
1324 void LoopRebuild::read_loop_file(
1325 utility::vector1< LRLoop > &loops,
1326 std::string filename
1329 std::ifstream infile( filename.c_str() );
1331 if (!infile.good()) {
1332 utility_exit_with_message( "[ERROR] Error opening RBSeg file '" + filename + "'" );
1335 utility::vector1< std::string > tokens;
1337 while( getline(infile,line) ) {
1338 Tokenize( line, tokens ) ;
1340 if( tokens.size() > 0 ) {
1341 if ( tokens[1] == "LOOP" ) {
1342 if ( tokens.size() < 3 ) {
1343 utility_exit_with_message( "[ERROR] Error parsing line '" + line + "'" );
1345 core::Size start_res = (core::Size) atoi(tokens[2].c_str());
1346 core::Size end_res = (core::Size) atoi(tokens[3].c_str());
1347 core::Size cutpt = 0; // default - let LoopRebuild choose cutpoint
1348 core::Real skip_rate = 0.0; // default - never skip
1349 std::string extend_loop_str;
1350 bool extend_loop = false;
1352 if (tokens.size() > 3)
1353 cutpt = (core::Size) atoi(tokens[4].c_str());
1354 if (tokens.size() > 4)
1355 skip_rate = atof(tokens[5].c_str());
1356 if (tokens.size() > 5)
1357 extend_loop_str = tokens[6];
1359 if (extend_loop_str.length() > 0)
1362 if( start_res >= end_res ){
1363 utility_exit_with_message( "[ERROR] Line '" + string_of(line) + "' has invalid loop definition (start residue >= end residue) - ERROR" );
1365 loops.push_back( LRLoop(start_res, end_res, cutpt, skip_rate, extend_loop) );
1367 } else if ( tokens[1][0] != '#' ) {
1368 if (tokens.size() >= 2) {
1369 TR << "[WARNING] Reading r++ style loopfile" << std::endl;
1370 core::Size start_res = (core::Size) atoi(tokens[1].c_str());
1371 core::Size end_res = (core::Size) atoi(tokens[2].c_str());
1372 core::Size cutpt = 0; // default - let LRLoopRebuild choose cutpoint
1373 core::Real skip_rate = 0.0; // default - never skip
1374 bool extend_loop = false;
1376 if (tokens.size() > 2)
1377 cutpt = (core::Size) atoi(tokens[3].c_str());
1378 if (tokens.size() > 3)
1379 skip_rate = atof(tokens[4].c_str());
1381 if( start_res >= end_res ){
1382 utility_exit_with_message( "[ERROR] Line '" + string_of(line) + "' has invalid loop definition (start residue >= end residue) - ERROR" );
1384 loops.push_back( LRLoop(start_res, end_res, cutpt, skip_rate, extend_loop) );
1387 TR << "[WARNING] Skipping line '" << line << "'" << std::endl;
1394 // sort by start residue
1395 std::sort( loops.begin(), loops.end(), Loop_lt() );
1397 // debug ... print in the data structure
1398 for (core::Size i=1; i<=loops.size(); ++i) {
1399 TR << "[debug] LOOP " << loops[i].start() << " " << loops[i].stop()
1400 << " " << loops[i].cut() << " " << loops[i].skip_rate() << std::endl;
1434 random_loop_flag_ = basic::options::option[ basic::options::OptionKeys::loops::random_loop ];
1455 TR <<
"***** Starting full-atom loop refinement protocol ****" << std::endl;
1460 Loop refine_loop( *it );
1462 LoopsToRefine->add_loop( refine_loop );
1472 refine_ccd.
apply( pose );
1478 return "LoopRefine";