28 #endif // BOINC_GRAPHICS
29 #include <boost/foreach.hpp>
30 #define foreach BOOST_FOREACH
38 #include <utility/tag/Tag.hh>
64 #include <basic/Tracer.hh>
89 #include <utility/exit.hh>
108 #include <basic/options/keys/in.OptionKeys.gen.hh>
109 #include <basic/options/keys/out.OptionKeys.gen.hh>
110 #include <basic/options/keys/loops.OptionKeys.gen.hh>
111 #include <basic/options/keys/relax.OptionKeys.gen.hh>
112 #include <basic/options/keys/cm.OptionKeys.gen.hh>
113 #include <basic/options/keys/edensity.OptionKeys.gen.hh>
123 #include <utility/Bound.hh>
124 #include <utility/vector0.hh>
125 #include <utility/vector1.hh>
126 #include <utility/keys/SmallKeyVector.hh>
127 #include <utility/options/BooleanOption.hh>
128 #include <basic/options/option.hh>
130 #if defined(WIN32) || defined(__CYGWIN__)
135 namespace protocols {
136 namespace comparative_modeling {
155 cmd_line_csts_( true ),
156 copy_sidechains_( true ),
157 n_rebuild_tries_( 3 ),
158 rebuild_filter_( 999 ),
160 intermedrelax_( intermedrelax ),
176 cmd_line_csts_( true ),
177 copy_sidechains_( true ),
178 n_rebuild_tries_( 3 ),
179 rebuild_filter_( 999 ),
181 intermedrelax_( intermedrelax ),
194 cmd_line_csts_( true ),
195 copy_sidechains_( true ),
196 n_rebuild_tries_( 3 ),
197 rebuild_filter_( 999 ),
199 intermedrelax_( intermedrelax ),
202 guarded_loops_( guarded_loops )
207 cmd_line_csts_( src.cmd_line_csts_ ),
208 copy_sidechains_( src.copy_sidechains_ ),
209 n_rebuild_tries_( src.n_rebuild_tries_ ),
210 rebuild_filter_( src.rebuild_filter_ ),
211 remodel_( src.remodel_ ),
212 intermedrelax_( src.intermedrelax_ ),
213 refine_( src.refine_ ),
214 relax_( src.relax_ ),
215 guarded_loops_( src.guarded_loops_ ),
216 cen_scorefxn_( src.cen_scorefxn_ ),
217 fa_scorefxn_( src.fa_scorefxn_ ),
218 frag_libs_( src.frag_libs_ ),
219 compute_rmsd_( src.compute_rmsd_ )
226 if (
this != &rhs ) {
290 using namespace core;
291 using namespace basic::options;
292 using namespace basic::options::OptionKeys;
296 basic::Tracer
TR(
"protocols.looprelax");
298 TR <<
"==== Loop protocol: ================================================="
300 TR <<
" remodel " <<
remodel() << std::endl;
302 TR <<
" refine " <<
refine() << std::endl;
303 TR <<
" relax " <<
relax() << std::endl;
307 if ( option[ in::file::native ].user() ) {
311 native_pose = start_pose;
314 if ( start_pose.
total_residue() != native_pose.total_residue() ) {
319 int nnonvrt_native = native_pose.total_residue();
320 while ( nnonvrt_native>0 && native_pose.residue( nnonvrt_native ).aa() ==
core::chemical::aa_vrt ) nnonvrt_native--;
321 if ( nnonvrt_native != nnonvrt_start )
322 utility_exit_with_message(
323 "Start pose and native pose don't match in length"
329 evaluator->add_evaluation(
333 #ifdef BOINC_GRAPHICS
335 boinc::Boinc::set_graphics_native_pose( native_pose );
342 if (
loops->size() == 0 ) {
343 TR.Debug <<
"picking loops by chainbreak score." << std::endl;
345 start_pose, option[ cm::min_loop_size ]() );
346 *
loops = *loops_picked;
348 if (
loops->size() == 0 ) {
349 TR.Debug <<
"no loops found." << std::endl;
354 loops->verify_against( start_pose );
355 TR.Debug <<
loops << std::endl;
357 if ( option[ OptionKeys::loops::extended ]() )
loops->set_extended(
true );
363 if( option[ OptionKeys::loops::superimpose_native ]() ){
365 for (
core::Size ir=1; ir <= native_pose.total_residue(); ++ir ) {
366 if( !
loops->is_loop_residue( ir ) ){
367 id::AtomID const id1( native_pose_super.residue(ir).atom_index(
"CA"), ir );
369 atom_map.set(id1, id2);
373 if ( debug ) pose.
dump_pdb(curr_job_tag +
"_after_super_pose.pdb");
374 if ( debug ) native_pose_super.dump_pdb(curr_job_tag +
"_after_super_native.pdb");
378 bool const fullatom_output(
379 option[ out::file::fullatom ]() ||
refine() !=
"no" ||
relax() !=
"no"
382 if (fullatom_input) {
389 checkpoints_.
checkpoint( pose, curr_job_tag,
"initial",
true );
391 #ifdef BOINC_GRAPHICS
393 boinc::Boinc::attach_graphics_current_pose_observer( pose );
404 loops->auto_choose_cutpoints( pose );
408 bool remove_extended_loops = option[ OptionKeys::loops::remove_extended_loops ]();
409 if (remove_extended_loops) {
413 if ( it->is_extended() && it->skip_rate() == 0.0 ) {
414 TR <<
"Removing loop: " << *it << std::endl;
415 int lstart = it->start();
if (lstart != 1) lstart++;
417 for (
core::Size r = lstart; r<= it->stop(); ++r) {
420 900.000 + numeric::random::uniform()*100.000,
421 900.000 + numeric::random::uniform()*100.000,
422 900.000 + numeric::random::uniform()*100.000
439 if ( option[ OptionKeys::loops::build_initial ].user() ) {
440 TR <<
"====================================================================================" << std::endl;
441 TR <<
"===" << std::endl;
442 TR <<
"=== Initial Building " << std::endl;
443 TR <<
"===" << std::endl;
445 if ( !checkpoints_.
recover_checkpoint( pose, curr_job_tag,
"initial_build",
false,
true) ) {
446 if ( debug ) pose.
dump_pdb(curr_job_tag +
"_before_initial_build.pdb");
467 quick_ccd.
apply( pose );
475 (*cen_scorefxn_)(pose);
476 if ( debug ) pose.
dump_pdb(curr_job_tag +
"_after_initial_build.pdb");
478 checkpoints_.
checkpoint( pose, curr_job_tag,
"initial_build",
true);
484 if ( basic::options::option[ basic::options::OptionKeys::loops::random_grow_loops_by ].user() ) {
485 loops->grow_all_loops( pose , basic::options::option[ basic::options::OptionKeys::loops::random_grow_loops_by ]() );
506 if ( option[ in::fix_disulf ].user() ) {
525 long starttime = time(NULL);
526 bool all_loops_closed =
true;
527 bool tmp_all_loops_closed =
false;
529 TR <<
"====================================================================================" << std::endl;
530 TR <<
"===" << std::endl;
531 TR <<
"=== Remodel " << std::endl;
532 TR <<
"===" << std::endl;
533 all_loops_closed =
false;
534 if ( !checkpoints_.
recover_checkpoint( pose, curr_job_tag,
"remodel",
false,
true) ) {
536 if ( debug ) pose.
dump_pdb(curr_job_tag +
"_before_rebuild.pdb");
543 TR.Debug <<
"Remodeling attempt " << ii <<
"." << std::endl;
544 if (
remodel() ==
"old_loop_relax") {
546 loop_rebuild.
apply( pose );
565 if ( !remodel_mover ) {
566 utility_exit_with_message(
"Error: no remodel mover defined!" );
568 if ( ! (
remodel() ==
"perturb_kic" ) ) {
573 remodel_mover->add_fragments(
frag_libs()[i] );
578 if (
remodel() ==
"perturb_kic" ) {
583 remodel_mover->get_checkpoints()->set_type(
"Remodel");
584 remodel_mover->set_current_tag( curr_job_tag );
585 remodel_mover->set_native_pose(
new Pose( native_pose ) );
586 remodel_mover->apply( pose );
588 if (
remodel() ==
"perturb_kic" ) {
591 TR <<
"Structure " <<
" failed initial kinematic closure. Skipping..." << std::endl;
598 tmp_all_loops_closed = remodel_mover->get_all_loops_closed();
600 current_sc = (*cen_scorefxn_)( pose );
602 if(option[ OptionKeys::cm::loop_rebuild_filter ].user() || (
remodel() ==
"old_loop_relax")){
603 TR <<
"classic check for loop closure" << std::endl;
604 current_sc = (*cen_scorefxn_)( pose );
606 all_loops_closed =
true;
612 if(tmp_all_loops_closed){
613 all_loops_closed =
true;
619 if ( debug ) pose.
dump_pdb(curr_job_tag +
"_after_rebuild.pdb");
620 checkpoints_.
checkpoint( pose, curr_job_tag,
"remodel",
true);
624 else { all_loops_closed =
true; }
626 long endtime = time(NULL);
628 TR <<
"Buildtime: " << endtime - starttime << std::endl;
640 if ( option[ in::file::native ].user() ) {
653 if ( fullatom_output ) {
661 !option[ OptionKeys::loops::build_initial ].user() &&
667 TR <<
"===================================================================================="
669 TR <<
"===" << std::endl;
670 TR <<
"=== Fullatom " << std::endl;
671 TR <<
"===" << std::endl;
673 if ( debug ) pose.
dump_pdb(curr_job_tag +
"_before_fullatom.pdb");
674 TR <<
"Annotated sequence before fa switch: " << pose.
annotated_sequence(
true) << std::endl;
681 bool needToRepackAtAll = !fullatom_input;
683 if ( debug ) pose.
dump_pdb(curr_job_tag +
"_after_fullatom.pdb");
695 TR.Debug <<
"Repacking because in loop: " << i << std::endl;
696 needToRepack[i] =
true;
708 if ( (ca_pos - start_pose.
residue(i).
atom(j).
xyz()).length() > 20 ) {
709 TR.Debug <<
"Missing dens: " << i << std::endl;
710 needToRepack[i] =
true;
717 if ( !needToRepack[i] ) {
720 TR.Debug <<
"Copying sidechain from template: " << i << std::endl;
722 needToRepackAtAll =
true;
741 core::Real constrain_rigid_segments_weight = option[ OptionKeys::loops::constrain_rigid_segments ]();
742 if( constrain_rigid_segments_weight > 0.0 ){
749 std::cout <<
"Restraining the following segments: " << std::endl << coordconstraint_segments << std::endl;
752 using namespace core;
753 using namespace conformation;
754 using namespace core::scoring;
755 using namespace core::scoring::constraints;
769 dynamic_cast<core::conformation::symmetry::SymmetricConformation &> ( pose.
conformation()) );
771 nmonomerres = symm_info->num_independent_residues();
774 if (!option[ OptionKeys::relax::coord_cst_width ].user() ) {
775 Real const coord_sdev( option[ OptionKeys::relax::coord_cst_stdev ] );
777 for (
Size i = 1; i<=nmonomerres; ++i ) {
781 for (
Size ii = 1; ii<=nat_i_rsd.last_backbone_atom(); ++ii ) {
799 Real const cst_width( option[ OptionKeys::relax::coord_cst_width ]() );
800 Real const coord_sdev( option[ OptionKeys::relax::coord_cst_stdev ]() );
801 for (
Size i = 1; i<=nmonomerres; ++i ) {
805 for (
Size ii = 1; ii<= nat_i_rsd.last_backbone_atom(); ++ii ) {
807 new BoundFunc( 0, cst_width, coord_sdev,
"xyz" )) );
838 if ( option[ edensity::mapfile ].user() ) {
842 if ( debug ) pose.
dump_pdb(curr_job_tag +
"_before_repack.pdb");
843 if ( needToRepackAtAll ) {
844 TR <<
"Repacking required" << std::endl;
845 TR <<
"Detecting disulfides" << std::endl;
846 TR <<
"Annotated sequence before repack: " << pose.
annotated_sequence(
true) << std::endl;
849 using namespace core::pack::task;
850 using namespace core::pack::task::operation;
856 PackerTaskOP taskstd = tf->create_task_and_apply_taskoperations( pose );
859 taskstd->restrict_to_residues(needToRepack);
867 TR<<
"disabling minimization on disulfide residue "<<i<<std::endl;
868 mm->set_chi( i,
false );
895 (*fa_scorefxn_)(pose);
896 TR <<
"No repacking required" << std::endl;
897 (*fa_scorefxn_)(pose);
900 if ( debug ) pose.
dump_pdb(curr_job_tag +
"_after_repack.pdb");
909 TR <<
"====================================================================================" << std::endl;
910 TR <<
"===" << std::endl;
911 TR <<
"=== Intermediate Relax " << std::endl;
912 TR <<
"===" << std::endl;
915 if ( option[ OptionKeys::loops::relax_with_foldtree ].user() ){
928 if ( option[ in::file::native ].user() ) {
929 if( option[ OptionKeys::loops::superimpose_native ]() ){
940 if ( debug ) pose.
dump_pdb(curr_job_tag +
"_before_relax.pdb");
943 relax_prot->set_current_tag( curr_job_tag );
944 relax_prot->apply( pose );
949 seqrelax.
apply( pose );
951 checkpoints_.
checkpoint( pose, curr_job_tag,
"relax",
true);
960 if ( option[ in::file::native ].user() ) {
961 if( option[ OptionKeys::loops::superimpose_native ]() ){
978 if (
refine() !=
"no" && (all_loops_closed)) {
979 TR <<
"====================================================================================" << std::endl;
980 TR <<
"===" << std::endl;
981 TR <<
"=== Refine " << std::endl;
982 TR <<
"===" << std::endl;
984 long starttime = time(NULL);
988 if ( option[ in::file::native ].user() ) {
989 if( option[ OptionKeys::loops::superimpose_native ]() ){
999 if (
refine() ==
"refine_kic" ) {
1006 TR <<
"fold_tree_before_refine " << pose.
fold_tree() << std::endl;
1008 if ( !checkpoints_.
recover_checkpoint( pose, curr_job_tag,
"refine",
true ,
true) ) {
1010 if ( debug ) pose.
dump_pdb(curr_job_tag +
"_before_refine.pdb");
1011 if (
refine() ==
"refine_ccd" ) {
1014 refine_ccd.
apply( pose );
1016 if (
refine() ==
"refine_kic" ) {
1020 refine_kic.
apply( pose );
1022 if ( debug ) pose.
dump_pdb(curr_job_tag +
"_after_refine.pdb");
1023 checkpoints_.
checkpoint( pose, curr_job_tag,
"refine",
true);
1027 if ( option[ OptionKeys::loops::kic_use_linear_chainbreak ]() ){
1029 pose,
"final_chainbreak",
1034 pose,
"final_chainbreak",
1046 endtime = time(NULL);
1048 TR <<
"Refinetime: " << endtime - starttime << std::endl;
1051 if (
refine() !=
"no" && (!all_loops_closed)) {
1055 if ( option[ in::file::native ].user() ) {
1056 if( option[ OptionKeys::loops::superimpose_native ]() ){
1073 if ( option[ OptionKeys::loops::idealize_after_loop_close ].user() && (all_loops_closed)) {
1076 pose.
dump_pdb(curr_job_tag +
"_before_idealize.pdb");
1079 idealizer.
fast(
false );
1080 idealizer.
apply( pose );
1082 pose.
dump_pdb(curr_job_tag +
"_after_idealize.pdb");
1093 if (
relax() !=
"no" && (all_loops_closed)) {
1094 TR <<
"====================================================================================" << std::endl;
1095 TR <<
"===" << std::endl;
1096 TR <<
"=== Relax " << std::endl;
1097 TR <<
"===" << std::endl;
1100 if ( option[ OptionKeys::loops::relax_with_foldtree ].user() ){
1113 if ( option[ in::file::native ].user() ) {
1114 if( option[ OptionKeys::loops::superimpose_native ]() ){
1124 if ( debug ) pose.
dump_pdb(curr_job_tag +
"_before_relax.pdb");
1125 if (
relax() ==
"relax" ) {
1127 relax_prot->set_current_tag( curr_job_tag );
1128 relax_prot->apply( pose );
1129 }
else if ((
relax() ==
"fastrelax" ) ||
1130 (
relax() ==
"seqrelax" )) {
1133 seqrelax.
apply( pose );
1134 }
else if (
relax() ==
"minirelax" ) {
1137 mini_relax.
apply( pose );
1139 checkpoints_.
checkpoint( pose, curr_job_tag,
"relax",
true);
1151 if ( debug ) pose.
dump_pdb(curr_job_tag +
"_after_relax.pdb");
1153 if ( option[ OptionKeys::loops::final_clean_fastrelax ]() ) {
1160 if ( !checkpoints_.
recover_checkpoint( pose, curr_job_tag,
"ffrelax",
true ,
true ) ) {
1163 fast_relax.
apply( pose );
1164 checkpoints_.
checkpoint( pose, curr_job_tag,
"ffrelax",
true);
1169 if (
relax() !=
"no" && (!all_loops_closed)) {
1173 if ( option[ in::file::native ].user() ) {
1174 if( option[ OptionKeys::loops::superimpose_native ]() ){
1189 TR <<
"====================================================================================" << std::endl;
1190 TR <<
"===" << std::endl;
1191 TR <<
"=== Getting Statistics " << std::endl;
1192 TR <<
"===" << std::endl;
1193 TR <<
"===" << std::endl;
1199 if ( option[ in::file::native ].user() ) {
1200 if( option[ OptionKeys::loops::superimpose_native ]() ){
1216 if ( debug ) pose.
dump_pdb(curr_job_tag +
"_before_final_rescore.pdb");
1218 if (fullatom_output) final_score = (*fa_scorefxn_)(pose);
1219 else final_score = (*cen_scorefxn_)(pose);
1223 pose,
std::string(
"final_looprelax_score"), final_score
1259 return "LoopRelaxMover";
1263 using namespace basic::options;
1264 using namespace basic::options::OptionKeys;
1268 remodel_ = option[ OptionKeys::loops::remodel ]();
1270 refine_ = option[ OptionKeys::loops::refine ]() ;
1271 relax_ = option[ OptionKeys::loops::relax ]();
1284 using namespace utility::tag;
1285 using namespace protocols::moves;
1289 cmd_line_csts( tag->getOption<
bool >(
"cmd_line_csts",
true ) );
1292 compute_rmsd( tag->getOption<
bool >(
"compute_rmsd",
true ) );
1298 if( tag->getOption<
bool >(
"read_fragments",
false ) )
1324 return "LoopRelaxMover";
1336 core::pack::task::TaskFactoryOP
1337 LoopRelaxMover::task_factory() const{ return task_factory_; }
1340 LoopRelaxMover::task_factory( core::pack::task::TaskFactoryOP tf ){ task_factory_ = tf; }