IMP  2.2.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-2014 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  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(kernel::Model *m, kernel::ParticleIndex pi,
31  char c) {
32  do_setup_particle(m, pi, std::string(1, c));
33  }
34  static void do_setup_particle(kernel::Model *m, kernel::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 
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  //! Return the chain id
56  /** \deprecated_at{2.2} Use the string version. */
57  IMPATOM_DEPRECATED_FUNCTION_DECL(2.2)
58  char get_id_char() const {
59  return get_model()->get_attribute(get_id_key(), get_particle_index())[0];
60  }
61 
62  //! Set the chain id
63  void set_id(std::string c) {
64  get_model()->set_attribute(get_id_key(), get_particle_index(), c);
65  }
66 
67  //! The key used to store the chain
68  static StringKey get_id_key();
69 };
70 
71 IMP_DECORATORS(Chain, Chains, Hierarchies);
72 
73 /** Get the containing chain or Chain() if there is none*/
74 IMPATOMEXPORT Chain get_chain(Hierarchy h);
75 
76 /** Walk up the hierarchy to determine the chain id. */
77 IMPATOMEXPORT std::string get_chain_id(Hierarchy h);
78 
79 IMPATOM_END_NAMESPACE
80 
81 #endif /* IMPATOM_CHAIN_H */
Import IMP/kernel/Decorator.h in the namespace.
ParticleIndex get_particle_index() const
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)
std::string get_id() const
Return the chain id.
Definition: Chain.h:51
Import IMP/kernel/macros.h in the namespace.
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
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_id(std::string c)
Set the chain id.
Definition: Chain.h:63
void set_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
Store info for a chain of a protein.
Definition: Chain.h:21
std::string get_chain_id(Hierarchy h)
#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.
Definition: kernel/Model.h:72