IMP  2.2.1
The Integrative Modeling Platform
atom/Atom.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/Atom.h \brief Simple atom decorator.
3  *
4  * Copyright 2007-2014 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPATOM_ATOM_H
9 #define IMPATOM_ATOM_H
10 
11 #include <IMP/atom/atom_config.h>
12 #include "atom_macros.h"
13 #include "Residue.h"
14 #include "Hierarchy.h"
15 #include "element.h"
16 #include <IMP/core/utility.h>
17 #include <IMP/core/XYZ.h>
18 
19 #include <IMP/base_types.h>
20 #include <IMP/kernel/Particle.h>
21 #include <IMP/kernel/Model.h>
22 
23 #include <vector>
24 #include <deque>
25 
26 IMPATOM_BEGIN_NAMESPACE
27 
28 typedef Key<IMP_ATOM_TYPE_INDEX, false> AtomType;
30 
31 /** \class IMP::atom::AtomType
32  \brief The type of an atom.
33 
34  The standard Atom names in %IMP are derived from the PDB names as follows:
35  - the AtomType of a protein, DNA or RNA atom is the AtomType
36  created from the PDB atom name string with spaces removed. For
37  example, a protein C-alpha has the name AtomType("CA").
38  - the AtomType for a hetero (HETATM) atom is the AtomType created by
39  prefixing "HET:" to the PBD atom name string (this time without
40  spaces removed). For example, a calcium atom is AtomType("HET:CA ").
41 
42  We provide an AtomType instance for each of the standard PDB %atom types.
43  These have names such as IMP::atom::AT_N. The full list is elided for
44  readability.
45 
46  An AtomType implies an element (and hence a mass). While we have the
47  associations set up for protein, DNA and RNA atoms, it may be necessary
48  to add them for hetero atoms. You can use the add_atom_type() function
49  to do this.
50 
51  All atoms have the mass stored internally using a Mass decorator.
52 
53  \see IMP::atom::Atom
54 */
55 
56 /* each static must be on a separate line because of MSVC bug C2487:
57  see http://support.microsoft.com/kb/127900/
58 */
59 /** See AtomType */
60 IMPATOMEXPORT extern const AtomType AT_UNKNOWN;
61 /** See AtomType */
62 IMPATOMEXPORT extern const AtomType AT_N;
63 /** See AtomType */
64 IMPATOMEXPORT extern const AtomType AT_CA;
65 #ifndef IMP_DOXYGEN
66 /** See AtomType */
67 IMPATOMEXPORT extern const AtomType AT_C;
68 /** See AtomType */
69 IMPATOMEXPORT extern const AtomType AT_O;
70 /** See AtomType */
71 IMPATOMEXPORT extern const AtomType AT_H;
72 /** See AtomType */
73 IMPATOMEXPORT extern const AtomType AT_H1;
74 /** See AtomType */
75 IMPATOMEXPORT extern const AtomType AT_H2;
76 /** See AtomType */
77 IMPATOMEXPORT extern const AtomType AT_H3;
78 /** See AtomType */
79 IMPATOMEXPORT extern const AtomType AT_HA;
80 /** See AtomType */
81 IMPATOMEXPORT extern const AtomType AT_HA1;
82 /** See AtomType */
83 IMPATOMEXPORT extern const AtomType AT_HA2;
84 /** See AtomType */
85 IMPATOMEXPORT extern const AtomType AT_HA3;
86 /** See AtomType */
87 IMPATOMEXPORT extern const AtomType AT_CB;
88 /** See AtomType */
89 IMPATOMEXPORT extern const AtomType AT_HB;
90 /** See AtomType */
91 IMPATOMEXPORT extern const AtomType AT_HB1;
92 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HB2;
93 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HB3;
94 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_OXT;
95 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_CH3;
96 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_CH;
97 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_CG;
98 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_CG1;
99 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_CG2;
100 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HG;
101 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HG1;
102 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HG2;
103 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HG3;
104 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HG11;
105 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HG21;
106 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HG31;
107 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HG12;
108 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HG13;
109 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HG22;
110 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HG23;
111 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HG32;
112 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_OG;
113 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_OG1;
114 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_SG;
115 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_CD;
116 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_CD1;
117 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_CD2;
118 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HD;
119 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HD1;
120 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HD2;
121 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HD3;
122 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HD11;
123 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HD21;
124 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HD31;
125 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HD12;
126 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HD13;
127 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HD22;
128 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HD23;
129 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HD32;
130 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_SD;
131 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_OD1;
132 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_OD2;
133 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_ND1;
134 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_ND2;
135 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_CE;
136 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_CE1;
137 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_CE2;
138 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_CE3;
139 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HE;
140 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HE1;
141 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HE2;
142 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HE3;
143 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HE21;
144 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HE22;
145 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_OE1;
146 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_OE2;
147 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_NE;
148 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_NE1;
149 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_NE2;
150 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_CZ;
151 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_CZ2;
152 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_CZ3;
153 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_NZ;
154 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HZ;
155 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HZ1;
156 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HZ2;
157 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HZ3;
158 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_CH2;
159 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_NH1;
160 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_NH2;
161 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_OH;
162 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HH;
163 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HH11;
164 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HH21;
165 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HH2;
166 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HH12;
167 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HH22;
168 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HH13;
169 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HH23;
170 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HH33;
171 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_P;
172 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_OP1;
173 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_OP2;
174 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_OP3;
175 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_O5p;
176 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_C5p;
177 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H5p;
178 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H5pp;
179 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_C4p;
180 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H4p;
181 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_O4p;
182 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_C1p;
183 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H1p;
184 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_C3p;
185 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H3p;
186 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_O3p;
187 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_C2p;
188 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H2p;
189 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H2pp;
190 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_O2p;
191 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_HO2p;
192 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_N9;
193 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_C8;
194 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H8;
195 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_N7;
196 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_C5;
197 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_C4;
198 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_N3;
199 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_C2;
200 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_N1;
201 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_C6;
202 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_N6;
203 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H61;
204 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H62;
205 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_O6;
206 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_N2;
207 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_NT;
208 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H21;
209 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H22;
210 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H6;
211 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H5;
212 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_O2;
213 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_N4;
214 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H41;
215 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H42;
216 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_O4;
217 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_C7;
218 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H71;
219 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H72;
220 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_H73;
221 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_O1A;
222 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_O2A;
223 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_O3A;
224 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_O1B;
225 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_O2B;
226 /** See AtomType */ IMPATOMEXPORT extern const AtomType AT_O3B;
227 #endif
228 
229 //! A decorator for a particle representing an atom.
230 /** Atoms always are Mass particles.
231  \ingroup hierarchy
232  \see Hierarchy
233  */
234 class IMPATOMEXPORT Atom : public Hierarchy {
235  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
236  Atom o);
237  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
238  AtomType t);
239 
240  public:
243  /** Add the required attributes using the passed AtomType. */
245 
246  /** return true if the particle has the needed attributes */
248  return m->get_has_attribute(get_atom_type_key(), pi) &&
250  }
251 
252  AtomType get_atom_type() const {
253  return AtomType(
254  get_model()->get_attribute(get_atom_type_key(), get_particle_index()));
255  }
256 
257  //! Set the name and corresponding element and mass
258  void set_atom_type(AtomType t);
259 
260  //! get element
262  return Element(
263  get_model()->get_attribute(get_element_key(), get_particle_index()));
264  }
265 #ifndef IMP_DOXYGEN
266  void set_element(Element e);
267 #endif
268 
269  double get_occupancy() const {
270  if (!get_model()->get_has_attribute(get_occupancy_key(),
271  get_particle_index())) {
272  return 1;
273  } else {
274  return get_model()->get_attribute(get_occupancy_key(),
276  }
277  }
278 
279  void set_occupancy(double occupancy) {
280  if (!get_model()->get_has_attribute(get_occupancy_key(),
281  get_particle_index())) {
282  get_model()->add_attribute(get_occupancy_key(), get_particle_index(),
283  occupancy);
284  } else {
285  get_model()->set_attribute(get_occupancy_key(), get_particle_index(),
286  occupancy);
287  }
288  }
289 
290  double get_temperature_factor() const {
291  if (!get_model()->get_has_attribute(get_temperature_factor_key(),
292  get_particle_index())) {
293  return 0;
294  } else {
295  return get_model()->get_attribute(get_temperature_factor_key(),
297  }
298  }
299 
300  void set_temperature_factor(double tempFactor) {
301  if (!get_model()->get_has_attribute(get_temperature_factor_key(),
302  get_particle_index())) {
303  get_model()->add_attribute(get_temperature_factor_key(),
304  get_particle_index(), tempFactor);
305  } else {
306  get_model()->set_attribute(get_temperature_factor_key(),
307  get_particle_index(), tempFactor);
308  }
309  }
310 
311  /** @name The atom index in the input file
312  This index is not necessarily unique over any particular
313  set of atoms and so should never be used as an atom identifier
314  except during I/O.
315  @{
316  */
317  IMP_DECORATOR_GET_SET_OPT(input_index, get_input_index_key(), Int, Int, -1);
318  /* @}*/
319 
320  /** @name Keys
321  These methods provide access to the various keys used to store
322  things in the Atom. These can be used if you want to
323  use an attribute to search a set of particles.
324  @{
325  */
326  static IntKey get_atom_type_key();
327 
328  static IntKey get_element_key();
329 
330  static IntKey get_input_index_key();
331 
332  static FloatKey get_occupancy_key();
333 
334  static FloatKey get_temperature_factor_key();
335  //! @}
336 };
337 
338 IMP_DECORATORS(Atom, Atoms, Hierarchies);
339 
340 #ifdef SWIG
341 class Residue;
342 #endif
343 
344 //! Return the Residue containing this atom
345 /** The atom must be part of a molecular hierarchy.
346 
347  \throw ValueException if no residue is found, unless
348  nothrow is true.
349 
350  See Atom
351  See Residue
352  See Hierarchy
353  */
354 IMPATOMEXPORT Residue get_residue(Atom d, bool nothrow = false);
355 
356 //! Return a particle atom from the residue
357 /** The residue must be part of a molecular hierarchy.
358  See Atom
359  See Residue
360  See Hierarchy
361  */
362 IMPATOMEXPORT Atom get_atom(Residue rd, AtomType at);
363 
364 //! Create a new AtomType
365 /** This creates a new AtomType (returned) and sets up the mapping
366  between the AtomType and the proper element.
367  \note This method has not been tested. If you use it, please
368  write a test and remove this comment.
369  See AtomType
370  \see atom_type_exists()
371 */
372 IMPATOMEXPORT AtomType add_atom_type(std::string name, Element e);
373 
374 IMPATOMEXPORT Element get_element_for_atom_type(AtomType at);
375 
376 //! Return true if that atom type already exists.
377 IMPATOMEXPORT bool get_atom_type_exists(std::string name);
378 
379 IMPATOM_END_NAMESPACE
380 
381 #endif /* IMPATOM_ATOM_H */
AtomType add_atom_type(std::string name, Element e)
Create a new AtomType.
Various important functionality for implementing decorators.
ParticleIndex get_particle_index() const
Define the elements used in IMP.
Import IMP/kernel/base_types.h in the namespace.
Element get_element() const
get element
Definition: atom/Atom.h:261
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex pi)
Definition: atom/Atom.h:247
Key< 1, true > IntKey
The type used to identify int attributes in the Particles.
const AtomType AT_CA
#define IMP_DECORATOR_METHODS(Name, Parent)
#define IMP_DECORATOR_GET_SET_OPT(name, AttributeKey, Type, ReturnType, default_value)
Define methods for getting and setting an optional simple field.
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)
The type of an atom.
Atom get_atom(Residue rd, AtomType at)
Return a particle atom from the residue.
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
Simple xyz decorator.
const AtomType AT_UNKNOWN
Decorator for helping deal with a hierarchy of molecules.
bool get_atom_type_exists(std::string name)
Return true if that atom type already exists.
The standard decorator for manipulating molecular structures.
A decorator for a particle representing an atom.
Definition: atom/Atom.h:234
A decorator for Residues.
void set_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
const AtomType AT_N
Storage of a model, its restraints, constraints and particles.
Classes to handle individual model particles.
Various important macros for implementing decorators.
Residue get_residue(Atom d, bool nothrow=false)
Return the Residue containing this atom.
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
int Int
Basic integer value.
Definition: base/types.h:35
Element
The various elements currently supported/known.
Definition: element.h:23
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
Key< 0, true > FloatKey
The type used to identify float attributes in the Particles.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:72