IMP  2.1.1
The Integrative Modeling Platform
Residue.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/Residue.h \brief A decorator for Residues.
3  *
4  * Copyright 2007-2013 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPATOM_RESIDUE_H
9 #define IMPATOM_RESIDUE_H
10 
11 #include <IMP/atom/atom_config.h>
12 #include "atom_macros.h"
13 #include "Hierarchy.h"
14 #include "Chain.h"
15 
16 #include <IMP/base_types.h>
17 #include <IMP/kernel/Particle.h>
18 #include <IMP/kernel/Model.h>
19 #include <IMP/Decorator.h>
20 
21 IMPATOM_BEGIN_NAMESPACE
22 
23 /* each static must be on a separate line because of MSVC bug C2487:
24  see http://support.microsoft.com/kb/127900/
25 */
26 typedef Key<IMP_RESIDUE_TYPE_INDEX, true> ResidueType;
28 
29 /** \class IMP::atom::ResidueType
30  \brief The type for a residue.
31 
32  A given residue is either a Residue::LIGAND, Residue::AMINOACID,
33  or Residue::NUCLEICACID.
34 
35  The standard residue types are provided with names like
36  IMP::atom::GLY. New types can be added simply by creating an
37  instance of ResidueType("my_residue_name"). All user-added
38  residues are assumed to be ligands.
39 
40  \see Residue
41 */
42 
43 /** Unknown residue */
44 IMPATOMEXPORT extern const ResidueType UNK;
45 /** See ResidueType
46  glycine G*/
47 IMPATOMEXPORT extern const ResidueType GLY;
48 #ifndef IMP_DOXYGEN
49 /* Code currently assumes that all indices between GLY.get_index()
50  and TRP.get_index() being amino acids */
51 /** alanine A*/
52 IMPATOMEXPORT extern const ResidueType ALA;
53 /** valine V*/
54 IMPATOMEXPORT extern const ResidueType VAL;
55 /** leucine L*/
56 IMPATOMEXPORT extern const ResidueType LEU;
57 /** isoleucine I*/
58 IMPATOMEXPORT extern const ResidueType ILE;
59 /** serine S*/
60 IMPATOMEXPORT extern const ResidueType SER;
61 /** threonine T*/
62 IMPATOMEXPORT extern const ResidueType THR;
63 /** cystein C*/
64 IMPATOMEXPORT extern const ResidueType CYS;
65 /** metthionine M*/
66 IMPATOMEXPORT extern const ResidueType MET;
67 /** proline P*/
68 IMPATOMEXPORT extern const ResidueType PRO;
69 /** aspartic acid D*/
70 IMPATOMEXPORT extern const ResidueType ASP;
71 /** asparagine N*/
72 IMPATOMEXPORT extern const ResidueType ASN;
73 /** glutamine Q*/
74 IMPATOMEXPORT extern const ResidueType GLU;
75 /** glutamic acid E*/
76 IMPATOMEXPORT extern const ResidueType GLN;
77 /** lysine K*/
78 IMPATOMEXPORT extern const ResidueType LYS;
79 /** arginine N*/
80 IMPATOMEXPORT extern const ResidueType ARG;
81 /** histidine H*/
82 IMPATOMEXPORT extern const ResidueType HIS;
83 /** phynylaline F*/
84 IMPATOMEXPORT extern const ResidueType PHE;
85 /** tyrosine Y */
86 IMPATOMEXPORT extern const ResidueType TYR;
87 /** tryptophan W */
88 IMPATOMEXPORT extern const ResidueType TRP;
89 /** ACE */
90 IMPATOMEXPORT extern const ResidueType ACE;
91 /** end group */
92 IMPATOMEXPORT extern const ResidueType NH2;
93 /* Code currently assumes that all indices between ADE.get_index()
94  and DTHY.get_index() being nucleic acid */
95 /** adenine (RNA) */
96 IMPATOMEXPORT extern const ResidueType ADE;
97 /** uracil (RNA) */
98 IMPATOMEXPORT extern const ResidueType URA;
99 /** cytosine (RNA) */
100 IMPATOMEXPORT extern const ResidueType CYT;
101 /** guanine (RNA) */
102 IMPATOMEXPORT extern const ResidueType GUA;
103 /** thymine (RNA) */
104 IMPATOMEXPORT extern const ResidueType THY;
105 /** adenine (DNA) */
106 IMPATOMEXPORT extern const ResidueType DADE;
107 /** uracil (DNA) */
108 IMPATOMEXPORT extern const ResidueType DURA;
109 /** cytosine (DNA) */
110 IMPATOMEXPORT extern const ResidueType DCYT;
111 /** guanine (DNA) */
112 IMPATOMEXPORT extern const ResidueType DGUA;
113 /** thymine (DNA) */
114 IMPATOMEXPORT extern const ResidueType DTHY;
115 
116 // All further residues (including user-added residues) are ligands
117 
118 /** water molecule */
119 IMPATOMEXPORT extern const ResidueType HOH;
120 /** heme */
121 IMPATOMEXPORT extern const ResidueType HEME;
122 #endif
123 /*@}*/
124 
125 //! A decorator for a residue.
126 /**
127  As with the Atom, the names of residues may be expanded
128  dynamically. This can be easily done in an analogous manner when we
129  need it.
130  \ingroup hierarchy
131  \ingroup decorators
132  */
133 class IMPATOMEXPORT Residue : public Hierarchy {
134  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
135  ResidueType t = UNK, int index = -1,
136  int insertion_code = 32) {
137  m->add_attribute(get_residue_type_key(), pi, t.get_index());
138  m->add_attribute(get_index_key(), pi, index);
139  m->add_attribute(get_insertion_code_key(), pi, insertion_code);
140  // insertion code 32 is for space
141  if (!Hierarchy::get_is_setup(m, pi)) {
143  }
144  Residue ret(m, pi);
145  ret.set_residue_type(t);
146  }
147  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
148  const Residue &o) {
149  do_setup_particle(m, pi, o.get_residue_type(), o.get_index(),
150  o.get_insertion_code());
151  }
152 
153  public:
155  IMP_DECORATOR_SETUP_3(Residue, ResidueType, t, int, index, int,
156  insertion_code);
157  /** Setup the particle as a Residue with the passed type and index. */
161 
162  static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex pi) {
163  return m->get_has_attribute(get_residue_type_key(), pi) &&
164  m->get_has_attribute(get_index_key(), pi) &&
165  m->get_has_attribute(get_insertion_code_key(), pi) &&
167  }
168 
169  ResidueType get_residue_type() const {
170  return ResidueType(get_model()->get_attribute(get_residue_type_key(),
171  get_particle_index()));
172  }
173 
174  //! Update the stored ResidueType and the atom::Hierarchy::Name.
175  void set_residue_type(ResidueType t);
176 
177  bool get_is_protein() const {
178  return get_residue_type().get_index() < ADE.get_index();
179  }
180 
181  bool get_is_dna() const {
182  return get_residue_type().get_index() >= DADE.get_index() &&
183  get_residue_type().get_index() <= DTHY.get_index();
184  }
185 
186  bool get_is_rna() const {
187  return get_residue_type().get_index() >= ADE.get_index() &&
188  get_residue_type().get_index() < DADE.get_index();
189  }
190 
191  //! The residues index in the chain
192  IMP_DECORATOR_GET_SET(index, get_index_key(), Int, Int);
193 
194  char get_insertion_code() const {
195  return char(get_model()->get_attribute(get_insertion_code_key(),
196  get_particle_index()));
197  }
198 
199  void set_insertion_code(char insertion_code) {
200  return get_model()->set_attribute(get_insertion_code_key(),
201  get_particle_index(), insertion_code);
202  }
203 
204  static IntKey get_index_key();
205 
206  static IntKey get_residue_type_key();
207 
208  static IntKey get_insertion_code_key();
209 };
210 
211 IMP_DECORATORS(Residue, Residues, Hierarchies);
212 
213 /** See Residue
214 
215  Return the residue from the same chain with one
216  higher index, or Hierarchy().
217 
218  \note Currently, this function only works if
219  the parent of rd is the chain. This should be fixed
220  later. Ask if you need it.
221 
222  The return type is Hierarchy since the particle
223  representing the next residue might not
224  be a Residue particle.
225  */
226 IMPATOMEXPORT Hierarchy get_next_residue(Residue rd);
227 
228 /** See Residue
229 
230  Return the residue from the same chain with one
231  lower index, or Hierarchy().
232  \see get_next_residue
233  */
234 IMPATOMEXPORT Hierarchy get_previous_residue(Residue rd);
235 
236 /** Get the residue type from the 1-letter amino acid
237  code.
238  \throw ValueException if an invalid character is passed.
239 */
240 IMPATOMEXPORT ResidueType get_residue_type(char c);
241 
242 /** Get the 1-letter amino acid code from the residue type.
243 */
244 IMPATOMEXPORT char get_one_letter_code(ResidueType c);
245 
246 IMPATOM_END_NAMESPACE
247 
248 #endif /* IMPATOM_RESIDUE_H */
Import IMP/kernel/Decorator.h in the namespace.
#define IMP_DECORATOR_SETUP_2(Name, FirstArgumentType, first_argument_name,SecondArgumentType, second_argument_name)
A base class for Keys.
Definition: kernel/Key.h:46
Import IMP/kernel/base_types.h in the namespace.
#define IMP_DECORATOR_METHODS(Name, Parent)
Model * get_model() const
Returns the Model containing the particle.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex p)
char get_one_letter_code(ResidueType c)
Decorator for helping deal with a hierarchy of molecules.
Int get_index() const
The residues index in the chain.
Definition: Residue.h:192
The standard decorator for manipulating molecular structures.
static Hierarchy setup_particle(kernel::Model *m, kernel::ParticleIndex pi, kernel::ParticleIndexesAdaptor children=kernel::ParticleIndexesAdaptor())
const ResidueType UNK
The type for a residue.
Hierarchy get_previous_residue(Residue rd)
const ResidueType GLY
void set_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
Store the chain ID.
Storage of a model, its restraints, constraints and particles.
Classes to handle individual model particles.
Various important macros for implementing decorators.
A decorator for a residue.
Definition: Residue.h:133
#define IMP_DECORATOR_SETUP_3(Name, FirstArgumentType, first_argument_name,SecondArgumentType, second_argument_name,ThirdArgumentType, third_argument_name)
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
int Int
Basic integer value.
Definition: base/types.h:35
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
void set_residue_type(ResidueType t)
Update the stored ResidueType and the atom::Hierarchy::Name.
#define IMP_DECORATOR_GET_SET(name, AttributeKey, Type, ReturnType)
Define methods for getting and setting a particular simple field.
Hierarchy get_next_residue(Residue rd)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
Class for storing model, its restraints, constraints, and particles.