IMP logo
IMP Reference Guide  2.6.2
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 transforms a rigid body
4  *
5  * Copyright 2007-2016 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_;
31  IMP::ParticleIndexes pixyzs_;
32  IMP::ParticleIndexes pirbs_;
40  unsigned int constr_;
41 
42 IMP::algebra::Vector3D get_center(){
43  Float x=0;
44  Float y=0;
45  Float z=0;
46  unsigned int nelements=0;
47  for (unsigned int i=0;i<pixyzs_.size();i++) {
48  core::XYZ d(get_model(), pixyzs_[i]);
50  x=x+xyz[0];
51  y=y+xyz[1];
52  z=z+xyz[2];
53  nelements++;
54  }
55 
56  for (unsigned int i=0;i<pirbs_.size();i++){
57  core::RigidBody rb(get_model(), pirbs_[i]);
58  algebra::Vector3D xyz=rb.get_coordinates();
59  unsigned int nparticles=rb.get_number_of_members();
60  x=x+xyz[0]*float(nparticles);
61  y=y+xyz[1]*float(nparticles);
62  z=z+xyz[2]*float(nparticles);
63  nelements=nelements+nparticles;
64  }
65 
66  algebra::Vector3D center;
67  center[0]=x/float(nelements);
68  center[1]=y/float(nelements);
69  center[2]=z/float(nelements);
70  return center;
71 }
72 
73 
74  public:
75  TransformMover(Model *m, Float max_translation, Float max_rotation);
76 
78  Float max_translation, Float max_rotation);
79 
80 
81 void add_xyz_particle(IMP::ParticleIndexAdaptor pi){
82 if ( core::RigidBody::get_is_setup(get_model(), pi) ) {
83  pirbs_.push_back(pi);
84  pis_.push_back(pi); }
85 else {
86  pixyzs_.push_back(pi);
87  pis_.push_back(pi); }
88 }
89 
90 void add_rigid_body_particle(IMP::ParticleIndexAdaptor pi){
91 pirbs_.push_back(pi);
92 pis_.push_back(pi);
93 //initializing the last_transformation array
94 //last_transformation_.push_back( d.get_reference_frame().get_transformation_to());
95 }
96 
97 
98 
99  void set_maximum_translation(Float mt) {
100  IMP_USAGE_CHECK(mt > 0, "Max translation must be positive");
101  max_translation_ = mt;
102  }
103 
104  void set_maximum_rotation(Float mr) {
105  IMP_USAGE_CHECK(mr > 0, "Max rotation must be positive");
106  max_angle_ = mr;
107  }
108 
109  Float get_maximum_translation() const { return max_translation_; }
110 
111  Float get_maximum_rotation() const { return max_angle_; }
112 
113  IMP::algebra::Transformation3D get_last_transformation() const { return tt_; }
114 
115  protected:
118  virtual void do_reject() IMP_OVERRIDE;
120 };
121 
122 IMPPMI_END_NAMESPACE
123 
124 #endif /* IMPPMI_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
virtual void do_reject()=0
Implement reset_proposed_move()
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 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:106
Modify the transformation of a rigid body.
Simple 3D transformation class.
VectorD< 3 > Vector3D
Definition: VectorD.h:395
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:75
virtual ModelObjectsTemp do_get_inputs() const =0
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.