8#ifndef IMPCORE_PROVENANCE_H
9#define IMPCORE_PROVENANCE_H
11#include <IMP/core/core_config.h>
21IMPCORE_BEGIN_NAMESPACE
31class IMPCOREEXPORT Provenance :
public Decorator {
34 m->add_attribute(get_previous_key(), pi, pi);
41 return m->get_has_attribute(get_previous_key(), pi);
68 "Previous provenance is already set");
69 get_model()->set_attribute(get_previous_key(),
86class IMPCOREEXPORT StructureProvenance :
public Provenance {
90 int residue_offset=0) {
94 m->add_attribute(get_chain_key(), pi, chain_id);
95 m->add_attribute(get_residue_offset_key(), pi, residue_offset);
99 StructureProvenance o) {
100 do_setup_particle(m, pi, o.get_filename(), o.get_chain_id(),
101 o.get_residue_offset());
110 return m->get_has_attribute(get_filename_key(), pi)
111 && m->get_has_attribute(get_chain_key(), pi)
112 && m->get_has_attribute(get_residue_offset_key(), pi);
144 return get_model()->set_attribute(get_residue_offset_key(),
151 return get_model()->get_attribute(get_residue_offset_key(),
157 std::string, chain_id,
int, residue_offset);
159 std::string, chain_id);
173class IMPCOREEXPORT SampleProvenance :
public Provenance {
175 std::string method,
int frames,
176 int iterations,
int replicas=1) {
177 validate_method(method);
179 m->add_attribute(get_method_key(), pi, method);
180 m->add_attribute(get_frames_key(), pi, frames);
181 m->add_attribute(get_iterations_key(), pi, iterations);
182 m->add_attribute(get_replicas_key(), pi, replicas);
186 SampleProvenance o) {
187 do_setup_particle(m, pi, o.get_method(), o.get_number_of_frames(),
188 o.get_number_of_iterations(),
189 o.get_number_of_replicas());
198 static std::set<std::string>& get_allowed_methods();
202 static void validate_method(std::string method) {
204 != get_allowed_methods().end(),
205 "Invalid sampling method",
211 return m->get_has_attribute(get_method_key(), pi)
212 && m->get_has_attribute(get_iterations_key(), pi)
213 && m->get_has_attribute(get_frames_key(), pi);
219 validate_method(method);
242 return get_model()->set_attribute(get_iterations_key(),
248 return get_model()->get_attribute(get_iterations_key(),
254 return get_model()->set_attribute(get_replicas_key(),
260 return get_model()->get_attribute(get_replicas_key(),
266 int, iterations,
int, replicas);
280class IMPCOREEXPORT CombineProvenance :
public Provenance {
284 m->add_attribute(get_runs_key(), pi, runs);
285 m->add_attribute(get_frames_key(), pi, frames);
289 CombineProvenance o) {
290 do_setup_particle(m, pi, o.get_number_of_runs(), o.get_number_of_frames());
298 return m->get_has_attribute(get_frames_key(), pi)
299 && m->get_has_attribute(get_runs_key(), pi);
340class IMPCOREEXPORT FilterProvenance :
public Provenance {
342 double threshold,
int frames) {
343 validate_method(method);
345 m->add_attribute(get_method_key(), pi, method);
346 m->add_attribute(get_threshold_key(), pi, threshold);
347 m->add_attribute(get_frames_key(), pi, frames);
350 FilterProvenance o) {
351 do_setup_particle(m, pi, o.get_method(), o.get_threshold(),
352 o.get_number_of_frames());
360 static std::set<std::string>& get_allowed_methods();
364 static void validate_method(std::string method) {
366 != get_allowed_methods().end(),
367 "Invalid filtering method",
373 return m->get_has_attribute(get_method_key(), pi)
374 && m->get_has_attribute(get_threshold_key(), pi)
375 && m->get_has_attribute(get_frames_key(), pi);
381 validate_method(method);
410 return get_model()->get_attribute(get_threshold_key(),
416 double, threshold,
int, frames);
426class IMPCOREEXPORT ClusterProvenance :
public Provenance {
428 double precision=0., std::string density=
"") {
430 m->add_attribute(get_members_key(), pi, members);
431 m->add_attribute(get_precision_key(), pi, precision);
432 if (density.empty()) {
433 m->add_attribute(get_density_key(), pi, density);
440 ClusterProvenance o) {
441 do_setup_particle(m, pi, o.get_number_of_members()), o.get_precision(),
451 return m->get_has_attribute(get_members_key(), pi)
452 && m->get_has_attribute(get_precision_key(), pi)
453 && m->get_has_attribute(get_density_key(), pi);
475 return get_model()->get_attribute(get_precision_key(),
486 if (!density.empty()) {
502 std::string, density);
511class IMPCOREEXPORT ScriptProvenance :
public Provenance {
513 std::string filename) {
520 ScriptProvenance o) {
521 do_setup_particle(m, pi, o.get_filename());
528 return m->get_has_attribute(get_filename_key(), pi);
562class IMPCOREEXPORT SoftwareProvenance :
public Provenance {
566 std::string location) {
568 m->add_attribute(get_name_key(), pi, name);
569 m->add_attribute(get_version_key(), pi, version);
570 m->add_attribute(get_location_key(), pi, location);
574 SoftwareProvenance o) {
575 do_setup_particle(m, pi, o.get_software_name(), o.get_version(),
585 return m->get_has_attribute(get_name_key(), pi)
586 && m->get_has_attribute(get_version_key(), pi)
587 && m->get_has_attribute(get_location_key(), pi);
592 return get_model()->set_attribute(get_name_key(),
603 return get_model()->set_attribute(get_version_key(),
609 return get_model()->get_attribute(get_version_key(),
615 return get_model()->set_attribute(get_location_key(),
621 return get_model()->get_attribute(get_location_key(),
627 std::string, version, std::string, location);
632class IMPCOREEXPORT Provenanced :
public Decorator {
635 m->add_attribute(get_provenance_key(), pi, p.get_particle_index());
642 return m->get_has_attribute(get_provenance_key(), pi);
653 p.get_particle_index());
The base class for decorators.
A shared base class to help in debugging and things.
#define IMP_ALWAYS_CHECK(condition, message, exception_name)
Throw an exception if a check fails.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Interface to specialized Particle types (e.g. atoms).
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Model * get_model() const
Returns the Model containing the particle.
Class for storing model, its restraints, constraints, and particles.
An exception for an invalid usage of IMP.
Track creation of a system fragment from clustering.
void set_density(std::string density) const
Set the path to the localization probability density for this cluster.
void set_precision(double precision) const
Set the cluster precision.
void set_number_of_members(int members) const
Set the number of cluster members.
double get_precision() const
int get_number_of_members() const
std::string get_density() const
Track creation of a system fragment by combination.
int get_number_of_frames() const
void set_number_of_frames(int frames) const
Set the total number of frames.
int get_number_of_runs() const
void set_number_of_runs(int runs) const
Set the number of runs.
Track creation of a system fragment by filtering.
double get_threshold() const
int get_number_of_frames() const
std::string get_method() const
void set_threshold(double threshold) const
Set the score threshold.
void set_number_of_frames(int frames) const
Set the number of frames.
void set_method(std::string method) const
Track how parts of the system were created.
Provenance get_previous() const
static Provenance setup_particle(Model *m, ParticleIndex pi)
void set_previous(Provenance p)
Set the previous provenance.
Track creation of a system fragment from sampling.
int get_number_of_frames() const
void set_number_of_frames(int frames) const
Set the number of frames.
void set_method(std::string method) const
int get_number_of_iterations() const
void set_number_of_replicas(int replicas) const
Set the number of replicas.
void set_number_of_iterations(int iterations) const
Set the number of iterations.
std::string get_method() const
int get_number_of_replicas() const
Track creation of a system fragment from running a script.
void set_filename(std::string filename) const
Set the filename.
std::string get_filename() const
Track creation of a system fragment from running some software.
std::string get_version() const
std::string get_location() const
void set_software_name(std::string name) const
Set the name.
void set_location(std::string location) const
Set the location.
std::string get_software_name() const
void set_version(std::string version) const
Set the version.
Track creation of a system fragment from a PDB file.
std::string get_chain_id() const
void set_filename(std::string filename) const
Set the filename.
void set_chain_id(std::string chain_id) const
Set the chain ID.
int get_residue_offset() const
void set_residue_offset(int residue_offset) const
Set the offset between PDB and internal numbering (defaults to 0).
std::string get_filename() const
Helper macros for implementing Decorators.
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
#define IMP_DECORATOR_SETUP_0(Name)
#define IMP_DECORATOR_SETUP_4(Name, FirstArgumentType, first_argument_name, SecondArgumentType, second_argument_name, ThirdArgumentType, third_argument_name, FourthArgumentType, fourth_argument_name)
#define IMP_DECORATOR_SETUP_2(Name, FirstArgumentType, first_argument_name, SecondArgumentType, second_argument_name)
#define IMP_DECORATOR_METHODS(Name, Parent)
#define IMP_DECORATOR_SETUP_3(Name, FirstArgumentType, first_argument_name, SecondArgumentType, second_argument_name, ThirdArgumentType, third_argument_name)
Handling of file input/output.
void add_provenance(Model *m, ParticleIndex pi, Provenance p)
Add provenance to part of the model.
Provenance create_clone(Provenance p, Model *m=nullptr)
Clone provenance (including previous provenance).
Index< ParticleIndexTag > ParticleIndex
std::string get_absolute_path(std::string file)
Convert a possibly relative path to an absolute path.
Key< 15 > SparseParticleIndexKey
The type used to identify sparse particle attributes in the Particles.
Key< 12 > SparseStringKey
The type used to identify sparse string attributes in the Particles.
Key< 13 > SparseIntKey
The type used to identify sparse int attributes in the Particles.
Key< 14 > SparseFloatKey
The type used to identify sparse float attributes in the Particles.
Helper macros for implementing IMP Objects.