IMP logo
IMP Reference Guide  2.6.1
The Integrative Modeling Platform
Chain.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/Chain.h
3  * \brief Store the chain ID
4  *
5  * Copyright 2007-2016 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPATOM_CHAIN_H
9 #define IMPATOM_CHAIN_H
10 
11 #include <IMP/atom/atom_config.h>
12 #include "Hierarchy.h"
13 #include <IMP/macros.h>
14 #include <IMP/Decorator.h>
15 
16 IMPATOM_BEGIN_NAMESPACE
17 
18 //! Store info for a chain of a protein
19 /** \see Hierarchy
20  */
21 class IMPATOMEXPORT Chain : public Hierarchy {
22 
23  static void do_setup_particle(Model *m, ParticleIndex pi,
24  std::string id) {
25  m->add_attribute(get_id_key(), pi, id);
26  if (!Hierarchy::get_is_setup(m, pi)) {
28  }
29  }
30  static void do_setup_particle(Model *m, ParticleIndex pi,
31  char c) {
32  do_setup_particle(m, pi, std::string(1, c));
33  }
34  static void do_setup_particle(Model *m, ParticleIndex pi,
35  Chain o) {
36  do_setup_particle(m, pi, o.get_id());
37  }
38 
39  public:
41  IMP_DECORATOR_SETUP_1(Chain, std::string, id);
44 
45  static bool get_is_setup(Model *m, ParticleIndex pi) {
46  return m->get_has_attribute(get_id_key(), pi) &&
48  }
49 
50  //! Return the chain id
51  std::string get_id() const {
52  return get_model()->get_attribute(get_id_key(), get_particle_index());
53  }
54 
55  //! Set the chain id
56  void set_id(std::string c) {
57  get_model()->set_attribute(get_id_key(), get_particle_index(), c);
58  }
59 
60  //! The key used to store the chain
61  static StringKey get_id_key();
62 };
63 
64 IMP_DECORATORS(Chain, Chains, Hierarchies);
65 
66 /** Get the containing chain or Chain() if there is none*/
67 IMPATOMEXPORT Chain get_chain(Hierarchy h);
68 
69 /** Walk up the hierarchy to determine the chain id. */
70 IMPATOMEXPORT std::string get_chain_id(Hierarchy h);
71 
72 IMPATOM_END_NAMESPACE
73 
74 #endif /* IMPATOM_CHAIN_H */
The base class for decorators.
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Definition: Decorator.h:188
Chain get_chain(Hierarchy h)
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
Model * get_model() const
Returns the Model containing the particle.
Definition: Decorator.h:191
std::string get_id() const
Return the chain id.
Definition: Chain.h:51
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.
static Hierarchy setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor children=ParticleIndexesAdaptor())
Create a Hierarchy of level t by adding the needed attributes.
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
The standard decorator for manipulating molecular structures.
void set_id(std::string c)
Set the chain id.
Definition: Chain.h:56
void set_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
A base class for Keys.
Definition: Key.h:46
static bool get_is_setup(Model *m, ParticleIndex p)
Check if the particle has the needed attributes for a cast to succeed.
#define IMP_DECORATOR_METHODS(Name, Parent)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
Store info for a chain of a protein.
Definition: Chain.h:21
std::string get_chain_id(Hierarchy h)
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)