Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SymDockingInitialPerturbation.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file DockingInitialPerturbation.cc
10 /// @brief initial position functions
11 /// @detailed
12 /// This contains the functions that create initial positions for docking
13 /// @author Ingemar Andre
14 
16 
17 // Rosetta Headers
18 #include <protocols/moves/Mover.hh>
20 #include <core/scoring/Energies.hh>
23 #include <core/kinematics/Jump.hh>
24 
25 #include <basic/options/option.hh>
26 #include <basic/options/keys/symmetry.OptionKeys.gen.hh>
27 
28 // for symmetry
30 // AUTO-REMOVED #include <core/conformation/symmetry/util.hh>
31 
34 
35 // ObjexxFCL Headers
36 #include <ObjexxFCL/string.functions.hh>
37 
38 // C++ Headers
39 #include <string>
40 
41 //Utility Headers
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>
46 
47 #include <basic/Tracer.hh>
48 
49 #include <core/pose/Pose.hh>
50 #include <utility/vector0.hh>
51 #include <utility/vector1.hh>
52 
53 using basic::T;
54 using basic::Error;
55 using basic::Warning;
56 
57 static basic::Tracer TR("protocols.simple_moves_symmetry.SymDockingInitialPerturbation");
58 static core::Size trans ( 1 ), rot ( 2 );
59 
60 using namespace core;
61 using namespace conformation::symmetry;
62 
63 namespace protocols {
64 namespace simple_moves{
65 namespace symmetry {
66 
67 static numeric::random::RandomGenerator RG(4227034);
68 
69 // Symmetric version of initial perturbation on one of the partners
70 // the type of perturbation is defined in the options
71 // some of the options are randomize1 or randomize2 (they are the same),
72 // dock_pert
73 //------------------------------------------------------------------------------
74 //
75 // there are several ways to perturb the structure before beginning
76 // the search; they are controlled through command-line flags
77 //
78 // at the end, partners are slid into contact and scored
79 //
80  // default constructor
81  SymDockingInitialPerturbation::SymDockingInitialPerturbation() : protocols::moves::Mover()
82  {
83  slide_ = false;
84  protocols::moves::Mover::type( "SymmDockingInitialPerturbation" );
85  }
86 
87  // constructor with arguments
89  bool const slide_in
90  ) : protocols::moves::Mover(),
91  slide_(slide_in)
92  {
93  protocols::moves::Mover::type( "SymmDockingInitialPerturbation" );
94  }
95 
97 
98 ////////////////////////////////////////////////////////////////////////////////
99 /// @begin initial_perturbation
100 ///
101 /// @brief Make starting perturbations for rigid body moves
102 ///
103 /////////////////////////////////////////////////////////////////////////////////
105 {
106  using namespace moves;
107  using namespace basic::options;
108  //////////////////////////////////
109  //The options are -symmetry::initialize_rigid_body_dofs
110  // -symmetry::perturb_rigid_body_dofs <trans> <rot>
111  // for dock_pert, also need to get the normal perturbation
112  // In the future this is specified in the symmetry definition file
113  //////////////////////////////////
114  assert( core::pose::symmetry::is_symmetric( pose ));
115  SymmetricConformation & symm_conf (
116  dynamic_cast<SymmetricConformation & > ( pose.conformation()) );
117 
118  std::map< Size, SymDof > dofs ( symm_conf.Symmetry_Info()->get_dofs() );
119  SymSlideInfo const & slide_info( symm_conf.Symmetry_Info()->get_slide_info() );
120  TR << "Reading options..." << std::endl;
121  if( option[ OptionKeys::symmetry::initialize_rigid_body_dofs ]() ) {
122  TR << "initialize_rigid_body_dofs: true" << std::endl;
124  mover.apply( pose );
125  }
126 
127  if( option[ OptionKeys::symmetry::perturb_rigid_body_dofs ].user() ) {
128  TR << "perturb_rigid_body_dofs: true" << std::endl;
129  /// read in dock_pert options from commandline. the first value is the
130  /// rotation magnitude and the second value is the translational value
131  utility::vector1< Real > pert_mags = option[ OptionKeys::symmetry::perturb_rigid_body_dofs ]();
132  TR << "option[ symmetry::perturb_rigid_body_dofs ]() rot=" << pert_mags[rot] << " trans=" << pert_mags[trans] << std::endl;
133  rigid::RigidBodyDofSeqPerturbMover mover( dofs, pert_mags[rot], pert_mags[trans] );
134  mover.apply( pose );
135  }
136  // DO NOT do this for e.g. ligand docking
137  if ( slide_ ) {
138  if ( slide_info.get_slide_type() == SEQUENTIAL ) {
140  slide_info.get_SlideCriteriaType(),
141  slide_info.get_SlideCriteriaVal() );
142  symm_slider.apply( pose );
143  }
144  if ( slide_info.get_slide_type() == ORDERED_SEQUENTIAL ) {
146  slide_info.get_SlideCriteriaType(),
147  slide_info.get_SlideCriteriaVal(),
148  slide_info.get_slide_order() );
149  symm_slider.apply( pose );
150  }
151  if ( slide_info.get_slide_type() == RANDOM ) {
152  RandomSymmetrySlider symm_slider = RandomSymmetrySlider( pose,
153  slide_info.get_SlideCriteriaType(),
154  slide_info.get_SlideCriteriaVal() );
155  symm_slider.apply( pose );
156  }
157 
158 // SymDockingSlideIntoContact slide( dofs );
159 // slide.apply( pose );
160  }
161 }
162 
165  return "SymDockingInitialPerturbation";
166 }
167 
168 
169  // default constructor
171 
172  // constructor with arguments
174  std::map< Size, core::conformation::symmetry::SymDof > dofs
175  ) : protocols::moves::Mover(),
176  dofs_(dofs)
177  {
178 
179  protocols::moves::Mover::type( "SymDockingSlideIntoContact" );
182  }
183 
185 
187 {
188  using namespace moves;
189 
190  assert( core::pose::symmetry::is_symmetric( pose ));
191  SymmetricConformation & symm_conf (
192  dynamic_cast<SymmetricConformation & > ( pose.conformation()) );
193 
194  Size num_slide_moves(1);
195  std::map< Size, SymDof > dofs ( symm_conf.Symmetry_Info()->get_dofs() );
197  ( *scorefxn_ )( pose );
198  TR.Debug << "score " << pose.energies().total_energies()[ scoring::interchain_vdw ] << std::endl;
199  TR.Debug << "sliding into contact" << std::endl;
200  TR.Debug << "Moving away" << std::endl;
201  // first try moving away from each other
202  while ( pose.energies().total_energies()[ scoring::interchain_vdw ] > 0.1 ) {
203  mover.apply( pose );
204  ( *scorefxn_ )( pose );
205  if ( ++num_slide_moves > 1000 ) {
206  std::cerr << "To many slide moves. Subunits never touching..." << std::endl;
207  utility_exit();
208  }
209  TR.Debug << "score away " << pose.energies().total_energies()[ scoring::interchain_vdw ] << std::endl;
210  }
211  // then try moving towards each other
212  TR.Debug << "Moving together" << std::endl;
213  mover.trans_axis().negate();
214  while ( pose.energies().total_energies()[ scoring::interchain_vdw ] < 0.1 ) {
215  mover.apply( pose );
216  ( *scorefxn_ )( pose );
217  if ( ++num_slide_moves > 1000 ) {
218  std::cerr << "To many slide moves. Subunits never touching..." << std::endl;
219  utility_exit();
220  }
221  TR.Debug << "score together " << pose.energies().total_energies()[ scoring::interchain_vdw ] << std::endl;
222  }
223  // move away again until just touching
224  mover.trans_axis().negate();
225  mover.apply( pose );
226 
227 }
228 
231  return "SymDockingSlideIntoContact";
232 }
233 
234 
236  std::map< Size, core::conformation::symmetry::SymDof > dofs
237  ) : protocols::moves::Mover(),
238  dofs_(dofs),
239  tolerance_(0.2)
240  {
241  protocols::moves::Mover::type( "FaSymDockingSlideTogether" );
243  scorefxn_->set_weight( core::scoring::fa_rep, 1.0 );
244  }
245 
247 
249 {
250  using namespace core::scoring;
251 
252  assert( core::pose::symmetry::is_symmetric( pose ));
253  SymmetricConformation & symm_conf (
254  dynamic_cast<SymmetricConformation & > ( pose.conformation()) );
255 
256  Size num_slide_moves(1);
257  std::map< Size, SymDof > dofs ( symm_conf.Symmetry_Info()->get_dofs() );
258 
259  // A very hacky way of guessing whether the components are touching:
260  // if pushed together by 1A, does fa_rep change at all?
261  // (The docking rb_* score terms aren't implemented as of this writing.)
262  (*scorefxn_)( pose );
263  core::Real const initial_fa_rep = pose.energies().total_energies()[ fa_rep ];
264  bool are_touching = false;
265  rigid::RigidBodyDofSeqTransMover trans_mover( dofs );
266 
267  //int i=1;
268  // Take 2A steps till clash, then back apart one step. Now you're within 2A of touching.
269  // Repeat with 1A steps, 0.5A steps, 0.25A steps, etc until you're as close are you want.
270  for( core::Real stepsize = 2.0; stepsize > tolerance_; stepsize /= 2.0 ) {
271  trans_mover.trans_axis( trans_mover.trans_axis().negate() ); // now move together
272  trans_mover.step_size(stepsize);
273  do
274  {
275  trans_mover.apply( pose );
276  (*scorefxn_)( pose );
277  core::Real const push_together_fa_rep = pose.energies().total_energies()[ fa_rep ];
278  //std::cout << "fa_rep = " << push_together_fa_rep << std::endl;
279  are_touching = (std::abs(initial_fa_rep - push_together_fa_rep) > 1e-4);
280  //std::ostringstream s;
281  //s << "snapshot" << i << ".pdb";
282  //pose.dump_pdb(s.str());
283  //i += 1;
284  } while( !are_touching );
285  if ( ++num_slide_moves > 1000 ) {
286  std::cerr << "To many slide moves. Subunits never touching..." << std::endl;
287  utility_exit();
288  }
289 
290  trans_mover.trans_axis( trans_mover.trans_axis().negate() ); // now move apart
291  trans_mover.apply( pose );
292  }
293 }
294 
297  return "FaSymDockingSlideTogether";
298 }
299 
300 
302 
304 {
305  setup( pose );
306 }
307 
309  core::pose::Pose & pose,
311  std::string SlideCriteriaVal
312 )
313 {
314  setup( pose );
315  runtime_assert( score_criteria >= 1 && score_criteria < TOTAL_NUM_CRITERIA );
316  SlideCriteriaType_ = score_criteria;
317  SlideThreshold_ = "AUTOMATIC";
318 
319  if ( SlideCriteriaType_ == CEN_DOCK_SCORE ){
322  } else if ( SlideCriteriaType_ == FA_REP_SCORE ) {
324  scorefxn_->set_weight( core::scoring::fa_rep, 1.0 );
325  (*scorefxn_)( pose );
326  core::Real const initial_fa_rep = pose.energies().total_energies()[ core::scoring::fa_rep ];
327  std::ostringstream stream;
328  stream << initial_fa_rep;
329  SlideThreshold_ = stream.str();
330  }
331 
332  if ( SlideCriteriaVal != "AUTOMATIC" ){
333  SlideThreshold_ = SlideCriteriaVal;
334  }
335 }
336 
338 {
339  using namespace core::scoring;
340  using namespace moves;
341 
342  assert( core::pose::symmetry::is_symmetric( pose ));
343  SymmetricConformation & symm_conf (
344  dynamic_cast<SymmetricConformation & > ( pose.conformation()) );
345 
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;
348 
349  // Save jumps that are allowed to move and have a translation dof
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 );
355  core::conformation::symmetry::SymDof dof ( (*it).second );
356  if ( dof.allow_dof(1) || dof.allow_dof(2) || dof.allow_dof(3) ) {
357  AllowSlideJumpMap_[jump_nbr] = true;
358  }
359  }
360  current_jump_ = 0;
361  reset_slide_ = false;
362  SlideCriteriaType_ = CEN_DOCK_SCORE;
363  SlideThreshold_ = "AUTOMATIC";
364 
367 
368  total_num_slides_ = 0;
369 
370  // initialize the InitialJumps_ map
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 );
378 
379  //fpd also find the correct direction to slide for each jump
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;
382 
383  dof_iterator = dofs.find( ( *i_it).first );
384  rigid::RigidBodyDofTransMover dofmover( (*dof_iterator).second, (*i_it).first, step_size() );
385  InvertJump_[ (*i_it).first ]=!dofmover_compresses( pose, dofmover );
386  }
387  }
388 }
389 
391 {
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;
398  }
399  return finished;
400 }
401 
403 {
404  SlideThreshold_ = SlideCriteria;
405 }
406 
408 {
409  TR.Debug << "Selecting Jump " << jump_nbr << std::endl;
410  current_jump_ = jump_nbr;
411 }
412 
413 // Start by sliding away. This is tricky if we are already in contact.
415 {
416  using namespace moves;
417 
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();
421  // slide away sequentially. Why? Becuase I say so.
422  for ( it = it_begin; it != it_end; ++it ) {
423  if ( ( *it).second ) {
424  TR.Debug << "Sliding away..." << std::endl;
425  // No point is sliding if we are already very_far_away
426  if ( very_far_away( pose ) ) break;
427  assert( core::pose::symmetry::is_symmetric( pose ));
428  SymmetricConformation & symm_conf (
429  dynamic_cast<SymmetricConformation & > ( pose.conformation()) );
430 
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 );
434  rigid::RigidBodyDofTransMover dofmover( (*dof_iterator).second, (*it).first, step_size() );
435  if (!InvertJump_[ (*it).first ]) {
436  dofmover.trans_axis().negate();
437  }
438  core::Real prev_score = slide_score(pose);
439  core::Real new_score = prev_score;
440  TR.Debug << "Sliding along " << (*it).first << " starting score: " << new_score << std::endl;
441  // Slide away up to 200 steps
442  for (int step=1; step< 200; ++step ){
443  // stop if score did not change after 5 steps
444  if ( step%5 == 0 ) {
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;
448  break;
449  }
450  else prev_score = new_score;
451  }
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;
457  break;
458  }
459  }
460  }
461  }
462 }
463 // The threshold metric. We are using docking interchain_vdw for now
465 {
466  if ( SlideCriteriaType_ == CEN_DOCK_SCORE ) {
467  (*scorefxn_)(pose);
469  } else if ( SlideCriteriaType_ == FA_REP_SCORE ) {
470  (*scorefxn_)(pose);
471  return pose.energies().total_energies()[ core::scoring::fa_rep ];
472  }
473 
474  return 0;
475 }
476 
478 {
479  return 1;
480 }
481 
483 {
484  return std::atof( SlideThreshold_.c_str() );
485 }
486 
488 {
489  SlideThreshold_ = threshold;
490 }
491 
492 // If the slide threshold criteria has been met we stop sliding.
493 // Currently only score-based criteria implemented
495 {
496  total_num_slides_++;
497 
498  if ( total_num_slides_ > 200 ) {
499  total_num_slides_ = 0;
500  reset_slide_ = true;
501  TR.Debug << "Stop sliding because we have taken more than 200 steps..." << std::endl;
502  return false;
503  }
504  if ( SlideCriteriaType_ >= CEN_DOCK_SCORE && SlideCriteriaType_ <= FA_REP_SCORE ) {
505  if ( slide_score(pose) <= get_slide_threshold() ) {
506  TR.Debug << "Continue sliding, step " << total_num_slides_ << " score: " << slide_score(pose) << std::endl;
507  return true;
508  }
509  total_num_slides_ = 0;
510  }
511  return false;
512 }
513 
515 {
516  return current_jump_;
517 }
518 
520 {
521  if ( AllowSlideJumpMap_.find( current_jump_ ) == AllowSlideJumpMap_.end() ) {
522  utility_exit_with_message( "[ERROR] slide jump not found..." );
523  }
524  return AllowSlideJumpMap_.find( current_jump_ )->second;
525 }
526 
528 {
529  if ( AllowSlideJumpMap_.find( current_jump_ ) == AllowSlideJumpMap_.end() ) {
530  utility_exit_with_message( "[ERROR] slide jump not found..." );
531  }
532  AllowSlideJumpMap_[current_jump_] = false;
533 }
534 
535 std::map< core::Size, bool >
537 {
538  return AllowSlideJumpMap_;
539 }
540 
541 // There is no point of sliding away if the chains are already really_far_away...
543 {
544  SymmetricConformation & symm_conf (
545  dynamic_cast<SymmetricConformation & > ( pose.conformation()) );
546  SymmetryInfoCOP symm_info( symm_conf.Symmetry_Info() );
547 
549  // find the residues that are connected to the virtual residues defined by the jump. Calculate the
550  // distances of the CA's for these residues and use as a metric of distance
551  core::Real min_distance (1000);
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();
555  clone != clone_end; ++clone ) {
556  conformation::Residue anchor_clone = pose.residue( *clone );
557  core::Real dist = pose.residue( anchor_res.seqpos() ).xyz("CA").distance( pose.residue( anchor_clone.seqpos() ).xyz("CA") );
558  TR.Debug << "Distance residue " << anchor_res.seqpos() << " to " << anchor_clone.seqpos() << " is " << dist << std::endl;
559  if ( dist < min_distance ) min_distance = dist;
560  }
561  // 50 Angstroms is pretty far innit?
562  TR.Debug << "Chains are " << min_distance << " away from each other" << std::endl;
563  return ( min_distance > 50 ? true : false );
564 
565 }
566 
567 // Slide chains into contact. Calls pure virtual select_jump() so this class can not be used on its own
569 {
570  using namespace moves;
571 
572  assert( core::pose::symmetry::is_symmetric( pose ));
573  SymmetricConformation & symm_conf (
574  dynamic_cast<SymmetricConformation & > ( pose.conformation()) );
575 
576  std::map< Size, core::conformation::symmetry::SymDof > dofs = symm_conf.Symmetry_Info()->get_dofs();
577 
578  // make sure we have a current_jump_
579  select_jump();
580  // start by sliding away
581  slide_away( pose );
582  // Go through all allowed translation jumps in the order defined by
583  // the selection of current_jump_
585  std::map< Size, core::conformation::symmetry::SymDof >::iterator dof_iterator;
586  while ( SymmetrySlider::continue_slide ( pose ) ) {
587  // Select a new slide
588  // We slide until the slide criteria is satisfied
589  select_jump();
590  dof_iterator = dofs.find(SymmetrySlider::get_current_jump() );
591  core::conformation::symmetry::SymDof dof ( (*dof_iterator).second );
592  assert( dof_iterator != dofs.end() );
593 
594  // slide along the current jump
596  //fpd pick slide direction
597  if ( InvertJump_[ (*dof_iterator).first ]) {
598  dofmover.trans_axis().negate();
599  }
600  dofmover.apply( pose );
601  }
602 
603  dof_iterator = dofs.find(SymmetrySlider::get_current_jump() );
604  core::conformation::symmetry::SymDof dof ( (*dof_iterator).second );
606  if (!reset_slide_) {
607  for ( core::Real step=step_size()/8; step<=step_size(); step *=2 ) {
608  dofmover.step_size(step);
609  dofmover.apply( pose );
610  TR.Debug << "Refine slide position, step " << step << std::endl;
611  if (SymmetrySlider::continue_slide ( pose ) ) break;
612  dofmover.trans_axis().negate();
613  dofmover.apply( pose );
614  dofmover.trans_axis().negate();
615  }
616  }
617 
618  // if we did not find a contact during the slide then reset the rb position.
619  if ( reset_slide_ ) {
620  // we should really keep track of how many slides we do in each direction. 200 step reset is only correct if slide
621  // in only one directions fails...
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 );
630  }
631  reset_slide_ = false;
632  }
633 
634  // Update the threshold due gained contact. Due to round-off errors we add a fudge factor of 0.1
635  core::Real score( slide_score(pose) + 0.01 );
636  // The threshold value is a string. We need to convert the real to a string. Akward...
637  std::ostringstream stream;
638  stream << score;
639  std::string new_threshold ( stream.str() );
640  set_slide_threshold( new_threshold );
641  // Now we are done with sliding in this direction.
642  TR.Debug << "Stop sliding along Jump " << get_current_jump() << std::endl;
644  // Select a new slide
645  select_jump();
646 
647  }
648 }
649 
651 {
652  slide(pose);
653 }
654 
655 //fpd return the rg
657 {
659  numeric::xyzVector <core::Real> sum_ca(0,0,0);
660  core::Real rg = 0.0;
661 
662  for (int i=1; i<=(int)pose.total_residue(); ++i) {
663  core::conformation::Residue const& rsd_i = pose.residue(i);
664  if (!rsd_i.is_protein()) continue;
665  cas.push_back( rsd_i.atom( pose.residue_type( i ).atom_index(" CA ") ).xyz() );
666  sum_ca += cas[cas.size()];
667  }
668  sum_ca /= cas.size();
669  for (int i=1; i<=(int)cas.size(); ++i) {
670  rg += (sum_ca-cas[i]).length_squared();
671  }
672  return std::sqrt( rg/cas.size() );
673 }
674 
676 {
677  core::Real radius_before = rg(pose);
678  dofmover.apply(pose);
679  core::Real radius_after = rg(pose);
680 
681  // undo changes to the pose (cheaper than working in a pose copy)
682  dofmover.trans_axis().negate();
683  dofmover.apply( pose );
684  dofmover.trans_axis().negate();
685 
686  if (radius_before > radius_after)
687  return true;
688  return false;
689 }
690 
691 
693  SymmetrySlider( pose )
694 {
695  init();
696 }
697 
699  SymmetrySlider( Slide )
700 {
701  init();
702 }
703 
705  core::pose::Pose & pose,
707  std::string SlideCriteriaVal
708 ) : SymmetrySlider( pose, score_criteria, SlideCriteriaVal )
709 {
710  init();
711 }
712 
714 {
715  std::map< core::Size, bool > const & allow_slide_jump_map( get_allow_slide_jump_map() );
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 ) {
721  slide_order_.push_back( (*it).first );
722  }
723  }
724  numeric::random::random_permutation( slide_order_, RG );
725 }
726 
728 {
729  std::map< core::Size, bool > const & allow_slide_jump_map( get_allow_slide_jump_map() );
730  std::map< core::Size, bool >::const_iterator allow_it;
731 
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 ) {
740  set_current_jump( *it );
741  break;
742  }
743  }
744  }
745 
746 /* std::map< core::Size, bool > const & allow_slide_jump_map( get_allow_slide_jump_map() );
747  std::map< core::Size, bool >::const_iterator it;
748  std::map< core::Size, bool >::const_iterator it_begin = allow_slide_jump_map.begin();
749  std::map< core::Size, bool >::const_iterator it_end = allow_slide_jump_map.end();
750  for ( it = it_begin; it != it_end; ++it ) {
751  if ( ( *it).second ) {
752  set_current_jump( ( *it).first );
753  break;
754  }
755  }*/
756 }
757 
759  SymmetrySlider( pose ),
760  slide_order_( slide_order)
761 {}
762 
763 OrderedSequentialSymmetrySlider::OrderedSequentialSymmetrySlider( SymmetrySlider const & Slide, std::vector<core::Size> slide_order ) :
764  SymmetrySlider( Slide ),
765  slide_order_( slide_order)
766 {}
767 
769  core::pose::Pose & pose,
771  std::string SlideCriteriaVal,
772  std::vector<core::Size> slide_order
773 ) : SymmetrySlider( pose, score_criteria, SlideCriteriaVal ),
774  slide_order_( slide_order)
775 {}
776 
778 {
779  std::map< core::Size, bool > const & allow_slide_jump_map( get_allow_slide_jump_map() );
780  std::map< core::Size, bool >::const_iterator allow_it;
781 
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 ) {
789  set_current_jump( *it );
790  break;
791  }
792  }
793  }
794 }
795 
796 
798  SymmetrySlider( pose )
799 {}
800 
802  SymmetrySlider( Slide )
803 {}
804 
806  core::pose::Pose & pose,
808  std::string SlideCriteriaVal
809 ) : SymmetrySlider( pose, score_criteria, SlideCriteriaVal )
810 {}
811 
813 {
814  std::map< core::Size, bool > const & allow_slide_jump_map( get_allow_slide_jump_map() );
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 );
822  }
823  }
824  if ( !allowed.empty() )
825  set_current_jump( numeric::random::random_element( allowed ) );
826 }
827 
828 }
829 } // namespace docking
830 } // namespace protocols