IMP logo
Residue.h
Go to the documentation of this file.
1 /**
2  * \file Residue.h \brief A decorator for Residues.
3  *
4  * Copyright 2007-2012 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPATOM_RESIDUE_H
9 #define IMPATOM_RESIDUE_H
10 
11 #include "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/Particle.h>
18 #include <IMP/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 
27 IMP_DECLARE_KEY_TYPE(ResidueType, IMP_RESIDUE_TYPE_INDEX);
28 /** \class ResidueType
29  \brief The type for a residue.
30 
31  A given residue is either a Residue::LIGAND, Residue::AMINOACID,
32  or Residue::NUCLEICACID.
33 
34  The standard residue types are provided with names like
35  IMP::atom::GLY. New types can be added simply by creating an
36  instance of ResidueType("my_residue_name"). All user-added
37  residues are assumed to be ligands.
38 
39  \see Residue
40 */
41 
42 /** Unknown residue */
43 IMPATOMEXPORT extern const ResidueType UNK;
44 /** \relatesalso ResidueType
45  glycein G*/
46 IMPATOMEXPORT extern const ResidueType GLY;
47 #ifndef IMP_DOXYGEN
48 /* Code currently assumes that all indices between GLY.get_index()
49  and TRP.get_index() being amino acids */
50 /** alanine A*/
51 IMPATOMEXPORT extern const ResidueType ALA;
52 /** valine V*/
53 IMPATOMEXPORT extern const ResidueType VAL;
54 /** leucine L*/
55 IMPATOMEXPORT extern const ResidueType LEU;
56 /** isoleucine I*/
57 IMPATOMEXPORT extern const ResidueType ILE;
58 /** serine S*/
59 IMPATOMEXPORT extern const ResidueType SER;
60 /** threonine T*/
61 IMPATOMEXPORT extern const ResidueType THR;
62 /** cystein C*/
63 IMPATOMEXPORT extern const ResidueType CYS;
64 /** metthionine M*/
65 IMPATOMEXPORT extern const ResidueType MET;
66 /** proline P*/
67 IMPATOMEXPORT extern const ResidueType PRO;
68 /** aspartic acid D*/
69 IMPATOMEXPORT extern const ResidueType ASP;
70 /** asparagine N*/
71 IMPATOMEXPORT extern const ResidueType ASN;
72 /** glutamine Q*/
73 IMPATOMEXPORT extern const ResidueType GLU;
74 /** glutamic acid E*/
75 IMPATOMEXPORT extern const ResidueType GLN;
76 /** lysine K*/
77 IMPATOMEXPORT extern const ResidueType LYS;
78 /** arginine N*/
79 IMPATOMEXPORT extern const ResidueType ARG;
80 /** histidine H*/
81 IMPATOMEXPORT extern const ResidueType HIS;
82 /** phynylaline F*/
83 IMPATOMEXPORT extern const ResidueType PHE;
84 /** tyrosine Y */
85 IMPATOMEXPORT extern const ResidueType TYR;
86 /** tryptophan W */
87 IMPATOMEXPORT extern const ResidueType TRP;
88 /** ACE */
89 IMPATOMEXPORT extern const ResidueType ACE;
90 /** end group */
91 IMPATOMEXPORT extern const ResidueType NH2;
92 /* Code currently assumes that all indices between ADE.get_index()
93  and DTHY.get_index() being nucleic acid */
94 /** adenine (RNA) */
95 IMPATOMEXPORT extern const ResidueType ADE;
96 /** uracil (RNA) */
97 IMPATOMEXPORT extern const ResidueType URA;
98 /** cytosine (RNA) */
99 IMPATOMEXPORT extern const ResidueType CYT;
100 /** guanine (RNA) */
101 IMPATOMEXPORT extern const ResidueType GUA;
102 /** thymine (RNA) */
103 IMPATOMEXPORT extern const ResidueType THY;
104 /** adenine (DNA) */
105 IMPATOMEXPORT extern const ResidueType DADE;
106 /** uracil (DNA) */
107 IMPATOMEXPORT extern const ResidueType DURA;
108 /** cytosine (DNA) */
109 IMPATOMEXPORT extern const ResidueType DCYT;
110 /** guanine (DNA) */
111 IMPATOMEXPORT extern const ResidueType DGUA;
112 /** thymine (DNA) */
113 IMPATOMEXPORT extern const ResidueType DTHY;
114 
115 // All further residues (including user-added residues) are ligands
116 
117 /** water molecule */
118 IMPATOMEXPORT extern const ResidueType HOH;
119 /** heme */
120 IMPATOMEXPORT extern const ResidueType HEME;
121 #endif
122 /*@}*/
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 {
135 public:
137  //! Add the required attributes to the particle and create a Residue
139  int index=-1, int insertion_code = 32) {
140  p->add_attribute(get_residue_type_key(), t.get_index());
141  p->add_attribute(get_index_key(), index);
142  p->add_attribute(get_insertion_code_key(), insertion_code);
143  // insertion code 32 is for space
144  if (!Hierarchy::particle_is_instance(p)) {
145  Hierarchy::setup_particle(p);
146  }
147  Residue ret(p);
148  ret.set_residue_type(t);
149  return ret;
150  }
151 
152  //! Copy data from the other Residue to the particle p
153  static Residue setup_particle(Particle *p, Residue o) {
154  return setup_particle(p, o.get_residue_type(),
155  o.get_index(),
156  o.get_insertion_code());
157  }
158 
159  static bool particle_is_instance(Particle *p) {
160  return p->has_attribute(get_residue_type_key())
161  && p->has_attribute(get_index_key())
162  && p->has_attribute(get_insertion_code_key())
163  && Hierarchy::particle_is_instance(p);
164  }
165 
166  ResidueType get_residue_type() const {
167  return ResidueType(get_particle()->get_value(get_residue_type_key()));
168  }
169 
170  //! Update the stored ResidueType and the atom::Hierarchy::Name.
171  void set_residue_type(ResidueType t);
172 
173  bool get_is_protein() const {
174  return get_residue_type().get_index() < ADE.get_index();
175  }
176 
177  bool get_is_dna() const {
178  return get_residue_type().get_index() >= DADE.get_index()
179  && get_residue_type().get_index() <= DTHY.get_index();
180  }
181 
182  bool get_is_rna() const {
183  return get_residue_type().get_index() >= ADE.get_index()
184  && get_residue_type().get_index() < DADE.get_index();
185  }
186 
187  //! The residues index in the chain
188  IMP_DECORATOR_GET_SET(index, get_index_key(),
189  Int, Int);
190 
191  char get_insertion_code() const {
192  return char(get_particle()->get_value(get_insertion_code_key()));
193  }
194 
195  void set_insertion_code(char insertion_code) {
196  return get_particle()->set_value(get_insertion_code_key(), insertion_code);
197  }
198 
199  static IntKey get_index_key();
200 
201  static IntKey get_residue_type_key();
202 
203  static IntKey get_insertion_code_key();
204 };
205 
206 IMP_DECORATORS(Residue,Residues, Hierarchies);
207 
208 /** Return the chain containing the residue.
209  \throw ValueException if no residue is found, unless
210  nothrow is true.
211  \relatesalso Residue */
212 IMPATOMEXPORT Chain get_chain(Residue rd, bool nothrow=false);
213 
214 /** \relatesalso Residue
215 
216  Return the residue from the same chain with one
217  higher index, or Hierarchy().
218 
219  \note Currently, this function only works if
220  the parent of rd is the chain. This should be fixed
221  later. Ask if you need it.
222 
223  The return type is Hierarchy since the particle
224  representing the next residue might not
225  be a Residue particle.
226  */
227 IMPATOMEXPORT Hierarchy get_next_residue(Residue rd);
228 
229 /** \relatesalso Residue
230 
231  Return the residue from the same chain with one
232  lower index, or Hierarchy().
233  \see get_next_residue
234  */
235 IMPATOMEXPORT Hierarchy get_previous_residue(Residue rd);
236 
237 /** Get the residue type from the 1-letter amino acid
238  code.
239  \throw ValueException if an invalid character is passed.
240 */
241 IMPATOMEXPORT ResidueType get_residue_type(char c);
242 
243 
244 /** Get the 1-letter amino acid code from the residue type.
245 */
246 IMPATOMEXPORT char get_one_letter_code(ResidueType c);
247 
248 IMPATOM_END_NAMESPACE
249 
250 #endif /* IMPATOM_RESIDUE_H */

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