IMP  2.1.1
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  static void do_setup_particle(kernel::Model* m, kernel::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.
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 
44 
45  //! Get the ith particle in the angle.
46  kernel::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 kernel::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(kernel::Model* m, kernel::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 
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 
97 
98  //! Get the ith particle in the dihedral.
99  kernel::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 kernel::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 
113 IMP_DECORATORS(Dihedral, Dihedrals, kernel::ParticlesTemp);
114 
115 IMPATOM_END_NAMESPACE
116 
117 #endif /* IMPATOM_ANGLE_DECORATORS_H */
Import IMP/kernel/Decorator.h in the namespace.
A base class for Keys.
Definition: kernel/Key.h:46
Particle * get_particle() const
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex pi)
Return true if the particle is an angle.
#define IMP_DECORATOR_METHODS(Name, Parent)
#define IMP_DECORATOR_GET_SET_OPT(name, AttributeKey, Type, ReturnType, default_value)
Define methods for getting and setting an optional simple field.
Simple xyz decorator.
#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 an angle between three particles.
static bool get_is_setup(Particle *p)
Return true if the particle can be cast to the decorator.
kernel::Particle * get_particle(unsigned int i) const
Get the ith particle in the dihedral.
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:32
Class to handle individual model particles.
kernel::Particle * get_particle(unsigned int i) const
Get the ith particle in the angle.
A particle that describes a dihedral angle between four particles.
double Float
Basic floating-point value (could be float, double...)
Definition: base/types.h:20
#define IMP_DECORATOR_SETUP_3(Name, FirstArgumentType, first_argument_name,SecondArgumentType, second_argument_name,ThirdArgumentType, third_argument_name)
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
int Int
Basic integer value.
Definition: base/types.h:35
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
Class for storing model, its restraints, constraints, and particles.