IMP  2.0.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-2013 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/log.h>
15 #include <IMP/exception.h>
16 
17 #include <string>
18 #include <IMP/base/map.h>
19 
20 IMPATOM_BEGIN_NAMESPACE
21 
22 //! The various elements currently supported/known.
23 enum Element {UNKNOWN_ELEMENT=0,
24 #ifndef IMP_DOXYGEN
25  OH=-1, H2O=-2,
26 #endif
27  H= 1, He= 2, Li= 3, Be= 4, B= 5, C= 6, N= 7,
28  O= 8, F= 9, Ne= 10, Na= 11, Mg= 12, Al= 13, Si= 14,
29  P= 15, S= 16, Cl= 17, Ar= 18, K= 19, Ca= 20, Sc= 21,
30  Ti= 22, V= 23, Cr= 24, Mn= 25, Fe= 26, Co= 27, Ni= 28,
31  Cu= 29, Zn= 30, Ga= 31, Ge= 32, As= 33, Se= 34, Br= 35,
32  Kr= 36, Rb= 37, Sr= 38, Y= 39, Zr= 40, Nb= 41, Mo= 42,
33  Tc= 43, Ru= 44, Rh= 45, Pd= 46, Ag= 47, Cd= 48, In= 49,
34  Sn= 50, Sb= 51, Te= 52, I= 53, Xe= 54, Cs= 55, Ba= 56,
35  La= 57, Ce= 58, Pr= 59, Nd= 60, Pm= 61, Sm= 62, Eu= 63,
36  Gd= 64, Tb= 65, Dy= 66, Ho= 67, Er= 68, Tm= 69, Yb= 70,
37  Lu= 71, Hf= 72, Ta= 73, W= 74, Re= 75, Os= 76, Ir= 77,
38  Pt= 78, Au= 79, Hg= 80, Tl= 81, Pb= 82, Bi= 83, Po= 84,
39  At= 85, Rn= 86, Fr= 87, Ra= 88, Ac= 89, Th= 90, Pa= 91,
40  U= 92, Np= 93, Pu= 94, Am= 95, Cm= 96, Bk= 97, Cf= 98,
41  Es= 99, Fm= 100, Md= 101, No= 102, Lr= 103, Db= 104, Jl= 105,
42  Rf= 106
43 #ifndef IMP_DOXYGEN
44  , NUMBER_OF_ELEMENTS = 107
45 #endif
46 };
47 
48 #ifndef IMP_DOXYGEN
49 inline size_t hash_value(Element e) {
50  return e;
51 }
52 #endif
53 
54 /** Class to translate between element symbols, names and masses.*/
55 class IMPATOMEXPORT ElementTable {
56 public:
57  ElementTable();
58 
59  //! get element from the string name (PDB columns 77-78)
60  Element get_element(const std::string& s) const;
61 
62  //! get string name for Element
63  std::string get_name(Element e) const;
64 
65  //! get mass for Element
66  Float get_mass(Element e) const { return mass_[e]; }
67 
68  private:
69  struct ElementString {
70  std::string name;
71  Element e;
72  };
73 
74  static ElementString element_strings_[];
75  static Float mass_[];
76  static IMP::base::map<std::string, Element> string_2_element_;
77  static IMP::base::map<Element, std::string> element_2_string_;
78 };
79 
80 IMPATOMEXPORT ElementTable &get_element_table();
81 
82 IMPATOM_END_NAMESPACE
83 
84 #endif /* IMPATOM_ELEMENT_H */