IMP logo
IMP Reference Guide  2.15.0
The Integrative Modeling Platform
/TransformMover.h
Go to the documentation of this file.
1 /**
2  * \file IMP/pmi1/TransformMover.h
3  * \brief A mover that transforms a rigid body
4  *
5  * Copyright 2007-2018 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPPMI1_TRANSFORM_MOVER_H
10 #define IMPPMI1_TRANSFORM_MOVER_H
11 
12 #include <IMP/pmi1/pmi1_config.h>
13 #include <IMP/core/MonteCarlo.h>
15 #include <IMP/algebra/Vector3D.h>
17 #include <IMP/SingletonContainer.h>
18 #include <IMP/core/rigid_bodies.h>
19 #include <IMP/core/XYZ.h>
20 IMPPMI1_BEGIN_NAMESPACE
21 
22 //! Modify the transformation of a rigid body
23 /** The transformation of a rigid body is moved in a ball of given
24  size. The probability distribution is uniform over the ball.
25  \see MonteCarlo
26  */
27 class IMPPMI1EXPORT TransformMover : public IMP::core::MonteCarloMover {
28  algebra::Transformation3D last_transformation_;
29  Float max_translation_;
30  Float max_angle_;
31  IMP::ParticleIndex p1i_;
32  IMP::ParticleIndex p2i_;
33  IMP::ParticleIndexes pixyzs_;
34  IMP::ParticleIndexes pirbs_;
42  unsigned int called_;
43  unsigned int not_accepted_;
44  unsigned int constr_;
45 
46 IMP::algebra::Vector3D get_center(){
47  Float x=0;
48  Float y=0;
49  Float z=0;
50  unsigned int nelements=0;
51  for (unsigned int i=0;i<pixyzs_.size();i++) {
52  core::XYZ d(get_model(), pixyzs_[i]);
54  x=x+xyz[0];
55  y=y+xyz[1];
56  z=z+xyz[2];
57  nelements++;
58  }
59 
60  for (unsigned int i=0;i<pirbs_.size();i++){
61  core::RigidBody rb(get_model(), pirbs_[i]);
62  algebra::Vector3D xyz=rb.get_coordinates();
63  unsigned int nparticles=rb.get_number_of_members();
64  x=x+xyz[0]*float(nparticles);
65  y=y+xyz[1]*float(nparticles);
66  z=z+xyz[2]*float(nparticles);
67  nelements=nelements+nparticles;
68  }
69 
70  algebra::Vector3D center;
71  center[0]=x/float(nelements);
72  center[1]=y/float(nelements);
73  center[2]=z/float(nelements);
74  return center;
75 }
76 
77 
78  public:
79  TransformMover(Model *m, Float max_translation, Float max_rotation);
80 
82  Float max_translation, Float max_rotation);
83 
85  Float max_translation, Float max_rotation);
86 
87 void add_xyz_particle(IMP::ParticleIndexAdaptor pi){
88 if ( core::RigidBody::get_is_setup(get_model(), pi) ) {
89  pirbs_.push_back(pi);
90  pis_.push_back(pi); }
91 else {
92  pixyzs_.push_back(pi);
93  pis_.push_back(pi); }
94 }
95 
96 void add_rigid_body_particle(IMP::ParticleIndexAdaptor pi){
97 pirbs_.push_back(pi);
98 pis_.push_back(pi);
99 //initializing the last_transformation array
100 //last_transformation_.push_back( d.get_reference_frame().get_transformation_to());
101 }
102 
103 
104 
105  void set_maximum_translation(Float mt) {
106  IMP_USAGE_CHECK(mt > 0, "Max translation must be positive");
107  max_translation_ = mt;
108  }
109 
110  void set_maximum_rotation(Float mr) {
111  IMP_USAGE_CHECK(mr > 0, "Max rotation must be positive");
112  max_angle_ = mr;
113  }
114 
115  Float get_maximum_translation() const { return max_translation_; }
116 
117  Float get_maximum_rotation() const { return max_angle_; }
118 
119  IMP::algebra::Transformation3D get_last_transformation() const { return tt_; }
120 
121  protected:
124  virtual void do_reject() IMP_OVERRIDE;
126 };
127 
128 IMPPMI1_END_NAMESPACE
129 
130 #endif /* IMPPMI1_TRANSFORM_MOVER_H */
Simple 3D transformation class.
A container for Singletons.
Simple Monte Carlo optimizer.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Take Decorator, Particle or ParticleIndex.
virtual void do_reject()=0
Implement reset_proposed_move()
Return value of the MonteCarloMover::propose() function.
Simple XYZ decorator.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
A base class for classes which perturb particles.
functionality for defining rigid bodies
The base class for movers for Monte Carlo optimization.
Modify the transformation of a rigid body.
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
virtual MonteCarloMoverResult do_propose()=0
Implement propose_move()
const algebra::Vector3D & get_coordinates() const
Convert it to a vector.
Definition: XYZ.h:109
Simple 3D transformation class.
VectorD< 3 > Vector3D
Definition: VectorD.h:421
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
Simple 3D vector class.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Definition: check_macros.h:168
A decorator for a rigid body.
Definition: rigid_bodies.h:82
virtual ModelObjectsTemp do_get_inputs() const =0
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.