IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
Transporting.h
Go to the documentation of this file.
1/**
2 * \file IMP/npctransport/Transporting.h
3 * \brief A decorator for a transporting particle, so as to keep track of its
4* directionality.
5 *
6 * Copyright 2007-2022 IMP Inventors. All rights reserved.
7 *
8 */
9
10#ifndef IMPNPCTRANSPORT_TRANSPORTING_H
11#define IMPNPCTRANSPORT_TRANSPORTING_H
12
13#include "npctransport_config.h"
14#include <IMP/Decorator.h>
16
17IMPNPCTRANSPORT_BEGIN_NAMESPACE
18
19//! A decorator for a particle transporting through a barrier.
20/** \ingroup helper
21 \ingroup decorators
22 */
23class IMPNPCTRANSPORTEXPORT Transporting : public IMP::Decorator {
24 /** Decorate a transporting particle, mainly for tracking transport
25 statistics (number of transports, etc.). It is assumed the
26 transport occurs along a z coordinate, and that the crossed barrier
27 is bounded from top and bottom.
28 The last tracked z is set to the z coordinate of p, initially,
29 and n entries from bottom and top are set to 0
30 @see get_last_tracked_z
31 @see get_n_entries_bottom
32 @see get_n_entries_top
33
34 @param m the model
35 @param pi the particle index
36 @param is_last_entry_from_top has particle last entered from top of
37 barrier (rather than bottom or unknown)
38 */
39 static void do_setup_particle(IMP::Model* m,
41 bool is_last_entry_from_top = false);
42
43 public:
44 IMP_DECORATOR_METHODS(Transporting, Decorator);
45
46
47 /** Decorate a transporting particle, mainly for tracking transport
48 statistics (number of transports, etc.). It is assumed the
49 transport occurs along a z coordinate, and that the crossed barrier
50 is bounded from top and bottom.
51 The last tracked z is set to the z coordinate of p, initially,
52 and n entries from bottom and top are set to 0
53 @see get_last_tracked_z
54 @see get_n_entries_bottom
55 @see get_n_entries_top
56
57 @param m the model
58 @param pi particle index
59 @param is_last_entry_from_top has particle last entered from top of
60 barrier
61 (rather than bottom or unknown)
62 */
63 IMP_DECORATOR_SETUP_1(Transporting, bool, is_last_entry_from_top = false);
64
65 //! Return true if the particle is an instance of an Transporting
66 static bool get_is_setup(Model *m, ParticleIndex pi) {
67 return m->get_has_attribute(get_is_last_entry_from_top_key(), pi) &&
68 m->get_has_attribute(get_last_tracked_z_key(), pi) &&
69 m->get_has_attribute(get_n_entries_bottom_key(), pi) &&
70 m->get_has_attribute(get_n_entries_top_key(), pi);
71 }
72
73 //! sets whether the particle last entered the transport moiety from its top
74 void set_is_last_entry_from_top(bool is_last_entry_from_top) {
76 is_last_entry_from_top ? 1 : 0);
77 }
78
79 //! returns whether the particle last entered the transport moiety from its
80 //top
82 return (get_particle()->get_value(get_is_last_entry_from_top_key()) != 0);
83 }
84
85 //! Get the decorator key for is_last_entry_from_top
87
88 //! set the Z coordinate of the particle, the last
89 //! time it was tracked for transport statistics
90 void set_last_tracked_z(double last_tracked_z) {
91 get_particle()->set_value(get_last_tracked_z_key(), last_tracked_z);
92 }
93
94 //! returns the Z coordinate of the particle, the last
95 //! time it was tracked for transport statistics
96 double get_last_tracked_z() const {
97 return get_particle()->get_value(get_last_tracked_z_key());
98 }
99
100 //! Get the decorator key last_tracked_z value
102
103 //! sets the number of times the particle crossed from the bottom
104 //! of the barrier into its interior
106 get_particle()->set_value(get_n_entries_bottom_key(), n);
107 }
108
109 //! gets the number of times the particle crossed from the bottom
110 //! of the barrier into its interior
112 return get_particle()->get_value(get_n_entries_bottom_key());
113 }
114
115 //! Get the decorator key n_entries_bottom value
117
118 //! sets the number of times the particle crossed from the top
119 //! of the barrier into its interior
120 void set_n_entries_top(int n) {
121 get_particle()->set_value(get_n_entries_top_key(), n);
122 }
123
124 //! gets the number of times the particle crossed from the top
125 //! of the barrier into its interior
126 int get_n_entries_top() const {
127 return get_particle()->get_value(get_n_entries_top_key());
128 }
129
130 //! Get the decorator key n_entries_top value
132};
133
134
135
136IMP_DECORATORS(Transporting, Transportings, IMP::Decorators);
137
138IMPNPCTRANSPORT_END_NAMESPACE
139
140#endif /* IMPNPCTRANSPORT_TRANSPORTING_H */
The base class for decorators.
Interface to specialized Particle types (e.g. atoms).
Definition Decorator.h:119
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
A decorator for a particle transporting through a barrier.
static FloatKey get_last_tracked_z_key()
Get the decorator key last_tracked_z value.
static bool get_is_setup(Model *m, ParticleIndex pi)
Return true if the particle is an instance of an Transporting.
void set_last_tracked_z(double last_tracked_z)
static IntKey get_n_entries_bottom_key()
Get the decorator key n_entries_bottom value.
static IntKey get_n_entries_top_key()
Get the decorator key n_entries_top value.
static IntKey get_is_last_entry_from_top_key()
Get the decorator key for is_last_entry_from_top.
bool get_is_last_entry_from_top() const
returns whether the particle last entered the transport moiety from its
void set_is_last_entry_from_top(bool is_last_entry_from_top)
sets whether the particle last entered the transport moiety from its top
Helper macros for implementing Decorators.
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
#define IMP_DECORATOR_METHODS(Name, Parent)
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
Key< 0 > FloatKey
The type used to identify float attributes in the Particles.
Definition base_types.h:32
Key< 1 > IntKey
The type used to identify int attributes in the Particles.
Definition base_types.h:36