IMP logo
IMP Reference Guide  2.6.1
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-2016 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  public:
50  IMP_DECORATOR_SETUP_1(Representation, double, resolution);
51 
53 
54  static bool get_is_setup(Model *m, ParticleIndex pi) {
55  return m->get_has_attribute(get_base_resolution_key(), pi);
56  }
57 
58  //! Get children at the resolution closest to `resolution` of the passed type.
59  Hierarchy get_representation(double resolution,
60  RepresentationType type = BALLS);
61 
62  //! Return all children at all resolutions.
63  Hierarchies get_representations(RepresentationType type = BALLS);
64 
65  //! Add the representation for the given resolution.
66  /** If the resolution is
67  not given it is computed using get_resolution().
68  Currently only 'BALLS' and 'DENSITIES' are supported; eventually,
69  other types of representation may be supported.
70  */
71  void add_representation(ParticleIndexAdaptor rep,
72  RepresentationType type = BALLS,
73  double resolution = -1);
74 
75  //! Get all resolutions that are available for a specific RepresentationType.
76  Floats get_resolutions(RepresentationType type = BALLS) const;
77 };
78 
79 IMP_DECORATORS(Representation, Representations, Hierarchies);
80 
81 //! Estimate the resolution of the hierarchy as used by Representation.
82 /** It is currently the inverse average radius of the leaves.
83  */
84 IMPATOMEXPORT double get_resolution(Model *m, ParticleIndex pi);
85 
86 /** \copydoc get_resolution(Model, ParticleIndex) */
87 inline double get_resolution(Hierarchy h) {
89 }
90 
91 //! Return the Representation object containing this hierarchy
92 IMPATOMEXPORT Representation get_representation(Hierarchy h, bool nothrow = false);
93 
94 //! Traverse through the tree and show atom info, including representations
95 IMPATOMEXPORT void show_with_representations(Hierarchy h,
96  std::ostream& out = std::cout);
97 
98 IMPATOM_END_NAMESPACE
99 
100 #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:46
#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.