IMP logo
IMP Reference Guide  2.19.0
The Integrative Modeling Platform
protobuf.h
Go to the documentation of this file.
1 /**
2  * \file protobuf.h
3  * \brief A Score on the distance between a pair of particles.
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPNPCTRANSPORT_PROTOBUF_H
9 #define IMPNPCTRANSPORT_PROTOBUF_H
10 
11 #include "npctransport_config.h"
12 #include <IMP/SingletonContainer.h>
13 #include <IMP/core/Typed.h>
14 #include <boost/cstdint.hpp>
15 #include <set>
16 
17 #ifndef SWIG
18 // instead of including protobuf header, which is problematic due to
19 // minor issue with google headers namespaces
20 namespace npctransport_proto {
21  class Conformation;
22  class Output;
23 }
24 #endif
25 
26 IMPNPCTRANSPORT_BEGIN_NAMESPACE
27 
28 
29 IMPNPCTRANSPORTEXPORT void show_ranges(std::string fname);
30 
31 /**
32  reads the protobuf message in [input_config_fname], which may contain submessages with
33  ranges of values (indicated by presence of .upper and .lower fields, with
34  .steps possible steps for each such field). The output is a message with
35  the [work_unit]'th possible combination of these ranges, to the file
36  [output_assignment_fname].
37 
38  Note: the range values are enumerated as if they lie on a grid with
39  log-evenly distributed axis-aligned grid points, using the .base field
40  as the log base for each ranged field, such that e.g. iterating over the
41  range [1..8] with 3 steps and base 2 will be enumerated as (1,4,8)
42 
43  @param fname input_config_fname configuration file name
44  @param output output_assignment_fname assignment file name
45  @param work_unit the index of combination of range values to be used. If the
46  total of possible combinations of all fields with ranges is
47  k,
48  it is guaranteed that iterating over work_unit between
49  0..k-1
50  will enumerate over all possible combinations, and that
51  work_unit and (work_unit % k) will return the same output
52  for
53  the same input.
54  @param show_steps show the steps that occur
55  @param random_seed the random seed used to initialize the IMP random number
56  generator for this simulation
57 
58  @throw IMP::ValueException if any of the values in the configuration
59  file are in conflict (e.g., simulation time and maximal number of
60  frames)
61 */
62 // Each range field also has .steps and .base field.
63 IMPNPCTRANSPORTEXPORT int assign_ranges(
64  std::string input_config_fname, std::string output_assignment_fname, unsigned int work_unit,
65  bool show_steps,
66  boost::uint64_t random_seed // do not use boost::uint64_t cause of SWIG
67  );
68 
69 IMPNPCTRANSPORTEXPORT int get_number_of_work_units(
70  std::string configuration_file);
71 
72 #ifndef SWIG
73 /**
74  Loads a protobuf conformation into the diffusers and sites
75 
76  @param conformation the saved conformation protobuf message
77  @param beads corresponding diffusers to be updated
78  @param sites a map of sites for each diffuser particle type
79  to be updated
80 
81  @note the beads and sites must have the same structure
82  as the ones used when saving (e.g. their
83  non-changing variables are expected to
84  be identical, and they differ only in the
85  dynamic ones)
86  \see save_pb_conformation
87 */
89 ( const ::npctransport_proto::Conformation &conformation,
91  boost::unordered_map<core::ParticleType, algebra::Sphere3Ds> &sites);
92 
93 /**
94  Saves a protobuf conformation from the diffusers and sites
95 
96  @param beads beads to save
97  @param sites a map of sites for each diffuser particle type
98  to be saved
99  @param conformation the conformation protobuf message to be save
100 
101  \see load_pb_conformation
102  */
105  const boost::unordered_map<core::ParticleType, algebra::Sphere3Ds> &sites,
106  ::npctransport_proto::Conformation *conformation );
107 
108 //! load file output_fname into protobuf output object output
109 //! return true if succesful
110 bool load_output_protobuf(std::string output_fname,
111  ::npctransport_proto::Output& output);
112 #endif
113 
114 IMPNPCTRANSPORT_END_NAMESPACE
115 
116 #endif /* IMPNPCTRANSPORT_PROTOBUF_H */
A container for Singletons.
int assign_ranges(std::string input_config_fname, std::string output_assignment_fname, unsigned int work_unit, bool show_steps, boost::uint64_t random_seed)
void load_pb_conformation(const ::npctransport_proto::Conformation &conformation, IMP::SingletonContainerAdaptor beads, boost::unordered_map< core::ParticleType, algebra::Sphere3Ds > &sites)
A particle with a user-defined type.
void save_pb_conformation(IMP::SingletonContainerAdaptor beads, const boost::unordered_map< core::ParticleType, algebra::Sphere3Ds > &sites,::npctransport_proto::Conformation *conformation)
bool load_output_protobuf(std::string output_fname,::npctransport_proto::Output &output)