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 IMPATOM_DEPRECATED_METHOD_DECL(2.6) \
28 UCName get_as_##lcname() const;
31 #define IMP_ATOM_GET_AS_DEF(UCName, lcname, CAPSNAME) \
32 UCName Hierarchy::get_as_##lcname() const { \
33 IMPATOM_DEPRECATED_METHOD_DEF(2.6, "Use decorators instead"); \
34 if (UCName::get_is_setup(get_particle())) { \
35 return UCName(get_particle()); \
42 #define IMP_ATOM_FOREACH_HIERARCHY_TYPE_LIST(macro) \
43 macro(Atom, atom, ATOM_TYPE), macro(Residue, residue, RESIDUE_TYPE), \
44 macro(Chain, chain, CHAIN_TYPE), \
45 macro(Molecule, molecule, MOLECULE_TYPE), \
46 macro(Domain, domain, DOMAIN_TYPE), \
47 macro(Fragment, fragment, FRAGMENT_TYPE), \
48 macro(core::XYZ, xyz, XYZ_TYPE), macro(core::XYZR, xyzr, XYZR_TYPE), \
49 macro(Mass, mass, MASS_TYPE), \
50 macro(State, state, STATE_TYPE)
53 #define IMP_ATOM_FOREACH_HIERARCHY_TYPE_STATEMENTS(macro) \
54 macro(Atom, atom, ATOM_TYPE); \
55 macro(Residue, residue, RESIDUE_TYPE); \
56 macro(Chain, chain, CHAIN_TYPE); \
57 macro(Molecule, molecule, MOLECULE_TYPE); \
58 macro(Domain, domain, DOMAIN_TYPE); \
59 macro(Fragment, fragment, FRAGMENT_TYPE); \
60 macro(core::XYZ, xyz, XYZ_TYPE); \
61 macro(core::XYZR, xyzr, XYZR_TYPE); \
62 macro(Mass, mass, MASS_TYPE); \
63 macro(State, state, STATE_TYPE)
66 #define IMP_ATOM_FOREACH_HIERARCHY_TYPE_FUNCTIONS(macro) \
67 macro(Atom, atom, ATOM_TYPE) macro(Residue, residue, RESIDUE_TYPE) \
68 macro(Chain, chain, CHAIN_TYPE) macro(Molecule, molecule, MOLECULE_TYPE) \
69 macro(Domain, domain, DOMAIN_TYPE) \
70 macro(Fragment, fragment, FRAGMENT_TYPE) macro(core::XYZ, xyz, XYZ_TYPE) \
71 macro(core::XYZR, xyzr, XYZR_TYPE) macro(Mass, mass, MASS_TYPE) \
72 macro(State, state, STATE_TYPE)
73 IMP_REQUIRE_SEMICOLON_NAMESPACE
75 #define IMP_ATOM_CAPS_NAME(UCName, lcname, CAPSNAME) CAPSNAME
77 IMPATOM_BEGIN_NAMESPACE
88 IMP_DECORATORS_DECL(Hierarchy, Hierarchies);
212 typedef boost::false_type DecoratorHasTraits;
217 H::setup_particle(p, get_traits());
219 for (
unsigned int i = 0; i < children.size(); ++i) {
220 if (!get_is_setup(p->get_model(), children[i])) {
232 static bool get_is_setup(
Particle *p) {
233 return H::get_is_setup(p, get_traits());
238 :
H(m, pi, get_traits()) {}
241 :
H(pi.get_model(), pi.get_particle_index(), get_traits()) {}
250 "Cannot construct a IMP.atom.Hierarchy from a general "
251 " IMP.core.Hierarchy");
258 H::setup_particle(m, pi, get_traits());
260 for (
unsigned int i = 0; i < children.size(); ++i) {
261 if (!get_is_setup(m, children[i])) {
271 return H::get_is_setup(m->
get_particle(p), get_traits());
291 void show(std::ostream &out, std::string delimiter)
const;
296 H hd = H::get_child(i);
302 for (
unsigned int i = 0; i < get_number_of_children(); ++i) {
303 ret[i] = get_child(i);
311 C ret(get_number_of_children());
312 for (
unsigned int i = 0; i < get_number_of_children(); ++i) {
313 ret[i] = get_child(i);
320 H hd = H::get_parent();
329 IMP_ATOM_FOREACH_HIERARCHY_TYPE_FUNCTIONS(IMP_ATOM_GET_AS_DECL);
339 IMP_DECORATORS_DEF(Hierarchy, Hierarchies);
357 IMP_ATOM_FOREACH_HIERARCHY_TYPE_LIST(IMP_ATOM_CAPS_NAME)
378 IMPATOMEXPORT Hierarchy
get_residue(Hierarchy mhd,
unsigned int index);
414 for (
unsigned int i = 0; i < h.size(); ++i) {
416 ret.insert(ret.end(), cur.begin(), cur.end());
418 return get_as<Hierarchies>(ret);
425 IMP::core::show<Hierarchy>(h, out);
440 const Hierarchies &h, std::string name = std::string(
"created rigid body"));
518 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.
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.
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.
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.
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.
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 generalized hierarchy.
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)
Decorator for a sphere-like particle.
Hierarchy(IMP::core::Hierarchy h)
The traits must match.