Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rigid_body_moves.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 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file
11 /// @brief
12 /// @author Phil Bradley
13 
14 
16 
17 // Rosetta Headers
18 #include <core/pose/Pose.hh>
20 #include <core/kinematics/Jump.hh>
21 
22 
23 //Utility Headers
24 #include <numeric/random/random.hh>
25 
26 
27 #include <basic/Tracer.hh>
28 
29 #include <utility/vector1.hh>
30 
31 
32 using basic::T;
33 using basic::Error;
34 using basic::Warning;
35 namespace protocols {
36 namespace rigid {
37 
38 using namespace core;
39 
40 
41 //static numeric::random::RandomGenerator RG(62458); // <- Magic number, do not change it!!!
42 
43 
44 int
46  pose::Pose & pose,
47  kinematics::MoveMap const & mm,
48  Real const translation_magnitude,
49  Real const rotation_magnitude,
50  int const dir // = 0 --> choose randomly
51 )
52 {
53 
54  utility::vector1< int > moving_jumps;
55  for ( Size i=1, i_end = pose.num_jump(); i<= i_end; ++i ) {
56  if ( mm.get_jump(i) ) moving_jumps.push_back( i );
57  }
58 
59  if ( moving_jumps.empty() ) {
60  T("protocols.rigid.rigid_body") << "[WARNING] no movable jumps!" << std::endl;
61  return 0;
62  }
63 
64  int const jump_number( numeric::random::random_element( moving_jumps ) );
65  gaussian_jump_move( pose, jump_number, translation_magnitude, rotation_magnitude, dir );
66  return jump_number;
67 }
68 
69 void
71  pose::Pose & pose,
72  int const jump_number,
73  Real const translation_magnitude,
74  Real const rotation_magnitude,
75  int dir // = 0 --> choose randomly
76 )
77 {
78  kinematics::Jump jump( pose.jump( jump_number ) );
79  if ( dir == 0 ) {
80  dir = ( numeric::random::uniform() < 0.5 ? -1 : 1 );
81  } else {
82  runtime_assert( dir == 1 || dir == -1 );
83  }
84  jump.gaussian_move( dir, translation_magnitude, rotation_magnitude );
85  pose.set_jump( jump_number, jump );
86 }
87 
88 
89 
90 } // namespace rigid
91 } // namespace core