IMP logo
IMP Reference Guide  2.9.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-2018 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  static void do_setup_particle(Model* m, ParticleIndex p,
25  core::XYZ a, core::XYZ b, core::XYZ c) {
26  m->add_attribute(get_particle_key(0), p, a);
27  m->add_attribute(get_particle_key(1), p, b);
28  m->add_attribute(get_particle_key(2), p, c);
29  }
30 
31  public:
34 
35  //! Return true if the particle is an angle.
36  static bool get_is_setup(Model* m, ParticleIndex pi) {
37  for (unsigned int i = 0; i < 3; ++i) {
38  if (!m->get_has_attribute(get_particle_key(i), pi)) return false;
39  }
40  return true;
41  }
42 
43  Particle* get_particle() const { return Decorator::get_particle(); }
44 
45  //! Get the ith particle in the angle.
46  Particle* get_particle(unsigned int i) const {
47  return get_particle()->get_value(get_particle_key(i));
48  }
49 
50  IMP_DECORATOR_GET_SET_OPT(ideal, get_ideal_key(), Float, Float, -1);
51  IMP_DECORATOR_GET_SET_OPT(stiffness, get_stiffness_key(), Float, Float, 0.);
52 
53  static ParticleIndexKey get_particle_key(unsigned int i);
54  static FloatKey get_ideal_key();
55  static FloatKey get_stiffness_key();
56 };
57 
59 
60 //! A particle that describes a dihedral angle between four particles.
61 /** An Angle decorator is a simple container of four particles, together
62  with an ideal value (in radians) for the angle, a multiplicity
63  and a stiffness.
64 
65  Note that multiple Dihedral particles can exist for the same set of
66  four particles. (For example, the CHARMM forcefield allows for multiple
67  dihedrals to exist with different multiplicities.)
68 
69  \see CHARMMParameters::create_dihedrals(),
70  CHARMMTopology::add_impropers(), DihedralSingletonScore,
71  ImproperSingletonScore.
72  */
73 class IMPATOMEXPORT Dihedral : public Decorator {
74  //! Create a dihedral with the given particles.
75  static void do_setup_particle(Model* m, ParticleIndex p,
77  core::XYZ d) {
78  m->add_attribute(get_particle_key(0), p, a);
79  m->add_attribute(get_particle_key(1), p, b);
80  m->add_attribute(get_particle_key(2), p, c);
81  m->add_attribute(get_particle_key(3), p, d);
82  }
83 
84  public:
87  core::XYZ, d);
88 
89  static bool get_is_setup(Model* m, ParticleIndex pi) {
90  for (unsigned int i = 0; i < 4; ++i) {
91  if (!m->get_has_attribute(get_particle_key(i), pi)) return false;
92  }
93  return true;
94  }
95 
96  Particle* get_particle() const { return Decorator::get_particle(); }
97 
98  //! Get the ith particle in the dihedral.
99  Particle* get_particle(unsigned int i) const {
100  return get_particle()->get_value(get_particle_key(i));
101  }
102 
103  IMP_DECORATOR_GET_SET_OPT(ideal, get_ideal_key(), Float, Float, -1);
104  IMP_DECORATOR_GET_SET_OPT(multiplicity, get_multiplicity_key(), Int, Int, 0);
105  IMP_DECORATOR_GET_SET_OPT(stiffness, get_stiffness_key(), Float, Float, 0.);
106 
107  static ParticleIndexKey get_particle_key(unsigned int i);
108  static FloatKey get_ideal_key();
109  static IntKey get_multiplicity_key();
110  static FloatKey get_stiffness_key();
111 };
112 
114 
115 IMPATOM_END_NAMESPACE
116 
117 #endif /* IMPATOM_ANGLE_DECORATORS_H */
The base class for decorators.
#define IMP_DECORATOR_GET_SET_OPT(name, AttributeKey, Type, ReturnType, default_value)
Define methods for getting and setting an optional simple field.
static bool get_is_setup(Model *m, ParticleIndex pi)
Return true if the particle is an angle.
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
A particle that describes an angle between three particles.
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
add particle atribute with the specied key and initial value
Particle * get_particle(unsigned int i) const
Get the ith particle in the angle.
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
#define IMP_DECORATOR_SETUP_4(Name, FirstArgumentType, first_argument_name,SecondArgumentType, second_argument_name,ThirdArgumentType, third_argument_name,FourthArgumentType, fourth_argument_name)
A particle that describes a dihedral angle between four particles.
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
#define IMP_DECORATOR_METHODS(Name, Parent)
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_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
int Int
Basic integer value.
Definition: types.h:35
bool get_has_attribute(TypeKey attribute_key, ParticleIndex particle) const
return true if particle has attribute with the specified key
#define IMP_DECORATOR_SETUP_3(Name, FirstArgumentType, first_argument_name,SecondArgumentType, second_argument_name,ThirdArgumentType, third_argument_name)
Particle * get_particle(unsigned int i) const
Get the ith particle in the dihedral.