IMP logo
Chain.h
Go to the documentation of this file.
1 /**
2  * \file Chain.h
3  * \brief Store the chain ID
4  *
5  * Copyright 2007-2012 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPATOM_CHAIN_H
9 #define IMPATOM_CHAIN_H
10 
11 #include "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 {
24 public:
25  static Chain setup_particle(Particle *p, char id) {
26  p->add_attribute(get_id_key(), id);
27  if (!Hierarchy::particle_is_instance(p)) {
28  Hierarchy::setup_particle(p);
29  }
30  return Chain(p);
31  }
32 
33  static Chain setup_particle(Particle *p, Chain o) {
34  p->add_attribute(get_id_key(), o.get_id());
35  if (!Hierarchy::particle_is_instance(p)) {
36  Hierarchy::setup_particle(p);
37  }
38  return Chain(p);
39  }
40 
41 
42  static bool particle_is_instance(Particle *p) {
43  return p->has_attribute(get_id_key())
44  && Hierarchy::particle_is_instance(p);
45  }
46 
47  //! Return the chain id
48  char get_id() const {
49  return get_particle()->get_value(get_id_key());
50  }
51 
52  //! Set the chain id
53  void set_id(char c) {
54  get_particle()->set_value(get_id_key(), c);
55  }
56 
57  //! The key used to store the chain
58  static IntKey get_id_key();
59 };
60 
61 IMP_DECORATORS(Chain,Chains, Hierarchies);
62 
63 /** Get the containing chain or Chain() if there is none*/
64 IMPATOMEXPORT
65 Chain get_chain(Hierarchy h);
66 
67 IMPATOM_END_NAMESPACE
68 
69 #endif /* IMPATOM_CHAIN_H */

Generated on Tue May 22 2012 23:33:12 for IMP by doxygen 1.8.1