IMP  2.1.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-2013 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(kernel::Model *m, kernel::ParticleIndex pi,
24  char 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(kernel::Model *m, kernel::ParticleIndex pi,
31  Chain o) {
32  do_setup_particle(m, pi, o.get_id());
33  }
34 
35  public:
39 
41  return m->get_has_attribute(get_id_key(), pi) &&
43  }
44 
45  //! Return the chain id
46  char get_id() const {
47  return static_cast<char>(
48  get_model()->get_attribute(get_id_key(), get_particle_index()));
49  }
50 
51  //! Set the chain id
52  void set_id(char c) {
53  get_model()->set_attribute(get_id_key(), get_particle_index(), c);
54  }
55 
56  //! The key used to store the chain
57  static IntKey get_id_key();
58 };
59 
60 IMP_DECORATORS(Chain, Chains, Hierarchies);
61 
62 /** Get the containing chain or Chain() if there is none*/
63 IMPATOMEXPORT Chain get_chain(Hierarchy h);
64 
65 IMPATOM_END_NAMESPACE
66 
67 #endif /* IMPATOM_CHAIN_H */
Import IMP/kernel/Decorator.h in the namespace.
A base class for Keys.
Definition: kernel/Key.h:46
Chain get_chain(Hierarchy h)
#define IMP_DECORATOR_METHODS(Name, Parent)
Model * get_model() const
Returns the Model containing the particle.
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex p)
Import IMP/kernel/macros.h in the namespace.
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
char get_id() const
Return the chain id.
Definition: Chain.h:46
Decorator for helping deal with a hierarchy of molecules.
The standard decorator for manipulating molecular structures.
static Hierarchy setup_particle(kernel::Model *m, kernel::ParticleIndex pi, kernel::ParticleIndexesAdaptor children=kernel::ParticleIndexesAdaptor())
void set_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
void set_id(char c)
Set the chain id.
Definition: Chain.h:52
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
Store info for a chain of a protein.
Definition: Chain.h:21
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
Class for storing model, its restraints, constraints, and particles.