IMP logo
IMP Reference Guide  2.12.0
The Integrative Modeling Platform
core/symmetry.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/symmetry.h \brief Implement various types of symmetry
3  *
4  * Copyright 2007-2019 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPCORE_SYMMETRY_H
9 #define IMPCORE_SYMMETRY_H
10 #include <IMP/core/core_config.h>
13 #include "XYZ.h"
14 #include "rigid_bodies.h"
15 #include "MonteCarloMover.h"
16 
17 IMPCORE_BEGIN_NAMESPACE
18 
19 //! A particle that has an associated reference particle.
20 /** This decorator is primarily designed to be used for implementing
21  symmetry.
22  */
23 class IMPCOREEXPORT Reference : public Decorator {
24  static void do_setup_particle(Model *m, ParticleIndex pi,
25  ParticleIndex refi) {
26  m->add_attribute(get_reference_key(), pi, refi);
27  }
28 
29  public:
31  /** Make the first particle reference the passed particle. */
33  Particle *get_reference_particle() const {
34  return get_particle()->get_value(get_reference_key());
35  }
36 
37  static bool get_is_setup(Model *m, ParticleIndex pi) {
38  return m->get_has_attribute(get_reference_key(), pi);
39  }
40 
41  static ParticleIndexKey get_reference_key();
42 };
43 
44 IMP_DECORATORS(Reference, References, ParticlesTemp);
45 
46 //! Set the coordinates of a particle to be a transformed version of a reference
47 /** The passed particles must be Reference particles and XYZ particles and must
48  not be RigidBody particles.
49  \see TransformationSymmetry
50  */
52  : public SingletonModifier {
55 
56  public:
57  //! Create with both reflection and translation
59  const algebra::Reflection3D &r);
60 
61  virtual void apply_index(Model *m, ParticleIndex p) const
64  Model *m, const ParticleIndexes &pis) const IMP_OVERRIDE;
66  Model *m, const ParticleIndexes &pis) const IMP_OVERRIDE;
69 };
70 
71 //! Set the coordinates of a particle to be a transformed version of a reference
72 /** The passed particles must be Reference particles and XYZ particles and
73  can be RigidBody particles iff the reference particle is a rigid body.
74  \see TransformationAndReflectionSymmetry
75  */
76 class IMPCOREEXPORT TransformationSymmetry : public SingletonModifier {
78  ParticleIndex rb_pi_;
79  int const_type_;
80  algebra::Transformation3D get_internal_transformation(Model *m) const;
81  public:
82  //! Create with both rotation and translation
84  //! Create based on a rigid body transformation
85  /** \note If the rigid body reference frame changes, the transformation
86  used by this Modifier will also change.
87  */
89 
90  algebra::Transformation3D get_transformation() const {
91  IMP_USAGE_CHECK(const_type_ == 0,
92  "Cannot get transformation of rigid body");
93  return t_;
94  }
95 
96  //! Set a new transformation to use
97  /** \note the transformation will not be applied until Model.update()
98  is called or the model score is evaluated */
100  IMP_USAGE_CHECK(const_type_ == 0,
101  "Cannot set transformation of rigid body");
102  t_ = t;
103  }
104 
105  virtual void apply_index(Model *m, ParticleIndex p) const
106  IMP_OVERRIDE;
108  Model *m, const ParticleIndexes &pis) const IMP_OVERRIDE;
110  Model *m, const ParticleIndexes &pis) const IMP_OVERRIDE;
113 };
114 
115 //! Modify the given TransformationSymmetry
116 /** The effect of this Mover is similar to applying a RigidBodyMover to
117  every Particle that is affected by the TransformationSymmetry Modifier,
118  that is the transformation of the TransformationSymmetry is modified
119  such that these Particles end up being randomly rotated and translated
120  (relative to their original positions) within a ball of given size.
121  Rotations are made around the given pivot in the reference frame of
122  the reference particles (usually the pivot is one of the particles
123  that is a reference for the TransformationSymmetry). */
124 class IMPCOREEXPORT TransformationSymmetryMover : public MonteCarloMover {
125  algebra::Transformation3D last_transformation_;
127  ParticleIndex pivot_;
128  Float max_translation_;
129  Float max_angle_;
130 
132  get_random_rotation_about_point(const algebra::Vector3D &v);
133 
134 public:
136  ParticleIndex pivot, Float max_translation,
137  Float max_rotation);
138 
139  void set_maximum_translation(Float mt) {
140  IMP_USAGE_CHECK(mt > 0, "Max translation must be positive");
141  max_translation_ = mt;
142  }
143 
144  void set_maximum_rotation(Float mr) {
145  IMP_USAGE_CHECK(mr > 0, "Max rotation must be positive");
146  max_angle_ = mr;
147  }
148 
149  Float get_maximum_translation() const { return max_translation_; }
150 
151  Float get_maximum_rotation() const { return max_angle_; }
152 
153 protected:
156  virtual void do_reject() IMP_OVERRIDE;
158 };
159 
160 IMPCORE_END_NAMESPACE
161 #endif /* IMPCORE_SYMMETRY_H */
A base class for modifiers of ParticlesTemp.
Simple 3D transformation class.
Set the coordinates of a particle to be a transformed version of a reference.
Definition: core/symmetry.h:76
A particle that has an associated reference particle.
Definition: core/symmetry.h:23
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
void set_transformation(algebra::Transformation3D t)
Set a new transformation to use.
Definition: core/symmetry.h:99
virtual void do_reject()=0
Implement reset_proposed_move()
Return value of the MonteCarloMover::propose() function.
virtual ModelObjectsTemp do_get_outputs(Model *m, const ParticleIndexes &pis) const =0
Overload this method to specify the outputs.
A more IMP-like version of the std::vector.
Definition: Vector.h:39
Simple XYZ decorator.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
add particle atribute with the specied key and initial value
#define IMP_SINGLETON_MODIFIER_METHODS(Name)
A base class for classes which perturb particles.
functionality for defining rigid bodies
The base class for movers for Monte Carlo optimization.
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:146
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const =0
Overload this method to specify the inputs.
virtual MonteCarloMoverResult do_propose()=0
Implement propose_move()
Reflect about a plane in 3D.
Definition: Reflection3D.h:18
Simple 3D transformation class.
Particle * get_particle() const
Returns the particle decorated by this decorator.
Definition: Decorator.h:171
Interface to specialized Particle types (e.g. atoms)
Definition: Decorator.h:118
virtual void apply_index(Model *m, ParticleIndex v) const =0
#define IMP_DECORATOR_METHODS(Name, Parent)
VectorD< 3 > Vector3D
Definition: VectorD.h:421
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
Class to handle individual particles of a Model object.
Definition: Particle.h:41
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Definition: check_macros.h:168
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
Reflect about a plane in 3D.
Set the coordinates of a particle to be a transformed version of a reference.
Definition: core/symmetry.h:51
Modify the given TransformationSymmetry.
bool get_has_attribute(TypeKey attribute_key, ParticleIndex particle) const
return true if particle has attribute with the specified key
virtual ModelObjectsTemp do_get_inputs() const =0
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.