IMP  2.1.0
The Integrative Modeling Platform
hierarchy_tools.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/hierarchy_tools.h
3  * \brief A set of useful functionality on IMP::atom::Hierarchy decorators
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPATOM_HIERARCHY_TOOLS_H
9 #define IMPATOM_HIERARCHY_TOOLS_H
10 
11 #include <IMP/atom/atom_config.h>
12 #include <IMP/algebra/algebra_config.h>
13 #include "Hierarchy.h"
14 #include "Residue.h"
15 #include "Atom.h"
16 #include <IMP/core/Typed.h>
17 #include <IMP/core/XYZR.h>
18 #include "Selection.h"
19 #include <boost/graph/adjacency_list.hpp>
20 
21 IMPATOM_BEGIN_NAMESPACE
22 
23 //! Create a coarse grained molecule
24 /** The coarse grained model is created with a number of spheres
25  based on the resolution and the volume. If the volume is not provided
26  it is estimated based on the number of residues. The protein is
27  created as a molecular hierarchy rooted at p. The leaves are Domain
28  particles with appropriate residue indexes stored and are XYZR
29  particles.
30 
31  Volume is, as usual, in cubic anstroms.
32 
33  Currently the function creates a set of balls with radii no greater
34  than resolution which overlap by 20% and have a volume of their
35  union equal to the passed volume.
36 
37  The coordinates of the balls defining the protein are optimized
38  by default, and have garbage coordinate values.
39  \untested{create_protein}
40  \unstable{create_protein}
41  See Hierarchy
42  */
43 IMPATOMEXPORT Hierarchy
44  create_protein(kernel::Model *m, std::string name, double resolution,
45  int number_of_residues, int first_residue_index = 0,
46  double volume = -1
47 #ifndef IMP_DOXYGEN
48  ,
49  bool ismol = true
50 #endif
51  );
52 /** Like the former create_protein(), but it enforces domain splits
53  at the provide domain boundairs. The domain boundaries should be
54  the start of the first domain, any boundies, and then one past
55  the end of the last domain.
56  */
57 IMPATOMEXPORT Hierarchy create_protein(kernel::Model *m, std::string name,
58  double resolution,
59  const Ints domain_boundaries);
60 
61 /** \name Simplification along backbone
62 
63  These two methods create a simplified version of a molecule by
64  merging residues sequentially. In one case every n residues are
65  merged, in the other, the intervals are passed manually. The
66  resulting molecule is not optimized by default and has no
67  restraints automatically created.
68 
69  At the moment, the calls only support unmodified hierarchies loaded
70  by read_pdb() which have only protein or DNA members.
71 
72  They return Hierarchy() if the input chain is empty.
73 
74  If keep_detailed is true, then the original high resolution structure
75  particles are added as children of the simplified structure.
76  @{
77 */
78 /** Simplify every num_res into one particle.*/
79 IMPATOMEXPORT Hierarchy
80  create_simplified_along_backbone(Hierarchy input, int num_res,
81  bool keep_detailed = false);
82 /** Simplify by breaking at the boundaries provided.*/
83 IMPATOMEXPORT Hierarchy
85  const IntRanges &residue_segments,
86  bool keep_detailed = false);
87 /** @} */
88 
89 /** \name Finding information
90  Get the attribute of the given particle or throw a ValueException
91  if it is not applicable. The particle with the given information
92  must be above the passed node.
93  @{
94 */
95 IMPATOMEXPORT std::string get_molecule_name(Hierarchy h);
96 IMPATOMEXPORT Ints get_residue_indexes(Hierarchy h);
97 IMPATOMEXPORT ResidueType get_residue_type(Hierarchy h);
98 IMPATOMEXPORT int get_chain_id(Hierarchy h);
99 IMPATOMEXPORT AtomType get_atom_type(Hierarchy h);
100 IMPATOMEXPORT std::string get_domain_name(Hierarchy h);
101 IMPATOMEXPORT int get_copy_index(Hierarchy h);
102 /** @} */
103 
104 /** Create an excluded volume restraint for the included molecules. If a
105  value is provided for resolution, then something less than the full
106  resolution representation will be used.
107 
108  If one or more of the selections is a rigid body, this will be used
109  to accelerate the computation.
110  See Hierarchy
111  */
113  const Hierarchies &hs, double resolution = -1);
114 
115 /** Set the mass, radius, residues, and coordinates to approximate the passed
116  particles.
117  */
118 IMPATOMEXPORT void setup_as_approximation(kernel::Particle *h,
119  const kernel::ParticlesTemp &other
120 #ifndef IMP_DOXYGEN
121  ,
122  double resolution = -1
123 #endif
124  );
125 
126 /** Set the mass, radius, residues, and coordinates to approximate the passed
127  particle based on the leaves of h.
128  See Hierarchy
129  */
130 IMPATOMEXPORT void setup_as_approximation(Hierarchy h
131 #ifndef IMP_DOXYGEN
132  ,
133  double resolution = -1
134 #endif
135  );
136 
137 /** Transform a hierarchy. This is aware of rigid bodies.
138  */
139 IMPATOMEXPORT void transform(Hierarchy h, const algebra::Transformation3D &tr);
140 
141 /** A graph for representing a Hierarchy so you can view it
142  nicely.
143 */
144 IMP_GRAPH(HierarchyTree, bidirectional, Hierarchy, int,
145  vertex.show(out, "\\n"));
146 /** Get a graph for the passed Hierarchy. This can be used,
147  for example, to graphically display the hierarchy in 2D.
148  See Hierarchy
149 */
151 
152 /** \class HierarchyGeometry
153  \brief Display an IMP::atom::Hierarchy particle as balls.
154 
155  \class HierarchiesGeometry
156  \brief Display an IMP::SingletonContainer of IMP::atom::Hierarchy particles
157  as balls.
158 */
160  double res_;
162  components_;
163 
164  public:
165  HierarchyGeometry(core::Hierarchy d, double resolution = -1)
166  : SingletonGeometry(d), res_(resolution) {}
169  atom::Hierarchy d(get_particle());
170  atom::Selection sel(d);
171  sel.set_target_radius(res_);
173  for (unsigned int i = 0; i < ps.size(); ++i) {
174  if (components_.find(ps[i]) == components_.end()) {
175  IMP_NEW(core::XYZRGeometry, g, (core::XYZR(ps[i])));
176  components_[ps[i]] = g;
177  }
178  ret.push_back(components_.find(ps[i])->second);
179  }
180  return ret;
181  }
183 };
185  double res_;
187  base::Pointer<display::Geometry> > components_;
188 
189  public:
190  HierarchiesGeometry(SingletonContainer *sc, double resolution = -1)
191  : SingletonsGeometry(sc), res_(resolution) {}
194  IMP_CONTAINER_FOREACH(SingletonContainer, get_container(), {
195  kernel::Model *m = get_container()->get_model();
196  if (components_.find(_1) == components_.end()) {
197  IMP_NEW(HierarchyGeometry, g, (atom::Hierarchy(m, _1), res_));
198  components_[_1] = g;
199  }
200  ret.push_back(components_.find(_1)->second);
201  });
202  return ret;
203  }
205 };
206 
207 IMPATOM_END_NAMESPACE
208 
209 #endif /* IMPATOM_HIERARCHY_TOOLS_H */
A base class for geometry contained in particles.
display::Geometries get_components() const
Return a set of geometry composing this one.
void setup_as_approximation(kernel::Particle *h, const kernel::ParticlesTemp &other)
Hierarchy create_simplified_along_backbone(Hierarchy input, int num_res, bool keep_detailed=false)
A base class for geometry from a set of particles.
A smart pointer to a reference counted object.
Definition: base/Pointer.h:87
HierarchyTree get_hierarchy_tree(Hierarchy h)
#define IMP_NEW(Typename, varname, args)
Declare a ref counted pointer to a new object.
A particle with a user-defined type.
Decorator for helping deal with a hierarchy of molecules.
void transform(Hierarchy h, const algebra::Transformation3D &tr)
The standard decorator for manipulating molecular structures.
Display an IMP::SingletonContainer of IMP::atom::Hierarchy particles as balls.
IMP::kernel::Model Model
A decorator for Residues.
void set_target_radius(double r)
Definition: Selection.h:106
boost::graph HierarchyTree
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
IMP::base::Vector< IntRange > IntRanges
Definition: base/types.h:38
#define IMP_GRAPH(Name, directionality, VertexData, EdgeData, ShowVertex)
Define a graph object in IMP.
base::Index< ParticleIndexTag > ParticleIndex
IMP::kernel::Particle Particle
#define IMP_CONTAINER_FOREACH(ContainerType, container, operation)
kernel::Restraint * create_excluded_volume_restraint(const Hierarchies &hs, double resolution=-1)
A decorator for helping deal with a hierarchy.
IMP::kernel::Restraint Restraint
Decorator for a sphere-like particle.
A set of useful functionality on IMP::atom::Hierarchy decorators.
Hierarchy create_protein(kernel::Model *m, std::string name, double resolution, int number_of_residues, int first_residue_index=0, double volume=-1)
Create a coarse grained molecule.
A shared container for Singletons.
display::Geometries get_components() const
Return a set of geometry composing this one.
kernel::ParticlesTemp get_selected_particles() const
Get the selected particles.
Display an IMP::atom::Hierarchy particle as balls.
Class for storing model, its restraints, constraints, and particles.
Display an IMP::core::XYZR particle as a ball.
Definition: XYZR.h:160
IMP::base::Vector< Int > Ints
Standard way to pass a bunch of Int values.
Definition: base/types.h:49
A decorator for a particle with x,y,z coordinates and a radius.
Definition: XYZR.h:27