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;
213 H::setup_particle(p, get_traits());
215 for (
unsigned int i = 0; i < children.size(); ++i) {
216 if (!get_is_setup(p->get_model(), children[i])) {
228 IMPATOM_DEPRECATED_METHOD_DECL(2.2)
229 static bool particle_is_instance(
Particle *p) {
230 IMPATOM_DEPRECATED_METHOD_DEF(2.2,
"Use get_is_setup() instead");
231 return H::get_is_setup(p, get_traits());
233 static bool get_is_setup(
Particle *p) {
234 return H::get_is_setup(p, get_traits());
236 IMPATOM_DEPRECATED_METHOD_DECL(2.2)
238 IMPATOM_DEPRECATED_METHOD_DEF(2.2,
"Use get_is_setup() instead");
239 return H::get_is_setup(m->
get_particle(p), get_traits());
244 :
H(m, pi, get_traits()) {}
247 :
H(pi.get_model(), pi.get_particle_index(), get_traits()) {}
256 "Cannot construct a IMP.atom.Hierarchy from a general "
257 " IMP.core.Hierarchy");
264 H::setup_particle(m, pi, get_traits());
266 for (
unsigned int i = 0; i < children.size(); ++i) {
267 if (!get_is_setup(m, children[i])) {
277 return H::get_is_setup(m->
get_particle(p), get_traits());
297 void show(std::ostream &out, std::string delimiter)
const;
302 H hd = H::get_child(i);
308 for (
unsigned int i = 0; i < get_number_of_children(); ++i) {
309 ret[i] = get_child(i);
317 C ret(get_number_of_children());
318 for (
unsigned int i = 0; i < get_number_of_children(); ++i) {
319 ret[i] = get_child(i);
326 H hd = H::get_parent();
343 IMP_ATOM_FOREACH_HIERARCHY_TYPE_FUNCTIONS(IMP_ATOM_GET_AS_DECL);
353 IMP_DECORATORS_DEF(Hierarchy, Hierarchies);
371 IMP_ATOM_FOREACH_HIERARCHY_TYPE_LIST(IMP_ATOM_CAPS_NAME)
391 IMPATOMEXPORT Hierarchy
get_residue(Hierarchy mhd,
unsigned int index);
427 for (
unsigned int i = 0; i < h.size(); ++i) {
429 ret.insert(ret.end(), cur.begin(), cur.end());
431 return get_as<Hierarchies>(ret);
438 IMP::core::show<Hierarchy>(h, out);
453 const Hierarchies &h, std::string name = std::string(
"created rigid body"));
470 Hierarchy h, Hierarchy reference);
510 IMPATOMEXPORT
void destroy(Hierarchy d);
529 IMPATOM_END_NAMESPACE
Particle * get_particle(ParticleIndex p) const
Decorator for helping deal with a hierarchy.
Various important functionality for implementing decorators.
Hierarchy get_parent() const
Get the parent particle.
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.
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.
Storage of a model, its restraints, constraints and particles.
Bonds get_internal_bonds(Hierarchy mhd)
Get the bonds internal to this tree.
#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.
Class for storing model, its restraints, constraints, and particles.
C get_children() const
Get the children in a container of your choosing, eg ParticlesTemp.
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.
Hierarchy create_fragment(const Hierarchies &ps)
Create a fragment containing the specified nodes.
The standard decorator for manipulating molecular structures.
GetByType
The different types which can be passed to get_by_type()
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
Gather all the molecular particles of a certain level in the hierarchy.
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
void destroy(Hierarchy d)
Delete the Hierarchy.
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
Various important macros for implementing decorators.
static bool get_is_setup(Model *m, ParticleIndex p)
Check if the particle has the needed attributes for a cast to succeed.
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
IMP::core::RigidBody create_rigid_body(Hierarchy h)
Class to handle individual model particles.
#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 hierarchy.
A decorator for a rigid body.
Decorator for a sphere-like particle.
Hierarchy(IMP::core::Hierarchy h)
The traits must match.