IMP logo
IMP Reference Guide  2.14.0
The Integrative Modeling Platform
RestraintInfo.h
Go to the documentation of this file.
1 /**
2  * \file IMP/RestraintInfo.h
3  * \brief Report key:value information on restraints
4  *
5  * Copyright 2007-2020 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPKERNEL_RESTRAINT_INFO_H
10 #define IMPKERNEL_RESTRAINT_INFO_H
11 
12 #include <IMP/kernel_config.h>
13 #include <IMP/Object.h>
14 #include <IMP/types.h>
15 #include <IMP/base_types.h>
16 
17 IMPKERNEL_BEGIN_NAMESPACE
18 
19 //! Report key:value information on restraints
20 /** These objects are typically returned by Restraint::get_static_info()
21  or Restraint::get_dynamic_info() and are used to report information
22  about a Restraint instance as a set of key:value pairs. The primary
23  purpose is to allow restraints to be written to files, such as RMF.
24 
25  Values can be simple types (int, float, string) or lists of them;
26  filename(s) (treated similarly to strings but paths are made relative
27  to that of the output file); or particles.
28 
29  Particle values are used to reference particles that contain restraint
30  information (either static or dynamic) that generally exist
31  outside of the molecular hierarchy, such as Bayesian nuisances
32  or Gaussians for an EM density map. The particles must live in
33  the same model as the restraint.
34  */
35 class IMPKERNELEXPORT RestraintInfo : public Object {
36 public:
37  RestraintInfo(std::string name = "RestraintInfo %1%") : Object(name) {}
38 
39  //! Add an int value referenced by the given key
40  void add_int(std::string key, int value);
41 
42  //! Get the number of int that have been added
43  unsigned get_number_of_int() const { return int_.size(); }
44 
45  //! Get the key for the ith int mapping
46  std::string get_int_key(unsigned i) const { return int_[i].first; }
47 
48  //! Get the value for the ith int mapping
49  int get_int_value(unsigned i) const {
50  return int_[i].second;
51  }
52 
53  //! Add a float value referenced by the given key
54  void add_float(std::string key, double value);
55 
56  //! Get the number of float that have been added
57  unsigned get_number_of_float() const { return float_.size(); }
58 
59  //! Get the key for the ith float mapping
60  std::string get_float_key(unsigned i) const { return float_[i].first; }
61 
62  //! Get the value for the ith float mapping
63  double get_float_value(unsigned i) const {
64  return float_[i].second;
65  }
66 
67  //! Add a string value referenced by the given key
68  void add_string(std::string key, std::string value);
69 
70  //! Get the number of string that have been added
71  unsigned get_number_of_string() const { return string_.size(); }
72 
73  //! Get the key for the ith string mapping
74  std::string get_string_key(unsigned i) const { return string_[i].first; }
75 
76  //! Get the value for the ith string mapping
77  std::string get_string_value(unsigned i) const {
78  return string_[i].second;
79  }
80 
81  //! Add a filename value referenced by the given key
82  /** Filenames are treated similarly to strings but the caller is expected
83  to make them absolute paths before adding them here. When written to
84  file they may be converted to paths relative to the file.
85  */
86  void add_filename(std::string key, std::string value);
87 
88  //! Get the number of filename that have been added
89  unsigned get_number_of_filename() const { return filename_.size(); }
90 
91  //! Get the key for the ith filename mapping
92  std::string get_filename_key(unsigned i) const { return filename_[i].first; }
93 
94  //! Get the value for the ith filename mapping
95  std::string get_filename_value(unsigned i) const {
96  return filename_[i].second;
97  }
98 
99  //! Add a list of Float values referenced by the given key
100  void add_floats(std::string key, Floats value);
101 
102  //! Get the number of Floats that have been added
103  unsigned get_number_of_floats() const { return floats_.size(); }
104 
105  //! Get the key for the ith Floats mapping
106  std::string get_floats_key(unsigned i) const { return floats_[i].first; }
107 
108  //! Get the value for the ith Floats mapping
109  Floats get_floats_value(unsigned i) const {
110  return floats_[i].second;
111  }
112 
113  //! Add a list of Int values referenced by the given key
114  void add_ints(std::string key, Ints value);
115 
116  //! Get the number of Ints that have been added
117  unsigned get_number_of_ints() const { return ints_.size(); }
118 
119  //! Get the key for the ith Ints mapping
120  std::string get_ints_key(unsigned i) const { return ints_[i].first; }
121 
122  //! Get the value for the ith Ints mapping
123  Ints get_ints_value(unsigned i) const {
124  return ints_[i].second;
125  }
126 
127  //! Add a list of string values referenced by the given key
128  void add_strings(std::string key, Strings value);
129 
130  //! Get the number of strings that have been added
131  unsigned get_number_of_strings() const { return strings_.size(); }
132 
133  //! Get the key for the ith strings mapping
134  std::string get_strings_key(unsigned i) const {
135  return strings_[i].first;
136  }
137 
138  //! Get the value for the ith strings mapping
139  Strings get_strings_value(unsigned i) const {
140  return strings_[i].second;
141  }
142 
143  //! Add a list of filename values referenced by the given key
144  /** Filenames are treated similarly to strings but the caller is expected
145  to make them absolute paths before adding them here. When written to
146  file they may be converted to paths relative to the file.
147  */
148  void add_filenames(std::string key, Strings value);
149 
150  //! Get the number of filenames that have been added
151  unsigned get_number_of_filenames() const { return filenames_.size(); }
152 
153  //! Get the key for the ith filenames mapping
154  std::string get_filenames_key(unsigned i) const {
155  return filenames_[i].first;
156  }
157 
158  //! Get the value for the ith filenames mapping
159  Strings get_filenames_value(unsigned i) const {
160  return filenames_[i].second;
161  }
162 
163  //! Add ParticleIndexes referenced by the given key
164  void add_particle_indexes(std::string key, ParticleIndexes value);
165 
166  //! Get the number of ParticleIndexes that have been added
167  unsigned get_number_of_particle_indexes() const { return pis_.size(); }
168 
169  //! Get the key for the ith ParticleIndexes mapping
170  std::string get_particle_indexes_key(unsigned i) const {
171  return pis_[i].first;
172  }
173 
174  //! Get the value for the ith ParticleIndexes mapping
176  return pis_[i].second;
177  }
178 
180 
181 private:
182  typedef std::pair<std::string, int> IntData;
183  std::vector<IntData> int_;
184 
185  typedef std::pair<std::string, double> FloatData;
186  std::vector<FloatData> float_;
187 
188  typedef std::pair<std::string, std::string> StringData;
189  std::vector<StringData> string_, filename_;
190 
191  typedef std::pair<std::string, Floats> FloatsData;
192  std::vector<FloatsData> floats_;
193 
194  typedef std::pair<std::string, Ints> IntsData;
195  std::vector<IntsData> ints_;
196 
197  typedef std::pair<std::string, Strings> StringsData;
198  std::vector<StringsData> strings_;
199  std::vector<StringsData> filenames_;
200 
201  typedef std::pair<std::string, ParticleIndexes> ParticleIndexesData;
202  std::vector<ParticleIndexesData> pis_;
203 };
204 
205 IMPKERNEL_END_NAMESPACE
206 
207 #endif /* IMPKERNEL_RESTRAINT_INFO_H */
Basic types used by IMP.
Basic types used by IMP.
unsigned get_number_of_filenames() const
Get the number of filenames that have been added.
std::string get_string_value(unsigned i) const
Get the value for the ith string mapping.
Definition: RestraintInfo.h:77
double get_float_value(unsigned i) const
Get the value for the ith float mapping.
Definition: RestraintInfo.h:63
unsigned get_number_of_filename() const
Get the number of filename that have been added.
Definition: RestraintInfo.h:89
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
std::string get_strings_key(unsigned i) const
Get the key for the ith strings mapping.
std::string get_filename_key(unsigned i) const
Get the key for the ith filename mapping.
Definition: RestraintInfo.h:92
int get_int_value(unsigned i) const
Get the value for the ith int mapping.
Definition: RestraintInfo.h:49
std::string get_float_key(unsigned i) const
Get the key for the ith float mapping.
Definition: RestraintInfo.h:60
Floats get_floats_value(unsigned i) const
Get the value for the ith Floats mapping.
std::string get_filename_value(unsigned i) const
Get the value for the ith filename mapping.
Definition: RestraintInfo.h:95
std::string get_ints_key(unsigned i) const
Get the key for the ith Ints mapping.
ParticleIndexes get_particle_indexes_value(unsigned i) const
Get the value for the ith ParticleIndexes mapping.
Strings get_strings_value(unsigned i) const
Get the value for the ith strings mapping.
std::string get_filenames_key(unsigned i) const
Get the key for the ith filenames mapping.
Common base class for heavy weight IMP objects.
Definition: Object.h:106
std::string get_floats_key(unsigned i) const
Get the key for the ith Floats mapping.
unsigned get_number_of_float() const
Get the number of float that have been added.
Definition: RestraintInfo.h:57
unsigned get_number_of_particle_indexes() const
Get the number of ParticleIndexes that have been added.
unsigned get_number_of_string() const
Get the number of string that have been added.
Definition: RestraintInfo.h:71
unsigned get_number_of_strings() const
Get the number of strings that have been added.
Report key:value information on restraints.
Definition: RestraintInfo.h:35
std::string get_int_key(unsigned i) const
Get the key for the ith int mapping.
Definition: RestraintInfo.h:46
unsigned get_number_of_int() const
Get the number of int that have been added.
Definition: RestraintInfo.h:43
A shared base class to help in debugging and things.
std::string get_particle_indexes_key(unsigned i) const
Get the key for the ith ParticleIndexes mapping.
Object(std::string name)
Construct an object with the given name.
std::string get_string_key(unsigned i) const
Get the key for the ith string mapping.
Definition: RestraintInfo.h:74
unsigned get_number_of_floats() const
Get the number of Floats that have been added.
unsigned get_number_of_ints() const
Get the number of Ints that have been added.
Ints get_ints_value(unsigned i) const
Get the value for the ith Ints mapping.
Strings get_filenames_value(unsigned i) const
Get the value for the ith filenames mapping.