9 #ifndef IMPATOM_HIERARCHY_H
10 #define IMPATOM_HIERARCHY_H
12 #include <IMP/atom/atom_config.h>
27 #define IMP_ATOM_FOREACH_HIERARCHY_TYPE_LIST(macro) \
28 macro(Atom, atom, ATOM_TYPE), macro(Residue, residue, RESIDUE_TYPE), \
29 macro(Chain, chain, CHAIN_TYPE), \
30 macro(Molecule, molecule, MOLECULE_TYPE), \
31 macro(Domain, domain, DOMAIN_TYPE), \
32 macro(Fragment, fragment, FRAGMENT_TYPE), \
33 macro(core::XYZ, xyz, XYZ_TYPE), macro(core::XYZR, xyzr, XYZR_TYPE), \
34 macro(Mass, mass, MASS_TYPE), \
35 macro(State, state, STATE_TYPE)
38 #define IMP_ATOM_FOREACH_HIERARCHY_TYPE_STATEMENTS(macro) \
39 macro(Atom, atom, ATOM_TYPE); \
40 macro(Residue, residue, RESIDUE_TYPE); \
41 macro(Chain, chain, CHAIN_TYPE); \
42 macro(Molecule, molecule, MOLECULE_TYPE); \
43 macro(Domain, domain, DOMAIN_TYPE); \
44 macro(Fragment, fragment, FRAGMENT_TYPE); \
45 macro(core::XYZ, xyz, XYZ_TYPE); \
46 macro(core::XYZR, xyzr, XYZR_TYPE); \
47 macro(Mass, mass, MASS_TYPE); \
48 macro(State, state, STATE_TYPE)
51 #define IMP_ATOM_FOREACH_HIERARCHY_TYPE_FUNCTIONS(macro) \
52 macro(Atom, atom, ATOM_TYPE) macro(Residue, residue, RESIDUE_TYPE) \
53 macro(Chain, chain, CHAIN_TYPE) macro(Molecule, molecule, MOLECULE_TYPE) \
54 macro(Domain, domain, DOMAIN_TYPE) \
55 macro(Fragment, fragment, FRAGMENT_TYPE) macro(core::XYZ, xyz, XYZ_TYPE) \
56 macro(core::XYZR, xyzr, XYZR_TYPE) macro(Mass, mass, MASS_TYPE) \
57 macro(State, state, STATE_TYPE)
58 IMP_REQUIRE_SEMICOLON_NAMESPACE
60 #define IMP_ATOM_CAPS_NAME(UCName, lcname, CAPSNAME) CAPSNAME
62 IMPATOM_BEGIN_NAMESPACE
73 IMP_DECORATORS_DECL(Hierarchy, Hierarchies);
197 typedef boost::false_type DecoratorHasTraits;
202 H::setup_particle(p, get_traits());
204 for (
unsigned int i = 0; i < children.size(); ++i) {
205 if (!get_is_setup(p->get_model(), children[i])) {
217 static bool get_is_setup(
Particle *p) {
218 return H::get_is_setup(p, get_traits());
223 :
H(m, pi, get_traits()) {}
226 :
H(pi.get_model(), pi.get_particle_index(), get_traits()) {}
235 "Cannot construct a IMP.atom.Hierarchy from a general "
236 " IMP.core.Hierarchy");
243 H::setup_particle(m, pi, get_traits());
245 for (
unsigned int i = 0; i < children.size(); ++i) {
246 if (!get_is_setup(m, children[i])) {
256 return H::get_is_setup(m, p, get_traits());
276 void show(std::ostream &out, std::string delimiter)
const;
281 H hd = H::get_child(i);
287 for (
unsigned int i = 0; i < get_number_of_children(); ++i) {
288 ret[i] = get_child(i);
296 C ret(get_number_of_children());
297 for (
unsigned int i = 0; i < get_number_of_children(); ++i) {
298 ret[i] = get_child(i);
305 H hd = H::get_parent();
320 IMP_DECORATORS_DEF(Hierarchy, Hierarchies);
338 IMP_ATOM_FOREACH_HIERARCHY_TYPE_LIST(IMP_ATOM_CAPS_NAME)
359 IMPATOMEXPORT Hierarchy
get_residue(Hierarchy mhd,
unsigned int index);
395 for (
unsigned int i = 0; i < h.size(); ++i) {
397 ret.insert(ret.end(), cur.begin(), cur.end());
399 return get_as<Hierarchies>(ret);
406 IMP::core::show<Hierarchy>(h, out);
421 const Hierarchies &h, std::string name = std::string(
"created rigid body"));
501 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
510 else return Hierarchy();
514 IMPATOM_END_NAMESPACE
Decorator for helping deal with a hierarchy.
Various important functionality for implementing decorators.
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Hierarchy get_parent() const
Get the parent particle.
Decorator to hold Gaussian3D.
Hierarchies get_leaves(const Hierarchies &h)
Hierarchy create_clone(Hierarchy d)
Clone the Hierarchy.
void add_child(Hierarchy o)
Add a child and check that the types are appropriate.
IMP::core::RigidBody create_compatible_rigid_body(Hierarchy h, Hierarchy reference)
Rigidify a molecule or collection of molecules.
Hierarchy()
Null constructor.
Model * get_model() const
Returns the Model containing the particle.
Storage of a model, its restraints, constraints and particles.
void destroy(Hierarchy d)
Delete the Hierarchy.
#define IMP_SHOWABLE(Name)
Hierarchy create_fragment(const Hierarchies &ps)
Create a fragment containing the specified nodes.
GenericHierarchies get_leaves(Hierarchy mhd)
Get all the leaves of the bit of hierarchy.
Hierarchies get_children() const
Return the children in the order they were added.
Contains decorators for a bond.
Take Decorator, Particle or ParticleIndex.
Class for storing model, its restraints, constraints, and particles.
C get_children() const
Get the children in a container of your choosing, eg ParticlesTemp.
Bonds get_internal_bonds(Hierarchy mhd)
Get the bonds internal to this tree.
static Hierarchy setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor children=ParticleIndexesAdaptor())
Create a Hierarchy of level t by adding the needed attributes.
Hierarchy get_root(Hierarchy h)
Return the root of the hierarchy.
The standard decorator for manipulating molecular structures.
algebra::Sphere3D get_bounding_sphere(const Hierarchy &h)
GetByType
The different types which can be passed to get_by_type()
Hierarchy get_residue(Hierarchy mhd, unsigned int index)
Get the residue with the specified index.
functionality for defining rigid bodies
BoundingBoxD< 3 > get_bounding_box(const Cone3D &g)
static Hierarchy setup_particle(Model *m, ParticleIndex pi, DecoratorTraits tr=get_default_decorator_traits())
Define the type for a type of hierarchy.
Hierarchy create_clone_one(Hierarchy d)
Clone the node in the Hierarchy.
Hierarchy get_child(unsigned int i) const
Get the ith child based on the order they were added.
bool get_is_valid() const
Returns true if constructed with a non-default constructor.
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
std::ostream & show(Hierarchy h, std::ostream &out=std::cout)
Print the hierarchy using a given decorator to display each node.
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
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.
IMP::core::RigidBody create_rigid_body(Hierarchy h)
Class to handle individual particles of a Model object.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
ParticleIndex get_index() const
returns the particle index of this particle in its model
A decorator for helping deal with a generalized hierarchy.
bool get_has_attribute(TypeKey attribute_key, ParticleIndex particle) const
return true if particle has attribute with the specified key
A decorator for a rigid body.
bool get_is_heterogen(Hierarchy h)
Return true if the piece of hierarchy should be classified as a heterogen.
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
Gather all the molecular particles of a certain level in the hierarchy.
Hierarchies get_leaves(Hierarchy h)
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
get the value of the particle attribute with the specified key
Decorator for a sphere-like particle.
Hierarchy(IMP::core::Hierarchy h)
The traits must match.