9 #ifndef IMPATOM_HIERARCHY_H
10 #define IMPATOM_HIERARCHY_H
12 #include <IMP/atom/atom_config.h>
26 #define IMP_GET_AS_DECL(UCName, lcname, CAPSNAME) \
27 UCName get_as_##lcname() const;
30 #define IMP_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_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)
50 #define IMP_FOREACH_HIERARCHY_TYPE_STATEMENTS(macro) \
51 macro(Atom, atom, ATOM_TYPE); \
52 macro(Residue, residue, RESIDUE_TYPE); \
53 macro(Chain, chain, CHAIN_TYPE); \
54 macro(Molecule, molecule, MOLECULE_TYPE); \
55 macro(Domain, domain, DOMAIN_TYPE); \
56 macro(Fragment, fragment, FRAGMENT_TYPE); \
57 macro(core::XYZ, xyz, XYZ_TYPE); \
58 macro(core::XYZR, xyzr, XYZR_TYPE); \
59 macro(Mass, mass, MASS_TYPE)
62 #define IMP_FOREACH_HIERARCHY_TYPE_FUNCTIONS(macro) \
63 macro(Atom, atom, ATOM_TYPE) macro(Residue, residue, RESIDUE_TYPE) \
64 macro(Chain, chain, CHAIN_TYPE) macro(Molecule, molecule, MOLECULE_TYPE) \
65 macro(Domain, domain, DOMAIN_TYPE) \
66 macro(Fragment, fragment, FRAGMENT_TYPE) macro(core::XYZ, xyz, XYZ_TYPE) \
67 macro(core::XYZR, xyzr, XYZR_TYPE) macro(Mass, mass, MASS_TYPE) \
68 IMP_REQUIRE_SEMICOLON_NAMESPACE
70 #define IMP_CAPS_NAME(UCName, lcname, CAPSNAME) CAPSNAME
72 IMPATOM_BEGIN_NAMESPACE
81 IMP_DECORATORS_DECL(Hierarchy, Hierarchies);
201 typedef boost::false_type DecoratorHasTraits;
214 H::setup_particle(p, get_traits());
216 for (
unsigned int i = 0; i < children.size(); ++i) {
217 if (!get_is_setup(p->get_model(), children[i])) {
230 return H::get_is_setup(p, get_traits());
233 return H::get_is_setup(p, get_traits());
236 return H::get_is_setup(m->
get_particle(p), get_traits());
241 :
H(m, pi, get_traits()) {}
244 :
H(pi.get_model(), pi.get_particle_index(), get_traits()) {}
253 "Cannot construct a IMP.atom.Hierarchy from a general "
254 " IMP.core.Hierarchy");
262 H::setup_particle(m, pi, get_traits());
264 for (
unsigned int i = 0; i < children.size(); ++i) {
265 if (!get_is_setup(m, children[i])) {
276 return H::get_is_setup(m->
get_particle(p), get_traits());
284 bool get_is_valid(
bool print_info)
const;
295 void show(std::ostream &out, std::string delimiter)
const;
300 H hd = H::get_child(i);
306 for (
unsigned int i = 0; i < get_number_of_children(); ++i) {
307 ret[i] = get_child(i);
315 C ret(get_number_of_children());
316 for (
unsigned int i = 0; i < get_number_of_children(); ++i) {
317 ret[i] = get_child(i);
324 H hd = H::get_parent();
341 IMP_FOREACH_HIERARCHY_TYPE_FUNCTIONS(IMP_GET_AS_DECL);
351 IMP_DECORATORS_DEF(Hierarchy, Hierarchies);
360 MOLECULE_TYPE.DOMAIN_TYPE,
368 IMP_FOREACH_HIERARCHY_TYPE_LIST(IMP_CAPS_NAME)
391 IMPATOMEXPORT Hierarchy
get_residue(Hierarchy mhd,
unsigned int index);
428 for (
unsigned int i = 0; i < h.size(); ++i) {
430 ret.insert(ret.end(), cur.begin(), cur.end());
432 return get_as<Hierarchies>(ret);
439 IMP::core::show<Hierarchy>(h, out);
454 const Hierarchies &h, std::string name = std::string(
"created rigid body"));
471 Hierarchy h, Hierarchy reference);
511 IMPATOMEXPORT
void destroy(Hierarchy d);
530 IMPATOM_END_NAMESPACE
Hierarchies get_leaves(Hierarchy h)
Decorator for helping deal with a hierarchy.
Various important functionality for implementing decorators.
static bool particle_is_instance(::IMP::kernel::Particle *p, const HierarchyTraits &tr=get_default_traits())
Hierarchy get_parent() const
algebra::Sphere3D get_bounding_sphere(const Hierarchy &h)
void add_child(Hierarchy o)
Add a child and check that the types are appropriate.
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)
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.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
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())
#define IMP_SHOWABLE(Name)
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
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.
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.
Residue get_residue(Atom d, bool nothrow=false)
Return the Residue containing this atom.
static Hierarchy decorate_particle(::IMP::kernel::Particle *p, const HierarchyTraits &tr=get_default_traits())
A decorator for helping deal with a hierarchy.
A decorator for a rigid body.
IMP::core::RigidBody create_rigid_body(const Hierarchies &h, std::string name=std::string("created rigid body"))
Rigidify a molecule or collection of molecules.
Decorator for a sphere-like particle.
Hierarchy(IMP::core::Hierarchy h)
The traits must match.
Class for storing model, its restraints, constraints, and particles.
BoundingBoxD< D > get_bounding_box(const BoundingBoxD< D > &g)