IMP logo
IMP Reference Guide  2.18.0
The Integrative Modeling Platform
Representation.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/Representation.h \brief A decorator for Representations.
3  *
4  * Copyright 2007-2022 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPATOM_REPRESENTATION_H
9 #define IMPATOM_REPRESENTATION_H
10 
11 #include <IMP/atom/atom_config.h>
12 #include "atom_macros.h"
13 #include "Hierarchy.h"
14 
15 #include <IMP/base_types.h>
16 #include <IMP/Particle.h>
17 #include <IMP/Model.h>
18 #include <IMP/Decorator.h>
19 
20 IMPATOM_BEGIN_NAMESPACE
21 
22 IMPATOMEXPORT extern const double ALL_RESOLUTIONS;
23 
24 /** Eventually, other types of representation will be supported */
26  BALLS = 0,
27  DENSITIES = 1
28 };
29 
30 //! A decorator for a representation.
31 /** It stores a number of copies of its sub hierarchy each with an associated
32  * resolution. You can use it to get the representation at a given resolution.
33  * \note The particle returned for a given representation should be thought of
34  * as replacing this particle (not as a child of it).
35  *
36  * \note Only one Representation node is allowed in any path up the tree as
37  * nesting them does not have a clear meaning.
38  */
39 class IMPATOMEXPORT Representation : public Hierarchy {
40  static IntsKey get_types_key();
41  static ParticleIndexesKey get_representations_key();
42  static FloatsKey get_resolutions_key();
43  static FloatKey get_base_resolution_key();
44 
45  static void do_setup_particle(Model *m, ParticleIndex pi,
46  double resolution = -1);
47 
48  static void do_setup_particle(Model *m, ParticleIndex pi,
49  Representation o){
50  do_setup_particle(m,pi,
51  o.get_model()->get_attribute(get_base_resolution_key(),
52  o.get_particle_index()));
53  }
54  public:
56  IMP_DECORATOR_SETUP_1(Representation, double, resolution);
59 
60  static bool get_is_setup(Model *m, ParticleIndex pi) {
61  return m->get_has_attribute(get_base_resolution_key(), pi);
62  }
63 
64  //! Get children at the resolution closest to `resolution` of the passed type.
65  Hierarchy get_representation(double resolution,
66  RepresentationType type = BALLS);
67 
68  //! Return all children at all resolutions.
69  Hierarchies get_representations(RepresentationType type = BALLS);
70 
71  //! Add the representation for the given resolution.
72  /** If the resolution is
73  not given it is computed using get_resolution().
74  Currently only 'BALLS' and 'DENSITIES' are supported; eventually,
75  other types of representation may be supported.
76  */
77  void add_representation(ParticleIndexAdaptor rep,
78  RepresentationType type = BALLS,
79  double resolution = -1);
80 
81  //! Get all resolutions that are available for a specific RepresentationType.
82  Floats get_resolutions(RepresentationType type = BALLS) const;
83 
84  //! Remove the given representation.
85  /** The representation is only removed from the Representation
86  decorator; it is not destroyed. For that, use IMP::atom::destroy().
87  */
88  void remove_representation(ParticleIndexAdaptor rep);
89 
90  //! If you've changed the parent, update all the resolutions
91  void update_parents();
92 };
93 
94 IMP_DECORATORS(Representation, Representations, Hierarchies);
95 
96 //! Estimate the resolution of the hierarchy as used by Representation.
97 /** It is currently the inverse average radius of the leaves.
98  */
99 IMPATOMEXPORT double get_resolution(Model *m, ParticleIndex pi);
100 
101 /** \copydoc get_resolution(Model, ParticleIndex) */
102 inline double get_resolution(Hierarchy h) {
104 }
105 
106 //! Return the Representation object containing this hierarchy
107 IMPATOMEXPORT Representation get_representation(Hierarchy h, bool nothrow = false);
108 
109 //! Traverse through the tree and show atom info, including representations
110 IMPATOMEXPORT void show_with_representations(Hierarchy h,
111  std::ostream& out = std::cout);
112 
113 IMPATOM_END_NAMESPACE
114 
115 #endif /* IMPATOM_REPRESENTATION_H */
The base class for decorators.
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Definition: Decorator.h:190
Basic types used by IMP.
void show_with_representations(Hierarchy h, std::ostream &out=std::cout)
Traverse through the tree and show atom info, including representations.
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
Take Decorator, Particle or ParticleIndex.
Model * get_model() const
Returns the Model containing the particle.
Definition: Decorator.h:193
Storage of a model, its restraints, constraints and particles.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:73
Decorator for helping deal with a hierarchy of molecules.
A decorator for a representation.
The standard decorator for manipulating molecular structures.
double get_resolution(Hierarchy h)
A base class for Keys.
Definition: Key.h:44
#define IMP_DECORATOR_SETUP_0(Name)
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
Macros for maintaining molecular hierarchies.
static bool get_is_setup(Model *m, ParticleIndex p)
Check if the particle has the needed attributes for a cast to succeed.
#define IMP_DECORATOR_METHODS(Name, Parent)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
Representation get_representation(Hierarchy h, bool nothrow=false)
Return the Representation object containing this hierarchy.
bool get_has_attribute(TypeKey attribute_key, ParticleIndex particle) const
return true if particle has attribute with the specified key
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
get the value of the particle attribute with the specified key