IMP logo
hierarchy_tools.h
Go to the documentation of this file.
1 /**
2  * \file hierarchy_tools.h
3  * \brief A set of useful functionality on IMP::atom::Hierarchy decorators
4  *
5  * Copyright 2007-2012 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPATOM_HIERARCHY_TOOLS_H
9 #define IMPATOM_HIERARCHY_TOOLS_H
10 
11 #include "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  \relatesalso Hierarchy
42  */
43 IMPATOMEXPORT Hierarchy create_protein(Model *m,
44  std::string name,
45  double resolution,
46  int number_of_residues,
47  int first_residue_index=0,
48  double volume=-1
49 #ifndef IMP_DOXYGEN
50  , bool ismol=true
51 #endif
52 );
53 /** Like the former create_protein(), but it enforces domain splits
54  at the provide domain boundairs. The domain boundaries should be
55  the start of the first domain, any boundies, and then one past
56  the end of the last domain.
57  */
58 IMPATOMEXPORT Hierarchy create_protein(Model *m,
59  std::string name,
60  double resolution,
61  const Ints domain_boundaries);
62 
63 
64 /** \name Simplification along backbone
65 
66  These two methods create a simplified version of a molecule by
67  merging residues sequentially. In one case every n residues are
68  merged, in the other, the intervals are passed manually. The
69  resulting molecule is not optimized by default and has no
70  restraints automatically created.
71 
72  At the moment, the calls only support unmodified hierarchies loaded
73  by read_pdb() which have only protein or DNA members.
74 
75  They return Hierarchy() if the input chain is empty.
76  @{
77 */
78 /** Simplify every num_res into one particle.*/
79 IMPATOMEXPORT Hierarchy create_simplified_along_backbone(Chain input,
80  int num_res);
81 /** Simplify by breaking at the boundaries provided.*/
82 IMPATOMEXPORT Hierarchy create_simplified_along_backbone(Chain input,
83  const IntRanges& residue_segments);
84 /** @} */
85 
86 
87 /** \name Finding information
88  Get the attribute of the given particle or throw a ValueException
89  if it is not applicable. The particle with the given information
90  must be above the passed node.
91  @{
92 */
93 IMPATOMEXPORT std::string get_molecule_name(Hierarchy h);
94 IMPATOMEXPORT Ints get_residue_indexes(Hierarchy h);
95 IMPATOMEXPORT ResidueType get_residue_type(Hierarchy h);
96 IMPATOMEXPORT int get_chain_id(Hierarchy h);
97 IMPATOMEXPORT AtomType get_atom_type(Hierarchy h);
98 IMPATOMEXPORT std::string get_domain_name(Hierarchy h);
99 IMPATOMEXPORT int get_copy_index(Hierarchy h);
100 /** @} */
101 
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  \relatesalso Hierarchy
111  */
112 IMPATOMEXPORT Restraint* create_excluded_volume_restraint(const Hierarchies &hs,
113  double resolution=-1);
114 
115 
116 
117 
118 /** Set the mass, radius, residues, and coordinates to approximate the passed
119  particles.
120  */
121 IMPATOMEXPORT void setup_as_approximation(Particle *h,
122  const ParticlesTemp &other
123 #ifndef IMP_DOXYGEN
124  ,
125  double resolution=-1
126 #endif
127 );
128 
129 /** Set the mass, radius, residues, and coordinates to approximate the passed
130  particle based on the leaves of h.
131  \relatesalso Hierarchy
132  */
133 IMPATOMEXPORT void setup_as_approximation(Hierarchy h
134 #ifndef IMP_DOXYGEN
135  ,
136  double resolution =-1
137 #endif
138 );
139 
140 /** Transform a hierarchy. This is aware of rigid bodies.
141  */
142 IMPATOMEXPORT void transform(Hierarchy h, const algebra::Transformation3D &tr);
143 
144 
145 
146 /** A graph for representing a Hierarchy so you can view it
147  nicely.
148 */
149 IMP_GRAPH(HierarchyTree, bidirectional, Hierarchy, int);
150 /** Get a graph for the passed Hierarchy. This can be used,
151  for example, to graphically display the hierarchy in 2D.
152  \relatesalso Hierarchy
153 */
155 
156 
157 
158 
159 
160 /** \class HierarchyGeometry
161  \brief Display an IMP::atom::Hierarchy particle as balls.
162 
163  \class HierarchiesGeometry
164  \brief Display an IMP::SingletonContainer of IMP::atom::Hierarchy particles
165  as balls.
166 */
168  double res_;
170  components_;
171 public:
172  HierarchyGeometry(core::Hierarchy d, double resolution=-1):
173  SingletonGeometry(d), res_(resolution){}
174  display::Geometries get_components() const {
175  display::Geometries ret;
176  atom::Hierarchy d(get_particle());
177  atom::Selection sel(d);
178  sel.set_target_radius(res_);
180  for (unsigned int i=0; i< ps.size(); ++i) {
181  if (components_.find(ps[i])== components_.end()) {
182  IMP_NEW(core::XYZRGeometry, g, (core::XYZR(ps[i])));
183  components_[ps[i]]=g;
184  }
185  ret.push_back(components_.find(ps[i])->second);
186  }
187  return ret;
188  }
189  IMP_OBJECT_INLINE(HierarchyGeometry,
190  out << atom::Hierarchy(get_particle())<< std::endl;,{});
191 };
193  double res_;
195  components_;
196  public:
197  HierarchiesGeometry(SingletonContainer* sc, double resolution=-1):
198  SingletonsGeometry(sc), res_(resolution){}
199  display::Geometries get_components() const {
200  display::Geometries ret;
201  IMP_FOREACH_SINGLETON(get_container(), {
202  if (components_.find(_1)
203  == components_.end()) {
204  IMP_NEW(HierarchyGeometry, g, (atom::Hierarchy(_1), res_));
205  components_[_1]= g;
206  }
207  ret.push_back(components_.find(_1)->second);
208  });
209  return ret;
210  }
212  out << get_container() << std::endl;,{});
213 };
214 
215 IMPATOM_END_NAMESPACE
216 
217 #endif /* IMPATOM_HIERARCHY_TOOLS_H */

Generated on Tue May 22 2012 23:33:14 for IMP by doxygen 1.8.1