IMP logo
IMP Reference Guide  2.10.1
The Integrative Modeling Platform
HelixDecorator.h
Go to the documentation of this file.
1 /**
2  * \file IMP/spb/HelixDecorator.h
3  * \brief Add helix parameters to a particle.
4  *
5  * Copyright 2007-2018 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPSPB_HELIX_DECORATOR_H
10 #define IMPSPB_HELIX_DECORATOR_H
11 
12 #include "spb_config.h"
13 
14 #include <IMP/Decorator.h>
15 #include <IMP/Model.h>
16 #include <IMP/Particle.h>
17 #include <IMP/decorator_macros.h>
18 
19 IMPSPB_BEGIN_NAMESPACE
20 
21 //! Add helix parameters to a particle.
22 class IMPSPBEXPORT HelixDecorator : public Decorator {
23  static FloatKey get_helix_key(unsigned int i);
24 
25  public:
27 
28  static HelixDecorator setup_particle(Particle *p, Float b, Float e) {
29  p->add_attribute(get_helix_key(0), b);
30  p->add_attribute(get_helix_key(1), e);
31  HelixDecorator boundaries(p->get_model(), p->get_index());
32  return boundaries;
33  }
34 
35  //! Get the beginning
36  Float get_begin() const {
37  return get_particle()->get_value(get_helix_key(0));
38  }
39 
40  //! Get the end
41  Float get_end() const { return get_particle()->get_value(get_helix_key(1)); }
42 
43  static bool get_is_setup(IMP::Model *m, IMP::ParticleIndex id) {
45  (m->get_particle(id)->has_attribute(get_helix_key(0)) &&
46  m->get_particle(id)->has_attribute(get_helix_key(1))) ||
47  (!m->get_particle(id)->has_attribute(get_helix_key(0)) &&
48  !m->get_particle(id)->has_attribute(get_helix_key(1))),
49  "Particle expected to either begin and end or none.");
50  return m->get_particle(id)->has_attribute(get_helix_key(1));
51  }
52 
53  //! set begin
54  void set_begin(Float v) { get_particle()->set_value(get_helix_key(0), v); }
55 
56  //! set end
57  void set_end(Float v) { get_particle()->set_value(get_helix_key(1), v); }
58 };
59 
61 
62 IMPSPB_END_NAMESPACE
63 
64 #endif /* IMPSPB_HELIX_DECORATOR_H */
Particle * get_particle(ParticleIndex p) const
Get the particle from an index.
Definition: Model.h:291
The base class for decorators.
Float get_end() const
Get the end.
Storage of a model, its restraints, constraints and particles.
Add helix parameters to a particle.
A more IMP-like version of the std::vector.
Definition: Vector.h:39
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
Definition: value_macros.h:23
Various general useful macros for IMP.
void set_end(Float v)
set end
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
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
#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_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Definition: check_macros.h:168
ParticleIndex get_index() const
returns the particle index of this particle in its model
void set_begin(Float v)
set begin
Float get_begin() const
Get the beginning.