OpenMS
Loading...
Searching...
No Matches
IMSAlphabet.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: Anton Pervukhin <Anton.Pervukhin@CeBiTec.Uni-Bielefeld.DE> $
7// --------------------------------------------------------------------------
8//
9
10#pragma once
11
12#include <vector>
13#include <string>
14#include <iosfwd>
15
17
20
21namespace OpenMS
22{
23
24 namespace ims
25 {
26
48 class OPENMS_DLLAPI IMSAlphabet
49 {
50
51public:
55 typedef std::vector<element_type> container;
56 typedef container::size_type size_type;
57 typedef container::iterator iterator;
58 typedef container::const_iterator const_iterator;
59 typedef std::vector<name_type> name_container;
60 typedef name_container::iterator name_iterator;
61 typedef name_container::const_iterator const_name_iterator;
62 typedef std::vector<mass_type> mass_container;
63 typedef mass_container::iterator mass_iterator;
64 typedef mass_container::const_iterator const_mass_iterator;
65 typedef std::vector<mass_type> masses_type;
66
71
72
78 explicit IMSAlphabet(const container & elements) :
79 elements_(elements)
80 {}
81
82
88 IMSAlphabet(const IMSAlphabet & alphabet) :
89 elements_(alphabet.elements_)
90 {}
91
98 {
99 return elements_.size();
100 }
101
109 const element_type & getElement(size_type index) const
110 {
111 return elements_[index];
112 }
113
124 void setElement(const name_type & name, mass_type mass, bool forced = false);
125
132 bool erase(const name_type & name);
133
142 const element_type & getElement(const name_type & name) const;
143
150 const name_type & getName(size_type index) const;
151
161 mass_type getMass(const name_type & name) const;
162
171
178 masses_type getMasses(size_type isotope_index = 0) const;
179
186
194 bool hasName(const name_type & name) const;
195
205 void push_back(const name_type & name, mass_type value)
206 {
207 push_back(element_type(name, value));
208 }
209
215 void push_back(const element_type & element)
216 {
217 elements_.push_back(element);
218 }
219
223 void clear()
224 {
225 elements_.clear();
226 }
227
233 virtual void sortByNames();
234
235
241 virtual void sortByValues();
242
243
254 virtual void load(const std::string & fname);
255
256
268 virtual void load(const std::string & fname, IMSAlphabetParser<> & parser);
269
270
274 virtual ~IMSAlphabet() {}
275
276private:
281
285 class OPENMS_DLLAPI MassSortingCriteria_
286 {
287public:
288 bool operator()(const element_type & el1,
289 const element_type & el2) const
290 {
291 return el1.getMass() < el2.getMass();
292 }
293
294 };
295
296 };
297
304 OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const IMSAlphabet & alphabet);
305
306 } // namespace ims
307
308} // namespace OpenMS
309
An abstract templatized parser to load the data that is used to initialize Alphabet objects.
Definition IMSAlphabetParser.h:38
Private class-functor to sort out elements in mass ascending order.
Definition IMSAlphabet.h:286
bool operator()(const element_type &el1, const element_type &el2) const
Definition IMSAlphabet.h:288
Holds an indexed list of bio-chemical elements used by mass-decomposition algorithms.
Definition IMSAlphabet.h:49
const name_type & getName(size_type index) const
masses_type getMasses(size_type isotope_index=0) const
element_type::mass_type mass_type
Definition IMSAlphabet.h:53
container::size_type size_type
Definition IMSAlphabet.h:56
virtual void load(const std::string &fname, IMSAlphabetParser<> &parser)
virtual void sortByValues()
container elements_
Definition IMSAlphabet.h:280
IMSAlphabet()
Definition IMSAlphabet.h:70
mass_type getMass(size_type index) const
virtual void load(const std::string &fname)
void push_back(const element_type &element)
Definition IMSAlphabet.h:215
bool hasName(const name_type &name) const
IMSAlphabet(const IMSAlphabet &alphabet)
Definition IMSAlphabet.h:88
const element_type & getElement(const name_type &name) const
const element_type & getElement(size_type index) const
Definition IMSAlphabet.h:109
size_type size() const
Definition IMSAlphabet.h:97
std::vector< mass_type > mass_container
Definition IMSAlphabet.h:62
std::vector< element_type > container
Definition IMSAlphabet.h:55
container::iterator iterator
Definition IMSAlphabet.h:57
virtual void sortByNames()
masses_type getAverageMasses() const
void setElement(const name_type &name, mass_type mass, bool forced=false)
std::vector< name_type > name_container
Definition IMSAlphabet.h:59
name_container::iterator name_iterator
Definition IMSAlphabet.h:60
void push_back(const name_type &name, mass_type value)
Definition IMSAlphabet.h:205
IMSElement element_type
Definition IMSAlphabet.h:52
std::vector< mass_type > masses_type
Definition IMSAlphabet.h:65
mass_type getMass(const name_type &name) const
mass_container::const_iterator const_mass_iterator
Definition IMSAlphabet.h:64
void clear()
Definition IMSAlphabet.h:223
element_type::name_type name_type
Definition IMSAlphabet.h:54
virtual ~IMSAlphabet()
Definition IMSAlphabet.h:274
container::const_iterator const_iterator
Definition IMSAlphabet.h:58
mass_container::iterator mass_iterator
Definition IMSAlphabet.h:63
name_container::const_iterator const_name_iterator
Definition IMSAlphabet.h:61
IMSAlphabet(const container &elements)
Definition IMSAlphabet.h:78
bool erase(const name_type &name)
Represents a chemical atom with name and isotope distribution.
Definition IMSElement.h:33
isotopes_type::mass_type mass_type
Type of isotope mass.
Definition IMSElement.h:42
std::string name_type
Type of element's name.
Definition IMSElement.h:36
mass_type getMass(size_type index=0) const
Definition IMSElement.h:146
std::ostream & operator<<(std::ostream &os, const IMSAlphabet &alphabet)
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19