IMP logo
IMP Reference Guide  2.14.0
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-2020 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>
15 #include <IMP/decorator_macros.h>
16 
17 IMPNPCTRANSPORT_BEGIN_NAMESPACE
18 
19 //! A decorator for a particle transporting through a barrier.
20 /** \ingroup helper
21  \ingroup decorators
22  */
23 class 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,
40  ParticleIndex pi,
41  bool is_last_entry_from_top = false);
42 
43  public:
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 enetered the transport moiety from its top
74  void set_is_last_entry_from_top(bool is_last_entry_from_top) {
75  get_particle()->set_value(get_is_last_entry_from_top_key(),
76  is_last_entry_from_top ? 1 : 0);
77  }
78 
79  //! returns whether the particle last enetered 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
86  static IntKey get_is_last_entry_from_top_key();
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
101  static FloatKey get_last_tracked_z_key();
102 
103  //! sets the number of times the particle crossed from the bottom
104  //! of the barrier into its interior
105  void set_n_entries_bottom(int n) {
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
111  int get_n_entries_bottom() const {
112  return get_particle()->get_value(get_n_entries_bottom_key());
113  }
114 
115  //! Get the decorator key n_entries_bottom value
116  static IntKey get_n_entries_bottom_key();
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
131  static IntKey get_n_entries_top_key();
132 };
133 
134 
135 
136 IMP_DECORATORS(Transporting, Transportings, IMP::Decorators);
137 
138 IMPNPCTRANSPORT_END_NAMESPACE
139 
140 #endif /* IMPNPCTRANSPORT_TRANSPORTING_H */
The base class for decorators.
bool get_is_last_entry_from_top() const
returns whether the particle last enetered the transport moiety from its
Definition: Transporting.h:81
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
A decorator for a particle transporting through a barrier.
Definition: Transporting.h:23
void set_is_last_entry_from_top(bool is_last_entry_from_top)
sets whether the particle last enetered the transport moiety from its top
Definition: Transporting.h:74
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
static bool get_is_setup(Model *m, ParticleIndex pi)
Return true if the particle is an instance of an Transporting.
Definition: Transporting.h:66
Various general useful macros for IMP.
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)
void set_last_tracked_z(double last_tracked_z)
Definition: Transporting.h:90
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
bool get_has_attribute(TypeKey attribute_key, ParticleIndex particle) const
return true if particle has attribute with the specified key
double get_last_tracked_z() const
Definition: Transporting.h:96