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)
50 #define IMP_ATOM_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_ATOM_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_ATOM_CAPS_NAME(UCName, lcname, CAPSNAME) CAPSNAME
72 IMPATOM_BEGIN_NAMESPACE
81 IMP_DECORATORS_DECL(Hierarchy, Hierarchies);
203 typedef boost::false_type DecoratorHasTraits;
216 H::setup_particle(p, get_traits());
218 for (
unsigned int i = 0; i < children.size(); ++i) {
219 if (!get_is_setup(p->get_model(), children[i])) {
233 return H::get_is_setup(p, get_traits());
236 return H::get_is_setup(p, get_traits());
240 return H::get_is_setup(m->
get_particle(p), get_traits());
245 :
H(m, pi, get_traits()) {}
248 :
H(pi.get_model(), pi.get_particle_index(), get_traits()) {}
257 "Cannot construct a IMP.atom.Hierarchy from a general "
258 " IMP.core.Hierarchy");
266 H::setup_particle(m, pi, get_traits());
268 for (
unsigned int i = 0; i < children.size(); ++i) {
269 if (!get_is_setup(m, children[i])) {
280 return H::get_is_setup(m->
get_particle(p), get_traits());
288 bool get_is_valid(
bool print_info)
const;
299 void show(std::ostream &out, std::string delimiter)
const;
304 H hd = H::get_child(i);
310 for (
unsigned int i = 0; i < get_number_of_children(); ++i) {
311 ret[i] = get_child(i);
319 C ret(get_number_of_children());
320 for (
unsigned int i = 0; i < get_number_of_children(); ++i) {
321 ret[i] = get_child(i);
328 H hd = H::get_parent();
345 IMP_ATOM_FOREACH_HIERARCHY_TYPE_FUNCTIONS(IMP_ATOM_GET_AS_DECL);
355 IMP_DECORATORS_DEF(Hierarchy, Hierarchies);
373 IMP_ATOM_FOREACH_HIERARCHY_TYPE_LIST(IMP_ATOM_CAPS_NAME)
396 IMPATOMEXPORT Hierarchy
get_residue(Hierarchy mhd,
unsigned int index);
433 for (
unsigned int i = 0; i < h.size(); ++i) {
435 ret.insert(ret.end(), cur.begin(), cur.end());
437 return get_as<Hierarchies>(ret);
444 IMP::core::show<Hierarchy>(h, out);
459 const Hierarchies &h, std::string name = std::string(
"created rigid body"));
476 Hierarchy h, Hierarchy reference);
516 IMPATOMEXPORT
void destroy(Hierarchy d);
535 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.
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.
algebra::BoundingBoxD< 3 > get_bounding_box(const Hierarchy &h)
Get a bounding box for the Hierarchy.
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex p)
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.
#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.
IMP::core::RigidBody create_rigid_body(Hierarchy h)
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.
Decorator for a sphere-like particle.
Hierarchy(IMP::core::Hierarchy h)
The traits must match.
Class for storing model, its restraints, constraints, and particles.