IMP logo
IMP Reference Guide  2.13.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-2020 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 FloatKey get_resolution_key(unsigned int index);
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  //! If you've changed the parent, update all the resolutions
85  void update_parents();
86 };
87 
88 IMP_DECORATORS(Representation, Representations, Hierarchies);
89 
90 //! Estimate the resolution of the hierarchy as used by Representation.
91 /** It is currently the inverse average radius of the leaves.
92  */
93 IMPATOMEXPORT double get_resolution(Model *m, ParticleIndex pi);
94 
95 /** \copydoc get_resolution(Model, ParticleIndex) */
96 inline double get_resolution(Hierarchy h) {
98 }
99 
100 //! Return the Representation object containing this hierarchy
101 IMPATOMEXPORT Representation get_representation(Hierarchy h, bool nothrow = false);
102 
103 //! Traverse through the tree and show atom info, including representations
104 IMPATOMEXPORT void show_with_representations(Hierarchy h,
105  std::ostream& out = std::cout);
106 
107 IMPATOM_END_NAMESPACE
108 
109 #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:188
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)
Model * get_model() const
Returns the Model containing the particle.
Definition: Decorator.h:191
Storage of a model, its restraints, constraints and particles.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
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...
Various important macros for implementing decorators.
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