IMP logo
IMP Reference Guide  2.6.2
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-2016 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/Particle.h>
21 #include <IMP/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 PDB 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(Model *m, ParticleIndex pi,
236  Atom o);
237  static void do_setup_particle(Model *m, 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 */
247  static bool get_is_setup(Model *m, ParticleIndex pi) {
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.
Define the elements used in IMP.
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Definition: Decorator.h:188
Basic types used by IMP.
Element get_element() const
get element
Definition: atom/Atom.h:261
const AtomType AT_CA
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
#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.
Definition: Decorator.h:191
Storage of a model, its restraints, constraints and particles.
The type of an atom.
Atom get_atom(Residue rd, AtomType at)
Return a particle atom from the residue.
Simple XYZ decorator.
Key< 1, true > IntKey
The type used to identify int attributes in the Particles.
Definition: base_types.h:36
const AtomType AT_UNKNOWN
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
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.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
Definition: value_macros.h:23
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
The standard decorator for manipulating molecular structures.
A decorator for a particle representing an atom.
Definition: atom/Atom.h:234
Hierarchy get_residue(Hierarchy mhd, unsigned int index)
Get the residue with the specified index.
A decorator for Residues.
Key< 0, true > FloatKey
The type used to identify float attributes in the Particles.
Definition: base_types.h:32
void set_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
const AtomType AT_N
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
Various important macros for implementing decorators.
static bool get_is_setup(Model *m, ParticleIndex p)
Check if the particle has the needed attributes for a cast to succeed.
#define IMP_DECORATOR_METHODS(Name, Parent)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
int Int
Basic integer value.
Definition: types.h:35
Element
The various elements currently supported/known.
Definition: element.h:23
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
static bool get_is_setup(Model *m, ParticleIndex pi)
Definition: atom/Atom.h:247