IMP  2.3.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-2014 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 //! cysteine C
64 IMPATOMEXPORT extern const ResidueType CYS;
65 //! methionine 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 //! phenylalanine 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 
126 //! A decorator for a residue.
127 /**
128  As with the Atom, the names of residues may be expanded
129  dynamically. This can be easily done in an analogous manner when we
130  need it.
131  \ingroup hierarchy
132  \ingroup decorators
133  */
134 class IMPATOMEXPORT Residue : public Hierarchy {
135  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
136  ResidueType t = UNK, int index = -1,
137  int insertion_code = 32) {
138  m->add_attribute(get_residue_type_key(), pi, t.get_index());
139  m->add_attribute(get_index_key(), pi, index);
140  m->add_attribute(get_insertion_code_key(), pi, insertion_code);
141  // insertion code 32 is for space
142  if (!Hierarchy::get_is_setup(m, pi)) {
144  }
145  Residue ret(m, pi);
146  ret.set_residue_type(t);
147  }
148  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
149  const Residue &o) {
150  do_setup_particle(m, pi, o.get_residue_type(), o.get_index(),
151  o.get_insertion_code());
152  }
153 
154  public:
156  IMP_DECORATOR_SETUP_3(Residue, ResidueType, t, int, index, int,
157  insertion_code);
158  /** Setup the particle as a Residue with the passed type and index. */
162 
163  static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex pi) {
164  return m->get_has_attribute(get_residue_type_key(), pi) &&
165  m->get_has_attribute(get_index_key(), pi) &&
166  m->get_has_attribute(get_insertion_code_key(), pi) &&
168  }
169 
170  ResidueType get_residue_type() const {
171  return ResidueType(get_model()->get_attribute(get_residue_type_key(),
172  get_particle_index()));
173  }
174 
175  //! Update the stored ResidueType and the atom::Hierarchy::Name.
176  void set_residue_type(ResidueType t);
177 
178  bool get_is_protein() const {
179  return get_residue_type().get_index() < ADE.get_index();
180  }
181 
182  bool get_is_dna() const {
183  return get_residue_type().get_index() >= DADE.get_index() &&
184  get_residue_type().get_index() <= DTHY.get_index();
185  }
186 
187  bool get_is_rna() const {
188  return get_residue_type().get_index() >= ADE.get_index() &&
189  get_residue_type().get_index() < DADE.get_index();
190  }
191 
192  //! The residues index in the chain
193  IMP_DECORATOR_GET_SET(index, get_index_key(), Int, Int);
194 
195  char get_insertion_code() const {
196  return char(get_model()->get_attribute(get_insertion_code_key(),
197  get_particle_index()));
198  }
199 
200  void set_insertion_code(char insertion_code) {
201  return get_model()->set_attribute(get_insertion_code_key(),
202  get_particle_index(), insertion_code);
203  }
204 
205  static IntKey get_index_key();
206 
207  static IntKey get_residue_type_key();
208 
209  static IntKey get_insertion_code_key();
210 };
211 
212 IMP_DECORATORS(Residue, Residues, Hierarchies);
213 
214 //! Return the residue from the same chain with one higher index.
215 /** If no such residue exists, return Hierarchy().
216 
217  \see Residue
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 //! Return the residue from the same chain with one lower index.
229 /** If no such residue exists, return Hierarchy().
230  \see get_next_residue
231  */
232 IMPATOMEXPORT Hierarchy get_previous_residue(Residue rd);
233 
234 //! Get the residue type from the 1-letter amino acid code.
235 /** \throw ValueException if an invalid character is passed.
236  */
237 IMPATOMEXPORT ResidueType get_residue_type(char c);
238 
239 //! Get the 1-letter amino acid code from the residue type.
240 IMPATOMEXPORT char get_one_letter_code(ResidueType c);
241 
242 
243 //! Get the mass from the residue type.
244 IMPATOMEXPORT double get_mass(ResidueType c);
245 
246 
247 IMPATOM_END_NAMESPACE
248 
249 #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)
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
A base class for Keys.
Definition: kernel/Key.h:46
Import IMP/kernel/base_types.h in the namespace.
double get_mass(ResidueType c)
Get the mass from the residue type.
#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)
char get_one_letter_code(ResidueType c)
Get the 1-letter amino acid code from the residue type.
Decorator for helping deal with a hierarchy of molecules.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
Definition: value_macros.h:23
Int get_index() const
The residues index in the chain.
Definition: Residue.h:193
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
Unknown residue.
The type for a residue.
Hierarchy get_previous_residue(Residue rd)
Return the residue from the same chain with one lower index.
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. (Note that implementation of inline functions in in int...
Various important macros for implementing decorators.
A decorator for a residue.
Definition: Residue.h:134
#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: 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)
Return the residue from the same chain with one higher index.
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
ResidueType get_residue_type(char c)
Get the residue type from the 1-letter amino acid code.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73