IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
HierarchyLoadLink.h
Go to the documentation of this file.
1/**
2 * \file IMP/rmf/HierarchyLoadLink.h
3 * \brief Manages loading links from an RMF file to an atom::Hierarchy.
4 *
5 * Copyright 2007-2022 IMP Inventors. All rights reserved.
6 *
7 */
8
9#ifndef IMPRMF_HIERARCHY_LOAD_LINK_H
10#define IMPRMF_HIERARCHY_LOAD_LINK_H
11
12#include <IMP/rmf/rmf_config.h>
13#include "simple_links.h"
14#include "internal/atom_links_static.h"
15#include "internal/atom_links_rigid_bodies.h"
16#include "internal/atom_links_xyzs.h"
17#include "internal/atom_links_gaussians.h"
18#include <RMF/decorator/alternatives.h>
19#include <RMF/decorator/provenance.h>
20#include <IMP/object_macros.h>
21#include <IMP/utility_macros.h>
22#include <RMF/NodeHandle.h>
23#include <RMF/FileHandle.h>
24#include <IMP/atom/Hierarchy.h>
25#include <IMP/core/provenance.h>
26#include <IMP/rmf/links.h>
27#include <IMP/rmf/link_macros.h>
28#include <IMP/tuple_macros.h>
29#include <RMF/decorators.h>
30#include <memory>
31#include <boost/unordered_map.hpp>
32
33IMPRMF_BEGIN_NAMESPACE
34
35/** Manage the loading link between an RMF file and an atom::Hierarchy.
36
37 \unstable{HierarchyLoadLink}
38 */
39class IMPRMFEXPORT HierarchyLoadLink : public SimpleLoadLink<Particle> {
40 typedef SimpleLoadLink<Particle> P;
41 RMF::decorator::IntermediateParticleFactory intermediate_particle_factory_;
42 RMF::decorator::ReferenceFrameFactory reference_frame_factory_;
43 RMF::decorator::AlternativesFactory af_;
44 RMF::decorator::StructureProvenanceFactory strucpf_;
45 RMF::decorator::SampleProvenanceFactory samppf_;
46 RMF::decorator::CombineProvenanceFactory combpf_;
47 RMF::decorator::FilterProvenanceFactory filtpf_;
48 RMF::decorator::ClusterProvenanceFactory clustpf_;
49 RMF::decorator::ScriptProvenanceFactory scriptpf_;
50 RMF::decorator::SoftwareProvenanceFactory softpf_;
51 RMF::decorator::ExplicitResolutionFactory explicit_resolution_factory_;
52 RMF::IntKey external_rigid_body_key_;
53 struct Data {
54 internal::HierarchyLoadStatic load_static;
55 internal::HierarchyLoadBonds load_bonds;
56 internal::HierarchyLoadXYZs load_xyzs;
57 internal::HierarchyLoadGaussians load_gaussians;
58 internal::HierarchyLoadRigidBodies load_rigid_bodies;
59 Data(RMF::FileConstHandle h)
60 : load_static(h),
61 load_bonds(h),
62 load_xyzs(h),
63 load_gaussians(h),
64 load_rigid_bodies(h) {}
65 };
66 typedef boost::unordered_map<ParticleIndex, std::shared_ptr<Data>>
67 DM;
68 DM data_;
69 virtual bool get_is(RMF::NodeConstHandle nh) const override {
70 return nh.get_type() == RMF::REPRESENTATION;
71 }
72 virtual void add_link_recursive(Model *m, ParticleIndex root,
74 RMF::NodeConstHandle node,
75 ParticleIndexes rigid_bodies,
76 Data &data);
77
78 virtual void do_add_link(Particle *o,
79 RMF::NodeConstHandle node) final override;
80 using P::do_create;
81 virtual Particle *do_create(RMF::NodeConstHandle name,
82 Model *m) final override;
83 void create_recursive(Model *m, ParticleIndex root,
84 ParticleIndex cur, RMF::NodeConstHandle name,
85 ParticleIndexes rigid_bodies, Data &data);
86
87 // Make tree of *Provenance IMP particles corresponding to those in the RMF
88 void create_provenance(Model *m, RMF::NodeConstHandle node,
89 ParticleIndex cur);
90
91 // Make *Provenance IMP particle corresponding to that in the RMF
92 core::Provenance create_one_provenance(Model *m, RMF::NodeConstHandle node);
93
94 virtual void do_load_one(RMF::NodeConstHandle nh,
95 Particle *o) final override;
96
97 protected:
98 /** This method is called for the hierarchy.*/
99 virtual void do_load_hierarchy(RMF::NodeConstHandle root_node,
100 Model *m, ParticleIndex root) {
101 IMP_UNUSED(root_node);
102 IMP_UNUSED(m);
103 IMP_UNUSED(root);
104 }
105 /** Overload this to take specific action on creating
106 a member of the hierarchy.
107 \unstable{do_create_recursive} */
108 virtual void do_setup_particle(Model *m, ParticleIndex root,
109 ParticleIndex cur,
110 RMF::NodeConstHandle node) {
111 IMP_UNUSED(m);
112 IMP_UNUSED(root);
113 IMP_UNUSED(cur);
114 IMP_UNUSED(node);
115 }
116
117 /** Overload this to take specific action on linking
118 a member of the hierarchy.
119 \unstable{do_add_link_recursive} */
120 virtual void do_link_particle(Model *m, ParticleIndex root,
121 ParticleIndex cur,
122 RMF::NodeConstHandle node) {
123 IMP_UNUSED(root);
124 IMP_UNUSED(m);
125 IMP_UNUSED(cur);
126 IMP_UNUSED(node);
127 }
128
129 public:
130 HierarchyLoadLink(RMF::FileConstHandle fh);
131
132 static const char *get_name() { return "atom load"; }
133
134 IMP_OBJECT_METHODS(HierarchyLoadLink);
135};
136
137IMPRMF_END_NAMESPACE
138
139#endif /* IMPRMF_HIERARCHY_LOAD_LINK_H */
Decorator for helping deal with a hierarchy of molecules.
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Class to handle individual particles of a Model object.
Definition Particle.h:45
Track how parts of the system were created.
Definition provenance.h:31
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
Vector< ParticleIndex, std::allocator< ParticleIndex > > ParticleIndexes
A list of particles, each identified by its ParticleIndex.
Definition base_types.h:199
Helper macros for implementing IMP Objects.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Classes to track how the model was created.
Macros to help in defining tuple classes.
Various general useful macros for IMP.
#define IMP_UNUSED(variable)