IMP  2.4.0
The Integrative Modeling Platform
element.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/element.h \brief Define the elements used in \imp.
3  *
4  * Copyright 2007-2015 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPATOM_ELEMENT_H
9 #define IMPATOM_ELEMENT_H
10 
11 #include <IMP/atom/atom_config.h>
12 #include <IMP/base_types.h>
13 
14 #include <IMP/base/log.h>
15 #include <IMP/base/exception.h>
16 #include <boost/unordered_map.hpp>
17 
18 #include <string>
19 
20 IMPATOM_BEGIN_NAMESPACE
21 
22 //! The various elements currently supported/known.
23 enum Element {
24  UNKNOWN_ELEMENT = 0,
25 #ifndef IMP_DOXYGEN
26  OH = -1,
27  H2O = -2,
28 #endif
29  H = 1,
30  He = 2,
31  Li = 3,
32  Be = 4,
33  B = 5,
34  C = 6,
35  N = 7,
36  O = 8,
37  F = 9,
38  Ne = 10,
39  Na = 11,
40  Mg = 12,
41  Al = 13,
42  Si = 14,
43  P = 15,
44  S = 16,
45  Cl = 17,
46  Ar = 18,
47  K = 19,
48  Ca = 20,
49  Sc = 21,
50  Ti = 22,
51  V = 23,
52  Cr = 24,
53  Mn = 25,
54  Fe = 26,
55  Co = 27,
56  Ni = 28,
57  Cu = 29,
58  Zn = 30,
59  Ga = 31,
60  Ge = 32,
61  As = 33,
62  Se = 34,
63  Br = 35,
64  Kr = 36,
65  Rb = 37,
66  Sr = 38,
67  Y = 39,
68  Zr = 40,
69  Nb = 41,
70  Mo = 42,
71  Tc = 43,
72  Ru = 44,
73  Rh = 45,
74  Pd = 46,
75  Ag = 47,
76  Cd = 48,
77  In = 49,
78  Sn = 50,
79  Sb = 51,
80  Te = 52,
81  I = 53,
82  Xe = 54,
83  Cs = 55,
84  Ba = 56,
85  La = 57,
86  Ce = 58,
87  Pr = 59,
88  Nd = 60,
89  Pm = 61,
90  Sm = 62,
91  Eu = 63,
92  Gd = 64,
93  Tb = 65,
94  Dy = 66,
95  Ho = 67,
96  Er = 68,
97  Tm = 69,
98  Yb = 70,
99  Lu = 71,
100  Hf = 72,
101  Ta = 73,
102  W = 74,
103  Re = 75,
104  Os = 76,
105  Ir = 77,
106  Pt = 78,
107  Au = 79,
108  Hg = 80,
109  Tl = 81,
110  Pb = 82,
111  Bi = 83,
112  Po = 84,
113  At = 85,
114  Rn = 86,
115  Fr = 87,
116  Ra = 88,
117  Ac = 89,
118  Th = 90,
119  Pa = 91,
120  U = 92,
121  Np = 93,
122  Pu = 94,
123  Am = 95,
124  Cm = 96,
125  Bk = 97,
126  Cf = 98,
127  Es = 99,
128  Fm = 100,
129  Md = 101,
130  No = 102,
131  Lr = 103,
132  Db = 104,
133  Jl = 105,
134  Rf = 106
135 #ifndef IMP_DOXYGEN
136  ,
137  NUMBER_OF_ELEMENTS = 107
138 #endif
139 };
140 
141 #ifndef IMP_DOXYGEN
142 inline size_t hash_value(Element e) { return e; }
143 #endif
144 
145 /** Class to translate between element symbols, names and masses.*/
146 class IMPATOMEXPORT ElementTable {
147  public:
148  ElementTable();
149 
150  //! get element from the string name (PDB columns 77-78)
151  Element get_element(const std::string& s) const;
152 
153  //! get string name for Element
154  std::string get_name(Element e) const;
155 
156  //! get mass for Element
157  Float get_mass(Element e) const { return mass_[e]; }
158 
159  private:
160  struct ElementString {
161  std::string name;
162  Element e;
163  };
164 
165  static ElementString element_strings_[];
166  static Float mass_[];
167  static boost::unordered_map<std::string, Element> string_2_element_;
168  static boost::unordered_map<Element, std::string> element_2_string_;
169 };
170 
171 IMPATOMEXPORT ElementTable& get_element_table();
172 
173 IMPATOM_END_NAMESPACE
174 
175 #endif /* IMPATOM_ELEMENT_H */
Import IMP/kernel/base_types.h in the namespace.
Exception definitions and assertions.
Float get_mass(Element e) const
get mass for Element
Definition: element.h:157
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
Logging and error reporting support.
Element
The various elements currently supported/known.
Definition: element.h:23