IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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-2022 IMP Inventors. All rights reserved.
6 *
7 */
8
9#ifndef IMPSPB_HELIX_DECORATOR_H
10#define IMPSPB_HELIX_DECORATOR_H
11
12#include <IMP/spb/spb_config.h>
13
14#include <IMP/Decorator.h>
15#include <IMP/Model.h>
16#include <IMP/Particle.h>
18
19IMPSPB_BEGIN_NAMESPACE
20
21//! Add helix parameters to a particle.
22class IMPSPBEXPORT HelixDecorator : public Decorator {
23 static FloatKey get_helix_key(unsigned int i);
24
25 public:
26 IMP_DECORATOR_METHODS(HelixDecorator, Decorator);
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
62IMPSPB_END_NAMESPACE
63
64#endif /* IMPSPB_HELIX_DECORATOR_H */
The base class for decorators.
Storage of a model, its restraints, constraints and particles.
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Particle * get_particle() const
Returns the particle decorated by this decorator.
Definition Decorator.h:194
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Class to handle individual particles of a Model object.
Definition Particle.h:45
Add helix parameters to a particle.
Float get_begin() const
Get the beginning.
void set_end(Float v)
set end
Float get_end() const
Get the end.
void set_begin(Float v)
set begin
Helper macros for implementing Decorators.
#define IMP_DECORATOR_METHODS(Name, Parent)
IMP::Vector< HelixDecorator > HelixDecorators
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
double Float
Basic floating-point value (could be float, double...).
Definition types.h:19
Key< 0 > FloatKey
The type used to identify float attributes in the Particles.
Definition base_types.h:32
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.