9 #ifndef IMPATOM_HIERARCHY_H
10 #define IMPATOM_HIERARCHY_H
12 #include <IMP/atom/atom_config.h>
26 #define IMP_ATOM_GET_AS_DECL(UCName, lcname, CAPSNAME) \
27 UCName get_as_##lcname() const;
30 #define IMP_ATOM_GET_AS_DEF(UCName, lcname, CAPSNAME) \
31 UCName Hierarchy::get_as_##lcname() const { \
32 if (UCName::get_is_setup(get_particle())) { \
33 return UCName(get_particle()); \
40 #define IMP_ATOM_FOREACH_HIERARCHY_TYPE_LIST(macro) \
41 macro(Atom, atom, ATOM_TYPE), macro(Residue, residue, RESIDUE_TYPE), \
42 macro(Chain, chain, CHAIN_TYPE), \
43 macro(Molecule, molecule, MOLECULE_TYPE), \
44 macro(Domain, domain, DOMAIN_TYPE), \
45 macro(Fragment, fragment, FRAGMENT_TYPE), \
46 macro(core::XYZ, xyz, XYZ_TYPE), 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_STATEMENTS(macro) \
52 macro(Atom, atom, ATOM_TYPE); \
53 macro(Residue, residue, RESIDUE_TYPE); \
54 macro(Chain, chain, CHAIN_TYPE); \
55 macro(Molecule, molecule, MOLECULE_TYPE); \
56 macro(Domain, domain, DOMAIN_TYPE); \
57 macro(Fragment, fragment, FRAGMENT_TYPE); \
58 macro(core::XYZ, xyz, XYZ_TYPE); \
59 macro(core::XYZR, xyzr, XYZR_TYPE); \
60 macro(Mass, mass, MASS_TYPE); \
61 macro(State, state, STATE_TYPE)
64 #define IMP_ATOM_FOREACH_HIERARCHY_TYPE_FUNCTIONS(macro) \
65 macro(Atom, atom, ATOM_TYPE) macro(Residue, residue, RESIDUE_TYPE) \
66 macro(Chain, chain, CHAIN_TYPE) macro(Molecule, molecule, MOLECULE_TYPE) \
67 macro(Domain, domain, DOMAIN_TYPE) \
68 macro(Fragment, fragment, FRAGMENT_TYPE) macro(core::XYZ, xyz, XYZ_TYPE) \
69 macro(core::XYZR, xyzr, XYZR_TYPE) macro(Mass, mass, MASS_TYPE) \
70 macro(State, state, STATE_TYPE)
71 IMP_REQUIRE_SEMICOLON_NAMESPACE
73 #define IMP_ATOM_CAPS_NAME(UCName, lcname, CAPSNAME) CAPSNAME
75 IMPATOM_BEGIN_NAMESPACE
85 IMP_DECORATORS_DECL(Hierarchy, Hierarchies);
208 typedef boost::false_type DecoratorHasTraits;
211 IMPATOM_DEPRECATED_METHOD_DECL(2.3)
213 IMPATOM_DEPRECATED_METHOD_DEF(2.3,
"Check explicitly instead");
223 H::setup_particle(p, get_traits());
225 for (
unsigned int i = 0; i < children.size(); ++i) {
226 if (!get_is_setup(p->get_model(), children[i])) {
240 return H::get_is_setup(p, get_traits());
243 return H::get_is_setup(p, get_traits());
247 return H::get_is_setup(m->
get_particle(p), get_traits());
252 :
H(m, pi, get_traits()) {}
255 :
H(pi.get_model(), pi.get_particle_index(), get_traits()) {}
264 "Cannot construct a IMP.atom.Hierarchy from a general "
265 " IMP.core.Hierarchy");
273 H::setup_particle(m, pi, get_traits());
275 for (
unsigned int i = 0; i < children.size(); ++i) {
276 if (!get_is_setup(m, children[i])) {
287 return H::get_is_setup(m->
get_particle(p), get_traits());
306 void show(std::ostream &out, std::string delimiter)
const;
311 H hd = H::get_child(i);
317 for (
unsigned int i = 0; i < get_number_of_children(); ++i) {
318 ret[i] = get_child(i);
326 C ret(get_number_of_children());
327 for (
unsigned int i = 0; i < get_number_of_children(); ++i) {
328 ret[i] = get_child(i);
335 H hd = H::get_parent();
352 IMP_ATOM_FOREACH_HIERARCHY_TYPE_FUNCTIONS(IMP_ATOM_GET_AS_DECL);
362 IMP_DECORATORS_DEF(Hierarchy, Hierarchies);
381 IMP_ATOM_FOREACH_HIERARCHY_TYPE_LIST(IMP_ATOM_CAPS_NAME)
404 IMPATOMEXPORT Hierarchy
get_residue(Hierarchy mhd,
unsigned int index);
440 for (
unsigned int i = 0; i < h.size(); ++i) {
442 ret.insert(ret.end(), cur.begin(), cur.end());
444 return get_as<Hierarchies>(ret);
451 IMP::core::show<Hierarchy>(h, out);
466 const Hierarchies &h, std::string name = std::string(
"created rigid body"));
483 Hierarchy h, Hierarchy reference);
523 IMPATOMEXPORT
void destroy(Hierarchy d);
542 IMPATOM_END_NAMESPACE
Decorator for helping deal with a hierarchy.
Various important functionality for implementing decorators.
Hierarchy get_parent() const
algebra::Sphere3D get_bounding_sphere(const Hierarchy &h)
Hierarchies get_leaves(const Hierarchies &h)
void add_child(Hierarchy o)
Add a child and check that the types are appropriate.
ParticleIndex get_index() const
returns the particle index of this particle in its model
Particle * get_particle(ParticleIndex p) const
IMP::core::RigidBody create_compatible_rigid_body(Hierarchy h, Hierarchy reference)
Rigidify a molecule or collection of molecules.
Hierarchy()
null constructor
Hierarchy create_clone(Hierarchy d)
Clone the Hierarchy.
Bonds get_internal_bonds(Hierarchy mhd)
Get the bonds internal to this tree.
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex p)
#define IMP_SHOWABLE(Name)
Hierarchy get_residue(Hierarchy mhd, unsigned int index)
Get the residue with the specified index.
bool get_is_heterogen(Hierarchy h)
Return true if the piece of hierarchy should be classified as a heterogen.
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.
C get_children() const
Get the children in a container of your choosing, eg kernel::ParticlesTemp.
Hierarchy get_root(Hierarchy h)
Return the root of the hierarchy.
Hierarchy create_fragment(const Hierarchies &ps)
Create a fragment containing the specified nodes.
static Hierarchy setup_particle(kernel::Model *m, ParticleIndex pi, DecoratorTraits tr=get_default_decorator_traits())
bool get_is_valid() const
The standard decorator for manipulating molecular structures.
static Hierarchy setup_particle(kernel::Model *m, kernel::ParticleIndex pi, kernel::ParticleIndexesAdaptor children=kernel::ParticleIndexesAdaptor())
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
functionality for defining rigid bodies
BoundingBoxD< 3 > get_bounding_box(const Cone3D &g)
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
Class to handle individual model particles.
Storage of a model, its restraints, constraints and particles.
Classes to handle individual model particles. (Note that implementation of inline functions in in int...
void destroy(Hierarchy d)
Delete the Hierarchy.
Various important macros for implementing decorators.
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
IMP::core::RigidBody create_rigid_body(Hierarchy h)
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
A decorator for helping deal with a hierarchy.
A decorator for a rigid body.
Decorator for a sphere-like particle.
Hierarchy(IMP::core::Hierarchy h)
The traits must match.
Class for storing model, its restraints, constraints, and particles.