IMP logo
IMP Reference Guide  2.10.0
The Integrative Modeling Platform
HierarchySaveLink.h
Go to the documentation of this file.
1 /**
2  * \file IMP/rmf/HierarchySaveLink.h
3  * \brief Manage saving links to an RMF file from an atom::Hierarchy.
4  *
5  * Copyright 2007-2018 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPRMF_HIERARCHY_SAVE_LINK_H
10 #define IMPRMF_HIERARCHY_SAVE_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 save link between an RMF file and an atom::Hierarchy.
34 
35  \unstable{HierarchySaveLink}
36  */
37 class IMPRMFEXPORT HierarchySaveLink : public SimpleSaveLink<Particle> {
39  struct Data {
40  internal::HierarchySaveStatic save_static;
41  internal::HierarchySaveBonds save_bonds;
42  internal::HierarchySaveXYZs save_xyzs;
43  internal::HierarchySaveGaussians save_gaussians;
44  internal::HierarchySaveRigidBodies save_rigid_bodies;
45  Data(RMF::FileHandle h)
46  : save_static(h),
47  save_bonds(h),
48  save_xyzs(h),
49  save_gaussians(h),
50  save_rigid_bodies(h) {}
51  };
52  typedef boost::unordered_map<ParticleIndex, boost::shared_ptr<Data> >
53  DM;
54  DM data_;
55  RMF::decorator::AlternativesFactory af_;
56  RMF::decorator::StructureProvenanceFactory strucpf_;
57  RMF::decorator::SampleProvenanceFactory samppf_;
58  RMF::decorator::CombineProvenanceFactory combpf_;
59  RMF::decorator::FilterProvenanceFactory filtpf_;
60  RMF::decorator::ClusterProvenanceFactory clustpf_;
61  RMF::decorator::ScriptProvenanceFactory scriptpf_;
62  RMF::decorator::SoftwareProvenanceFactory softpf_;
63  RMF::decorator::ExplicitResolutionFactory explicit_resolution_factory_;
64  RMF::IntKey external_rigid_body_key_;
65 
66  void add_recursive(Model *m, ParticleIndex root,
67  ParticleIndex p,
68  ParticleIndexes rigid_bodies, RMF::NodeHandle cur,
69  Data &data);
70 
71  // Make RMF PROVENANCE nodes corresponding to those in IMP
72  void add_provenance(Model *m, ParticleIndex p, RMF::NodeHandle cur);
73 
74  virtual void do_add(Particle *p, RMF::NodeHandle cur) IMP_OVERRIDE;
75  virtual void do_save_one(Particle *o,
76  RMF::NodeHandle nh) IMP_OVERRIDE;
77  RMF::NodeType get_type(Particle *) const {
78  return RMF::REPRESENTATION;
79  }
80 
81  protected:
82  /** Override to add extra data for nodes. */
83  virtual void do_setup_node(Model *m, ParticleIndex root,
84  ParticleIndex p, RMF::NodeHandle n) {
85  IMP_UNUSED(m);
86  IMP_UNUSED(root);
87  IMP_UNUSED(p);
88  IMP_UNUSED(n);
89  }
90  /** Override to add extra data for nodes. */
91  virtual void do_save_hierarchy(Model *m, ParticleIndex root,
92  RMF::NodeHandle root_node) {
93  IMP_UNUSED(m);
94  IMP_UNUSED(root);
95  IMP_UNUSED(root_node);
96  }
97 
98  public:
99  HierarchySaveLink(RMF::FileHandle fh);
100  static const char *get_name() { return "atom save"; }
102 };
103 
104 IMPRMF_END_NAMESPACE
105 
106 #endif /* IMPRMF_HIERARCHY_SAVE_LINK_H */
Various general useful macros for IMP.
Classes to track how the model was created.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Various general useful macros for IMP.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
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
void add_provenance(Model *m, ParticleIndex pi, Provenance p)
Add provenance to part of the model.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.