IMP  2.3.1
The Integrative Modeling Platform
TransformMover.h
Go to the documentation of this file.
1 /**
2  * \file IMP/pmi/TransformMover.h
3  * \brief A mover that transform a rigid body
4  *
5  * Copyright 2007-2014 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPPMI_TRANSFORM_MOVER_H
10 #define IMPPMI_TRANSFORM_MOVER_H
11 
12 #include <IMP/pmi/pmi_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 IMPPMI_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 IMPPMIEXPORT TransformMover : public IMP::core::MonteCarloMover {
28  algebra::Transformation3D last_transformation_;
29  Float max_translation_;
30  Float max_angle_;
39  unsigned int constr_;
40 
41 IMP::algebra::Vector3D get_center(){
42  Float x=0;
43  Float y=0;
44  Float z=0;
45  unsigned int nelements=0;
46  for (unsigned int i=0;i<pixyzs_.size();i++) {
47  core::XYZ d(get_model(), pixyzs_[i]);
49  x=x+xyz[0];
50  y=y+xyz[1];
51  z=z+xyz[2];
52  nelements++;
53  }
54 
55  for (unsigned int i=0;i<pirbs_.size();i++){
56  core::RigidBody rb(get_model(), pirbs_[i]);
57  algebra::Vector3D xyz=rb.get_coordinates();
58  unsigned int nparticles=rb.get_number_of_members();
59  x=x+xyz[0]*float(nparticles);
60  y=y+xyz[1]*float(nparticles);
61  z=z+xyz[2]*float(nparticles);
62  nelements=nelements+nparticles;
63  }
64 
65  algebra::Vector3D center;
66  center[0]=x/float(nelements);
67  center[1]=y/float(nelements);
68  center[2]=z/float(nelements);
69  return center;
70 }
71 
72 
73  public:
74  TransformMover(kernel::Model *m, Float max_translation, Float max_rotation);
75 
77  Float max_translation, Float max_rotation);
78 
79 
80 void add_xyz_particle(IMP::kernel::ParticleIndexAdaptor pi){
81 pixyzs_.push_back(pi);
82 pis_.push_back(pi);
83 }
84 
85 void add_rigid_body_particle(IMP::kernel::ParticleIndexAdaptor pi){
86 pirbs_.push_back(pi);
87 pis_.push_back(pi);
88 //initializing the last_transformation array
89 //last_transformation_.push_back( d.get_reference_frame().get_transformation_to());
90 }
91 
92 
93 
94  void set_maximum_translation(Float mt) {
95  IMP_USAGE_CHECK(mt > 0, "Max translation must be positive");
96  max_translation_ = mt;
97  }
98 
99  void set_maximum_rotation(Float mr) {
100  IMP_USAGE_CHECK(mr > 0, "Max rotation must be positive");
101  max_angle_ = mr;
102  }
103 
104  Float get_maximum_translation() const { return max_translation_; }
105 
106  Float get_maximum_rotation() const { return max_angle_; }
107 
108  protected:
111  virtual void do_reject() IMP_OVERRIDE;
113 };
114 
115 IMPPMI_END_NAMESPACE
116 
117 #endif /* IMPPMI_TRANSFORM_MOVER_H */
Simple 3D transformation class.
Import IMP/kernel/SingletonContainer.h in the namespace.
Simple Monte Carlo optimizer.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
virtual void do_reject()=0
Implement reset_proposed_move()
Simple XYZ decorator.
A base class for classes which perturb particles.
functionality for defining rigid bodies
The base class for movers for MC optimization.
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:107
Modify the transformation of a rigid body.
Simple 3D transformation class.
VectorD< 3 > Vector3D
Definition: VectorD.h:395
virtual ModelObjectsTemp do_get_inputs() const =0
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:170
A decorator for a rigid body.
Definition: rigid_bodies.h:75
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73