IMP logo
IMP Reference Guide  2.8.0
The Integrative Modeling Platform
StructureSource.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/StructureSource.h \brief Add a Structure ID and Chain ID
3  *
4  * Copyright 2007-2017 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPATOM_STRUCTURE_SOURCE_H
9 #define IMPATOM_STRUCTURE_SOURCE_H
10 
11 #include <IMP/atom/atom_config.h>
12 
13 #include <IMP/Particle.h>
14 #include <IMP/Model.h>
15 #include <IMP/Decorator.h>
16 #include <IMP/decorator_macros.h>
17 #include <IMP/exception.h>
18 
19 IMPATOM_BEGIN_NAMESPACE
20 
21 //! Store strings describing the source of this structure fragment
22 
23 class IMPATOMEXPORT StructureSource : public Decorator {
24  static StringKey get_source_id_key();
25  static StringKey get_source_chain_id_key();
26  static void do_setup_particle(Model *m, ParticleIndex pi,
27  std::string source_id,
28  std::string source_chain_id) {
29  IMP_USAGE_CHECK(!source_id.empty(), "The structure ID cannot be empty.");
30  m->add_attribute(get_source_id_key(), pi, source_id);
31  m->add_attribute(get_source_chain_id_key(), pi, source_chain_id);
32  }
33 
34  public:
35  static bool get_is_setup(Model *m, ParticleIndex pi) {
36  return (m->get_has_attribute(get_source_id_key(), pi) &&
37  m->get_has_attribute(get_source_chain_id_key(), pi));
38  }
39  //! Get the source ID
40  std::string get_source_id() const {
41  return get_particle()->get_value(get_source_id_key());
42  }
43 
44  //! Get the source ID
45  std::string get_source_chain_id() const {
46  return get_particle()->get_value(get_source_chain_id_key());
47  }
48 
49  //! Set the structure ID
50  void set_source_id(std::string source_id) {
51  IMP_USAGE_CHECK(!source_id.empty(), "The structure ID cannot be empty");
52  get_particle()->set_value(get_source_id_key(), source_id);
53  }
54 
55  //! Set the structure ID
56  void set_source_chain_id(std::string source_chain_id) {
57  get_particle()->set_value(get_source_chain_id_key(), source_chain_id);
58  }
59 
60  /* Declare the basic constructors and the cast function.*/
62  IMP_DECORATOR_SETUP_2(StructureSource, std::string, source_id,
63  std::string, source_chain_id);
64 };
65 
67 
68 IMPATOM_END_NAMESPACE
69 
70 #endif /* IMPATOM_STRUCTURE_SOURCE_H */
The base class for decorators.
Storage of a model, its restraints, constraints and particles.
Exception definitions and assertions.
A more IMP-like version of the std::vector.
Definition: Vector.h:39
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
std::string get_source_id() const
Get the source ID.
Store strings describing the source of this structure fragment.
void set_source_id(std::string source_id)
Set the structure ID.
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
add particle atribute with the specied key and initial value
Various general useful macros for IMP.
#define IMP_DECORATOR_SETUP_2(Name, FirstArgumentType, first_argument_name,SecondArgumentType, second_argument_name)
A base class for Keys.
Definition: Key.h:44
std::string get_source_chain_id() const
Get the source ID.
Particle * get_particle() const
Returns the particle decorated by this decorator.
Definition: Decorator.h:171
Interface to specialized Particle types (e.g. atoms)
Definition: Decorator.h:118
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
#define IMP_DECORATOR_METHODS(Name, Parent)
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Definition: check_macros.h:168
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
bool get_has_attribute(TypeKey attribute_key, ParticleIndex particle) const
return true if particle has attribute with the specified key
void set_source_chain_id(std::string source_chain_id)
Set the structure ID.