IMP  2.0.0
The Integrative Modeling Platform
angle_decorators.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/angle_decorators.h \brief Decorators for angles
3  *
4  * Copyright 2007-2013 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPATOM_ANGLE_DECORATORS_H
9 #define IMPATOM_ANGLE_DECORATORS_H
10 
11 #include <IMP/atom/atom_config.h>
12 #include <IMP/core/XYZ.h>
13 #include <IMP/Decorator.h>
14 
15 IMPATOM_BEGIN_NAMESPACE
16 
17 //! A particle that describes an angle between three particles.
18 /** An Angle decorator is a simple container of three particles, together
19  with an ideal value (in radians) for the angle and a stiffness.
20 
21  \see CHARMMParameters::create_angles(), AngleSingletonScore.
22  */
23 class IMPATOMEXPORT Angle : public Decorator
24 {
25 public:
27 
28  //! Create an angle with the given particles.
29  static Angle setup_particle(Particle *p, core::XYZ a, core::XYZ b,
30  core::XYZ c) {
31  p->add_attribute(get_particle_key(0), a);
32  p->add_attribute(get_particle_key(1), b);
33  p->add_attribute(get_particle_key(2), c);
34  return Angle(p);
35  }
36 
37  //! Return true if the particle is an angle.
38  static bool particle_is_instance(Particle *p) {
39  for (unsigned int i = 0; i < 3; ++i) {
40  if (!p->has_attribute(get_particle_key(i))) return false;
41  }
42  return true;
43  }
44 
45  Particle* get_particle() const {
46  return Decorator::get_particle();
47  }
48 
49  //! Get the ith particle in the angle.
50  Particle* get_particle(unsigned int i) const {
51  return get_particle()->get_value(get_particle_key(i));
52  }
53 
54  IMP_DECORATOR_GET_SET_OPT(ideal, get_ideal_key(), Float, Float, -1);
55  IMP_DECORATOR_GET_SET_OPT(stiffness, get_stiffness_key(), Float, Float, 0.);
56 
57  static ParticleIndexKey get_particle_key(unsigned int i);
58  static FloatKey get_ideal_key();
59  static FloatKey get_stiffness_key();
60 };
61 
62 
63 IMP_DECORATORS(Angle,Angles, ParticlesTemp);
64 
65 //! A particle that describes a dihedral angle between four particles.
66 /** An Angle decorator is a simple container of four particles, together
67  with an ideal value (in radians) for the angle, a multiplicity
68  and a stiffness.
69 
70  Note that multiple Dihedral particles can exist for the same set of
71  four particles. (For example, the CHARMM forcefield allows for multiple
72  dihedrals to exist with different multiplicities.)
73 
74  \see CHARMMParameters::create_dihedrals(),
75  CHARMMTopology::add_impropers(), DihedralSingletonScore,
76  ImproperSingletonScore.
77  */
78 class IMPATOMEXPORT Dihedral : public Decorator
79 {
80 public:
82 
83  //! Create a dihedral with the given particles.
84  static Dihedral setup_particle(Particle *p, core::XYZ a, core::XYZ b,
85  core::XYZ c, core::XYZ d) {
86  p->add_attribute(get_particle_key(0), a);
87  p->add_attribute(get_particle_key(1), b);
88  p->add_attribute(get_particle_key(2), c);
89  p->add_attribute(get_particle_key(3), d);
90  return Dihedral(p);
91  }
92 
93  //! Return true if the particle is a dihedral.
94  static bool particle_is_instance(Particle *p) {
95  for (unsigned int i = 0; i < 4; ++i) {
96  if (!p->has_attribute(get_particle_key(i))) return false;
97  }
98  return true;
99  }
100 
101  Particle* get_particle() const {
102  return Decorator::get_particle();
103  }
104 
105  //! Get the ith particle in the dihedral.
106  Particle* get_particle(unsigned int i) const {
107  return get_particle()->get_value(get_particle_key(i));
108  }
109 
110  IMP_DECORATOR_GET_SET_OPT(ideal, get_ideal_key(), Float, Float, -1);
111  IMP_DECORATOR_GET_SET_OPT(multiplicity, get_multiplicity_key(),
112  Int, Int, 0);
113  IMP_DECORATOR_GET_SET_OPT(stiffness, get_stiffness_key(), Float, Float, 0.);
114 
115  static ParticleIndexKey get_particle_key(unsigned int i);
116  static FloatKey get_ideal_key();
117  static IntKey get_multiplicity_key();
118  static FloatKey get_stiffness_key();
119 };
120 
121 IMP_DECORATORS(Dihedral,Dihedrals, ParticlesTemp);
122 
123 IMPATOM_END_NAMESPACE
124 
125 #endif /* IMPATOM_ANGLE_DECORATORS_H */