IMP logo
IMP Reference Guide  2.16.0
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-2021 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 <boost/unordered_map.hpp>
31 IMPRMF_BEGIN_NAMESPACE
32 
33 /** Manage the loading link between an RMF file and an atom::Hierarchy.
34 
35  \unstable{HierarchyLoadLink}
36  */
37 class IMPRMFEXPORT HierarchyLoadLink : public SimpleLoadLink<Particle> {
39  RMF::decorator::IntermediateParticleFactory intermediate_particle_factory_;
40  RMF::decorator::ReferenceFrameFactory reference_frame_factory_;
41  RMF::decorator::AlternativesFactory af_;
42  RMF::decorator::StructureProvenanceFactory strucpf_;
43  RMF::decorator::SampleProvenanceFactory samppf_;
44  RMF::decorator::CombineProvenanceFactory combpf_;
45  RMF::decorator::FilterProvenanceFactory filtpf_;
46  RMF::decorator::ClusterProvenanceFactory clustpf_;
47  RMF::decorator::ScriptProvenanceFactory scriptpf_;
48  RMF::decorator::SoftwareProvenanceFactory softpf_;
49  RMF::decorator::ExplicitResolutionFactory explicit_resolution_factory_;
50  RMF::IntKey external_rigid_body_key_;
51  struct Data {
52  internal::HierarchyLoadStatic load_static;
53  internal::HierarchyLoadBonds load_bonds;
54  internal::HierarchyLoadXYZs load_xyzs;
55  internal::HierarchyLoadGaussians load_gaussians;
56  internal::HierarchyLoadRigidBodies load_rigid_bodies;
57  Data(RMF::FileConstHandle h)
58  : load_static(h),
59  load_bonds(h),
60  load_xyzs(h),
61  load_gaussians(h),
62  load_rigid_bodies(h) {}
63  };
64  typedef boost::unordered_map<ParticleIndex, boost::shared_ptr<Data> >
65  DM;
66  DM data_;
67  virtual bool get_is(RMF::NodeConstHandle nh) const IMP_OVERRIDE {
68  return nh.get_type() == RMF::REPRESENTATION;
69  }
70  virtual void add_link_recursive(Model *m, ParticleIndex root,
71  ParticleIndex o,
72  RMF::NodeConstHandle node,
73  ParticleIndexes rigid_bodies,
74  Data &data);
75 
76  virtual void do_add_link(Particle *o,
77  RMF::NodeConstHandle node) IMP_FINAL IMP_OVERRIDE;
78  using P::do_create;
79  virtual Particle *do_create(RMF::NodeConstHandle name,
81  void create_recursive(Model *m, ParticleIndex root,
82  ParticleIndex cur, RMF::NodeConstHandle name,
83  ParticleIndexes rigid_bodies, Data &data);
84 
85  // Make tree of *Provenance IMP particles corresponding to those in the RMF
86  void create_provenance(Model *m, RMF::NodeConstHandle node,
87  ParticleIndex cur);
88 
89  // Make *Provenance IMP particle corresponding to that in the RMF
90  core::Provenance create_one_provenance(Model *m, RMF::NodeConstHandle node);
91 
92  virtual void do_load_one(RMF::NodeConstHandle nh,
94 
95  protected:
96  /** This method is called for the hierarchy.*/
97  virtual void do_load_hierarchy(RMF::NodeConstHandle root_node,
98  Model *m, ParticleIndex root) {
99  IMP_UNUSED(root_node);
100  IMP_UNUSED(m);
101  IMP_UNUSED(root);
102  }
103  /** Overload this to take specific action on creating
104  a member of the hierarchy.
105  \unstable{do_create_recursive} */
106  virtual void do_setup_particle(Model *m, ParticleIndex root,
107  ParticleIndex cur,
108  RMF::NodeConstHandle node) {
109  IMP_UNUSED(m);
110  IMP_UNUSED(root);
111  IMP_UNUSED(cur);
112  IMP_UNUSED(node);
113  }
114 
115  /** Overload this to take specific action on linking
116  a member of the hierarchy.
117  \unstable{do_add_link_recursive} */
118  virtual void do_link_particle(Model *m, ParticleIndex root,
119  ParticleIndex cur,
120  RMF::NodeConstHandle node) {
121  IMP_UNUSED(root);
122  IMP_UNUSED(m);
123  IMP_UNUSED(cur);
124  IMP_UNUSED(node);
125  }
126 
127  public:
128  HierarchyLoadLink(RMF::FileConstHandle fh);
129 
130  static const char *get_name() { return "atom load"; }
131 
133 };
134 
135 IMPRMF_END_NAMESPACE
136 
137 #endif /* IMPRMF_HIERARCHY_LOAD_LINK_H */
Helper macros for implementing IMP Objects.
Classes to track how the model was created.
#define IMP_FINAL
Have the compiler report an error if anything overrides this method.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Macros to help in defining tuple classes.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:73
Decorator for helping deal with a hierarchy of molecules.
#define IMP_UNUSED(variable)
Various general useful macros for IMP.
Key< 1 > IntKey
The type used to identify int attributes in the Particles.
Definition: base_types.h:36
Class to handle individual particles of a Model object.
Definition: Particle.h:41
Track how parts of the system were created.
Definition: provenance.h:31
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.