OpenMS
Loading...
Searching...
No Matches
ElementDB.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Andreas Bertsch, Timo Sachsenberg, Chris Bielow, Jang Jang Jin$
7// --------------------------------------------------------------------------
8//
9
10#pragma once
11
14
15#include <map>
16#include <memory>
17#include <unordered_map>
18#include <string>
19
20namespace OpenMS
21{
22 class Element;
23
44 class OPENMS_DLLAPI ElementDB
45 {
46public:
47
53 static const ElementDB* getInstance();
54
56 const std::unordered_map<std::string, const Element*>& getNames() const;
57
59 const std::unordered_map<std::string, const Element*>& getSymbols() const;
60
62 const std::unordered_map<unsigned int, const Element*>& getAtomicNumbers() const;
63
68 const Element* getElement(const std::string& name) const;
69
71 const Element* getElement(unsigned int atomic_number) const;
73
78 bool hasElement(const std::string& name) const;
79
81 bool hasElement(unsigned int atomic_number) const;
83
84protected:
85
89 IsotopeDistribution parseIsotopeDistribution_(const std::map<unsigned int, double>& abundance, const std::map<unsigned int, double>& mass);
90
93 double calculateAvgWeight_(const std::map<unsigned int, double>& abundance, const std::map<unsigned int, double>& mass);
94
97 double calculateMonoWeight_(const std::map<unsigned int, double>& abundance, const std::map<unsigned int, double>& mass);
98
101
103 void buildElement_(const std::string& name, const std::string& symbol, const unsigned int an, const std::map<unsigned int, double>& abundance, const std::map<unsigned int, double>& mass);
104
106 void addElementToMaps_(const std::string& name, const std::string& symbol, const unsigned int an, std::unique_ptr<const Element> e);
107
109 void storeIsotopes_(const std::string& name, const std::string& symbol, const unsigned int an, const std::map<unsigned int, double>& Z_to_mass, const IsotopeDistribution& isotopes);
110
113 void clear_();
114
115 std::unordered_map<std::string, const Element*> names_;
116
117 std::unordered_map<std::string, const Element*> symbols_;
118
119 std::unordered_map<unsigned int, const Element*> atomic_numbers_;
120
121private:
124 ElementDB(const ElementDB& db) = delete;
125 ElementDB(const ElementDB&& db) = delete;
126 ElementDB& operator=(const ElementDB& db) = delete;
127
128 };
129
130} // namespace OpenMS
Singleton that stores elements and isotopes.
Definition ElementDB.h:45
const std::unordered_map< std::string, const Element * > & getSymbols() const
returns a hashmap that contains symbols mapped to pointers to the elements
std::unordered_map< unsigned int, const Element * > atomic_numbers_
Definition ElementDB.h:119
IsotopeDistribution parseIsotopeDistribution_(const std::map< unsigned int, double > &abundance, const std::map< unsigned int, double > &mass)
static const ElementDB * getInstance()
ElementDB(const ElementDB &&db)=delete
std::unordered_map< std::string, const Element * > symbols_
Definition ElementDB.h:117
const Element * getElement(const std::string &name) const
void buildElement_(const std::string &name, const std::string &symbol, const unsigned int an, const std::map< unsigned int, double > &abundance, const std::map< unsigned int, double > &mass)
build element objects from given abundances, masses, name, symbol, and atomic number
void addElementToMaps_(const std::string &name, const std::string &symbol, const unsigned int an, std::unique_ptr< const Element > e)
add element objects to documentation maps
ElementDB(const ElementDB &db)=delete
bool hasElement(unsigned int atomic_number) const
returns true if the db contains an element with the given atomic_number
double calculateMonoWeight_(const std::map< unsigned int, double > &abundance, const std::map< unsigned int, double > &mass)
ElementDB & operator=(const ElementDB &db)=delete
const Element * getElement(unsigned int atomic_number) const
returns a pointer to the element of atomic number; if no element is found 0 is returned
bool hasElement(const std::string &name) const
returns true if the db contains an element with the given name
void storeElements_()
constructs element objects
double calculateAvgWeight_(const std::map< unsigned int, double > &abundance, const std::map< unsigned int, double > &mass)
const std::unordered_map< unsigned int, const Element * > & getAtomicNumbers() const
returns a hashmap that contains atomic numbers mapped to pointers of the elements
void storeIsotopes_(const std::string &name, const std::string &symbol, const unsigned int an, const std::map< unsigned int, double > &Z_to_mass, const IsotopeDistribution &isotopes)
constructs isotope objects
std::unordered_map< std::string, const Element * > names_
Definition ElementDB.h:115
const std::unordered_map< std::string, const Element * > & getNames() const
returns a hashmap that contains names mapped to pointers to the elements
Representation of an element.
Definition Element.h:34
Definition IsotopeDistribution.h:40
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19