25 #include <basic/options/option.hh>
26 #include <basic/options/keys/symmetry.OptionKeys.gen.hh>
36 #include <ObjexxFCL/string.functions.hh>
42 #include <numeric/trig.functions.hh>
43 #include <numeric/xyzMatrix.fwd.hh>
44 #include <numeric/random/random.hh>
45 #include <numeric/random/random_permutation.hh>
47 #include <basic/Tracer.hh>
50 #include <utility/vector0.hh>
51 #include <utility/vector1.hh>
57 static basic::Tracer
TR(
"protocols.simple_moves_symmetry.SymDockingInitialPerturbation");
61 using namespace conformation::symmetry;
64 namespace simple_moves{
67 static numeric::random::RandomGenerator
RG(4227034);
81 SymDockingInitialPerturbation::SymDockingInitialPerturbation() : protocols::moves::
Mover()
90 ) : protocols::moves::
Mover(),
106 using namespace moves;
107 using namespace basic::options;
116 dynamic_cast<SymmetricConformation & > ( pose.
conformation()) );
118 std::map< Size, SymDof > dofs ( symm_conf.
Symmetry_Info()->get_dofs() );
120 TR <<
"Reading options..." << std::endl;
121 if( option[ OptionKeys::symmetry::initialize_rigid_body_dofs ]() ) {
122 TR <<
"initialize_rigid_body_dofs: true" << std::endl;
127 if( option[ OptionKeys::symmetry::perturb_rigid_body_dofs ].user() ) {
128 TR <<
"perturb_rigid_body_dofs: true" << std::endl;
132 TR <<
"option[ symmetry::perturb_rigid_body_dofs ]() rot=" << pert_mags[
rot] <<
" trans=" << pert_mags[
trans] << std::endl;
138 if ( slide_info.get_slide_type() ==
SEQUENTIAL ) {
140 slide_info.get_SlideCriteriaType(),
141 slide_info.get_SlideCriteriaVal() );
142 symm_slider.
apply( pose );
146 slide_info.get_SlideCriteriaType(),
147 slide_info.get_SlideCriteriaVal(),
148 slide_info.get_slide_order() );
149 symm_slider.
apply( pose );
151 if ( slide_info.get_slide_type() ==
RANDOM ) {
153 slide_info.get_SlideCriteriaType(),
154 slide_info.get_SlideCriteriaVal() );
155 symm_slider.
apply( pose );
165 return "SymDockingInitialPerturbation";
174 std::map< Size, core::conformation::symmetry::SymDof > dofs
175 ) : protocols::moves::
Mover(),
188 using namespace moves;
192 dynamic_cast<SymmetricConformation & > ( pose.
conformation()) );
194 Size num_slide_moves(1);
195 std::map< Size, SymDof > dofs ( symm_conf.
Symmetry_Info()->get_dofs() );
197 ( *scorefxn_ )( pose );
199 TR.Debug <<
"sliding into contact" << std::endl;
200 TR.Debug <<
"Moving away" << std::endl;
204 ( *scorefxn_ )( pose );
205 if ( ++num_slide_moves > 1000 ) {
206 std::cerr <<
"To many slide moves. Subunits never touching..." << std::endl;
212 TR.Debug <<
"Moving together" << std::endl;
213 mover.trans_axis().negate();
216 ( *scorefxn_ )( pose );
217 if ( ++num_slide_moves > 1000 ) {
218 std::cerr <<
"To many slide moves. Subunits never touching..." << std::endl;
224 mover.trans_axis().negate();
231 return "SymDockingSlideIntoContact";
236 std::map< Size, core::conformation::symmetry::SymDof > dofs
237 ) : protocols::moves::
Mover(),
250 using namespace core::scoring;
254 dynamic_cast<SymmetricConformation & > ( pose.
conformation()) );
256 Size num_slide_moves(1);
257 std::map< Size, SymDof > dofs ( symm_conf.
Symmetry_Info()->get_dofs() );
262 (*scorefxn_)( pose );
264 bool are_touching =
false;
275 trans_mover.
apply( pose );
276 (*scorefxn_)( pose );
279 are_touching = (std::abs(initial_fa_rep - push_together_fa_rep) > 1e-4);
284 }
while( !are_touching );
285 if ( ++num_slide_moves > 1000 ) {
286 std::cerr <<
"To many slide moves. Subunits never touching..." << std::endl;
291 trans_mover.
apply( pose );
297 return "FaSymDockingSlideTogether";
316 SlideCriteriaType_ = score_criteria;
317 SlideThreshold_ =
"AUTOMATIC";
325 (*scorefxn_)( pose );
327 std::ostringstream stream;
328 stream << initial_fa_rep;
329 SlideThreshold_ = stream.str();
332 if ( SlideCriteriaVal !=
"AUTOMATIC" ){
333 SlideThreshold_ = SlideCriteriaVal;
339 using namespace core::scoring;
340 using namespace moves;
344 dynamic_cast<SymmetricConformation & > ( pose.
conformation()) );
346 std::map< Size, core::conformation::symmetry::SymDof > dofs = symm_conf.
Symmetry_Info()->get_dofs();
347 std::map< Size, core::conformation::symmetry::SymDof >::iterator jump_iterator;
350 std::map< Size, core::conformation::symmetry::SymDof >::iterator it;
351 std::map< Size, core::conformation::symmetry::SymDof >::iterator it_begin = dofs.begin();
352 std::map< Size, core::conformation::symmetry::SymDof >::iterator it_end = dofs.end();
353 for ( it = it_begin; it != it_end; ++it ) {
354 int jump_nbr ( (*it).first );
357 AllowSlideJumpMap_[jump_nbr] =
true;
361 reset_slide_ =
false;
363 SlideThreshold_ =
"AUTOMATIC";
368 total_num_slides_ = 0;
371 std::map< core::Size, bool >::const_iterator i_it;
372 std::map< core::Size, bool >::const_iterator i_it_begin = AllowSlideJumpMap_.begin();
373 std::map< core::Size, bool >::const_iterator i_it_end = AllowSlideJumpMap_.end();
374 for ( i_it = i_it_begin; i_it != i_it_end; ++i_it ) {
375 if ( (*i_it).second ) {
376 TR.Debug <<
"Initial Jump (nbr): " << (*i_it).first << std::endl << pose.
jump ( (*i_it).first ) << std::endl;
377 InitialJumps_[ (*i_it).first ]=pose.
jump( (*i_it).first );
380 std::map< Size, core::conformation::symmetry::SymDof > dofs = symm_conf.
Symmetry_Info()->get_dofs();
381 std::map< Size, core::conformation::symmetry::SymDof >::iterator dof_iterator;
383 dof_iterator = dofs.find( ( *i_it).first );
385 InvertJump_[ (*i_it).first ]=!dofmover_compresses( pose, dofmover );
392 bool finished =
true;
393 std::map< core::Size, bool >::const_iterator it;
394 std::map< core::Size, bool >::const_iterator it_begin = AllowSlideJumpMap_.begin();
395 std::map< core::Size, bool >::const_iterator it_end = AllowSlideJumpMap_.end();
396 for ( it = it_begin; it != it_end; ++it ) {
397 if ( ( *it).second ) finished =
false;
404 SlideThreshold_ = SlideCriteria;
409 TR.Debug <<
"Selecting Jump " << jump_nbr << std::endl;
410 current_jump_ = jump_nbr;
416 using namespace moves;
418 std::map< core::Size, bool >::const_iterator it;
419 std::map< core::Size, bool >::const_iterator it_begin = AllowSlideJumpMap_.begin();
420 std::map< core::Size, bool >::const_iterator it_end = AllowSlideJumpMap_.end();
422 for ( it = it_begin; it != it_end; ++it ) {
423 if ( ( *it).second ) {
424 TR.Debug <<
"Sliding away..." << std::endl;
426 if ( very_far_away( pose ) )
break;
429 dynamic_cast<SymmetricConformation & > ( pose.
conformation()) );
431 std::map< Size, core::conformation::symmetry::SymDof > dofs = symm_conf.
Symmetry_Info()->get_dofs();
432 std::map< Size, core::conformation::symmetry::SymDof >::iterator dof_iterator;
433 dof_iterator = dofs.find( ( *it).first );
435 if (!InvertJump_[ (*it).first ]) {
440 TR.Debug <<
"Sliding along " << (*it).first <<
" starting score: " << new_score << std::endl;
442 for (
int step=1; step< 200; ++step ){
445 TR.Debug <<
"Slide away score: " << new_score << std::endl;
446 if ( std::fabs( new_score - prev_score ) < 1e-1 ) {
447 TR.Debug <<
"Done sliding, score is unchanged " << new_score <<
" " << prev_score << std::endl;
450 else prev_score = new_score;
452 dofmover.
apply( pose );
453 new_score = slide_score(pose);
454 TR.Debug <<
"slide away score: " << new_score <<
" threshold: " << get_slide_threshold() << std::endl;
455 if ( new_score <= get_slide_threshold() ) {
456 TR.Debug <<
"Done sliding " << new_score << std::endl;
484 return std::atof( SlideThreshold_.c_str() );
489 SlideThreshold_ = threshold;
498 if ( total_num_slides_ > 200 ) {
499 total_num_slides_ = 0;
501 TR.Debug <<
"Stop sliding because we have taken more than 200 steps..." << std::endl;
505 if ( slide_score(pose) <= get_slide_threshold() ) {
506 TR.Debug <<
"Continue sliding, step " << total_num_slides_ <<
" score: " << slide_score(pose) << std::endl;
509 total_num_slides_ = 0;
516 return current_jump_;
521 if ( AllowSlideJumpMap_.find( current_jump_ ) == AllowSlideJumpMap_.end() ) {
522 utility_exit_with_message(
"[ERROR] slide jump not found..." );
524 return AllowSlideJumpMap_.find( current_jump_ )->second;
529 if ( AllowSlideJumpMap_.find( current_jump_ ) == AllowSlideJumpMap_.end() ) {
530 utility_exit_with_message(
"[ERROR] slide jump not found..." );
532 AllowSlideJumpMap_[current_jump_] =
false;
535 std::map< core::Size, bool >
538 return AllowSlideJumpMap_;
545 dynamic_cast<SymmetricConformation & > ( pose.
conformation()) );
552 for ( std::vector< Size>::const_iterator
553 clone = symm_info->bb_clones( anchor_res.seqpos() ).begin(),
554 clone_end = symm_info->bb_clones( anchor_res.seqpos() ).
end();
558 TR.Debug <<
"Distance residue " << anchor_res.seqpos() <<
" to " << anchor_clone.
seqpos() <<
" is " << dist << std::endl;
559 if ( dist < min_distance ) min_distance = dist;
562 TR.Debug <<
"Chains are " << min_distance <<
" away from each other" << std::endl;
563 return ( min_distance > 50 ?
true :
false );
570 using namespace moves;
574 dynamic_cast<SymmetricConformation & > ( pose.
conformation()) );
576 std::map< Size, core::conformation::symmetry::SymDof > dofs = symm_conf.
Symmetry_Info()->get_dofs();
585 std::map< Size, core::conformation::symmetry::SymDof >::iterator dof_iterator;
592 assert( dof_iterator != dofs.end() );
597 if ( InvertJump_[ (*dof_iterator).first ]) {
598 dofmover.trans_axis().negate();
600 dofmover.apply( pose );
607 for (
core::Real step=step_size()/8; step<=step_size(); step *=2 ) {
609 dofmover.
apply( pose );
610 TR.Debug <<
"Refine slide position, step " << step << std::endl;
613 dofmover.
apply( pose );
619 if ( reset_slide_ ) {
622 TR.Debug <<
"Reset slide. No contact was found after 200 steps..." << std::endl;
623 std::map< core::Size, core::kinematics::Jump >
const & initial_jumps( InitialJumps_ );
624 std::map< core::Size, core::kinematics::Jump >::const_iterator it;
625 std::map< core::Size, core::kinematics::Jump >::const_iterator it_begin = initial_jumps.begin();
626 std::map< core::Size, core::kinematics::Jump >::const_iterator it_end = initial_jumps.end();
627 for ( it = it_begin; it != it_end; ++it ) {
628 TR.Debug <<
"Reset Jump (nbr): " << (*it).first << std::endl << (*it).second << std::endl;
629 pose.
set_jump( (*it).first, (*it).second );
631 reset_slide_ =
false;
637 std::ostringstream stream;
640 set_slide_threshold( new_threshold );
642 TR.Debug <<
"Stop sliding along Jump " << get_current_jump() << std::endl;
666 sum_ca += cas[cas.size()];
668 sum_ca /= cas.size();
669 for (
int i=1; i<=(
int)cas.size(); ++i) {
670 rg += (sum_ca-cas[i]).length_squared();
672 return std::sqrt( rg/cas.size() );
678 dofmover.
apply(pose);
683 dofmover.
apply( pose );
686 if (radius_before > radius_after)
716 std::map< core::Size, bool >::const_iterator it;
717 std::map< core::Size, bool >::const_iterator it_begin = allow_slide_jump_map.begin();
718 std::map< core::Size, bool >::const_iterator it_end = allow_slide_jump_map.end();
719 for ( it = it_begin; it != it_end; ++it ) {
720 if ( ( *it).second ) {
730 std::map< core::Size, bool >::const_iterator allow_it;
732 std::vector< core::Size >::const_iterator it;
733 std::vector< core::Size >::const_iterator it_begin =
slide_order_.begin();
734 std::vector< core::Size >::const_iterator it_end =
slide_order_.end();
735 for ( it = it_begin; it != it_end; ++it ) {
736 TR.Debug <<
"JUMP select " << (*it) << std::endl;
737 allow_it = allow_slide_jump_map.find( *it );
738 if ( allow_it != allow_slide_jump_map.end() ) {
739 if ( (*allow_it).second ) {
760 slide_order_( slide_order)
765 slide_order_( slide_order)
772 std::vector<core::Size> slide_order
774 slide_order_( slide_order)
780 std::map< core::Size, bool >::const_iterator allow_it;
782 std::vector< core::Size >::const_iterator it;
783 std::vector< core::Size >::const_iterator it_begin =
slide_order_.begin();
784 std::vector< core::Size >::const_iterator it_end =
slide_order_.end();
785 for ( it = it_begin; it != it_end; ++it ) {
786 allow_it = allow_slide_jump_map.find( *it );
787 if ( allow_it != allow_slide_jump_map.end() ) {
788 if ( (*allow_it).second ) {
815 std::map< core::Size, bool >::const_iterator it;
816 std::map< core::Size, bool >::const_iterator it_begin = allow_slide_jump_map.begin();
817 std::map< core::Size, bool >::const_iterator it_end = allow_slide_jump_map.end();
819 for ( it = it_begin; it != it_end; ++it ) {
820 if ( ( *it).second ) {
821 allowed.push_back( ( *it).first );
824 if ( !allowed.empty() )