Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
IMSAlphabet.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2017.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: Anton Pervukhin <Anton.Pervukhin@CeBiTec.Uni-Bielefeld.DE> $
33 // --------------------------------------------------------------------------
34 //
35 
36 #ifndef OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_IMSALPHABET_H
37 #define OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_IMSALPHABET_H
38 
39 #include <vector>
40 #include <string>
41 #include <ostream>
42 
44 
47 
48 namespace OpenMS
49 {
50 
51  namespace ims
52  {
53 
82  class OPENMS_DLLAPI IMSAlphabet
83  {
84 
85 public:
89  typedef std::vector<element_type> container;
90  typedef container::size_type size_type;
91  typedef container::iterator iterator;
92  typedef container::const_iterator const_iterator;
93  typedef std::vector<name_type> name_container;
94  typedef name_container::iterator name_iterator;
95  typedef name_container::const_iterator const_name_iterator;
96  typedef std::vector<mass_type> mass_container;
97  typedef mass_container::iterator mass_iterator;
98  typedef mass_container::const_iterator const_mass_iterator;
99  typedef std::vector<mass_type> masses_type;
100 
105 
106 
112  explicit IMSAlphabet(const container & elements) :
113  elements_(elements)
114  {}
115 
116 
122  IMSAlphabet(const IMSAlphabet & alphabet) :
123  elements_(alphabet.elements_)
124  {}
125 
131  size_type size() const
132  {
133  return elements_.size();
134  }
135 
143  const element_type & getElement(size_type index) const
144  {
145  return elements_[index];
146  }
147 
158  void setElement(const name_type & name, mass_type mass, bool forced = false);
159 
166  bool erase(const name_type & name);
167 
176  const element_type & getElement(const name_type & name) const;
177 
184  const name_type & getName(size_type index) const;
185 
195  mass_type getMass(const name_type & name) const;
196 
204  mass_type getMass(size_type index) const;
205 
212  masses_type getMasses(size_type isotope_index = 0) const;
213 
219  masses_type getAverageMasses() const;
220 
228  bool hasName(const name_type & name) const;
229 
239  void push_back(const name_type & name, mass_type value)
240  {
241  push_back(element_type(name, value));
242  }
243 
249  void push_back(const element_type & element)
250  {
251  elements_.push_back(element);
252  }
253 
257  void clear()
258  {
259  elements_.clear();
260  }
261 
267  virtual void sortByNames();
268 
269 
275  virtual void sortByValues();
276 
277 
287  virtual void load(const std::string & fname);
288 
289 
301  virtual void load(const std::string & fname, IMSAlphabetParser<> * parser);
302 
303 
307  virtual ~IMSAlphabet() {}
308 
309 private:
313  container elements_;
314 
318  class OPENMS_DLLAPI MassSortingCriteria_
319  {
320 public:
321  bool operator()(const element_type & el1,
322  const element_type & el2) const
323  {
324  return el1.getMass() < el2.getMass();
325  }
326 
327  };
328 
329  };
330 
337  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const IMSAlphabet & alphabet);
338 
339  } // namespace ims
340 
341 } // namespace OpenMS
342 
343 #endif // OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_ALPHABET_H
std::vector< name_type > name_container
Definition: IMSAlphabet.h:93
size_type size() const
Definition: IMSAlphabet.h:131
void clear()
Definition: IMSAlphabet.h:257
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
container::size_type size_type
Definition: IMSAlphabet.h:90
virtual ~IMSAlphabet()
Definition: IMSAlphabet.h:307
element_type::name_type name_type
Definition: IMSAlphabet.h:88
container elements_
Definition: IMSAlphabet.h:313
mass_container::const_iterator const_mass_iterator
Definition: IMSAlphabet.h:98
void push_back(const name_type &name, mass_type value)
Definition: IMSAlphabet.h:239
Represents a chemical atom with name and isotope distribution.
Definition: IMSElement.h:59
IMSAlphabet(const container &elements)
Definition: IMSAlphabet.h:112
IMSElement element_type
Definition: IMSAlphabet.h:86
mass_container::iterator mass_iterator
Definition: IMSAlphabet.h:97
name_container::iterator name_iterator
Definition: IMSAlphabet.h:94
mass_type getMass(size_type index=0) const
Definition: IMSElement.h:173
Private class-functor to sort out elements in mass ascending order.
Definition: IMSAlphabet.h:318
IMSAlphabet()
Definition: IMSAlphabet.h:104
std::vector< mass_type > masses_type
Definition: IMSAlphabet.h:99
name_container::const_iterator const_name_iterator
Definition: IMSAlphabet.h:95
std::vector< mass_type > mass_container
Definition: IMSAlphabet.h:96
element_type::mass_type mass_type
Definition: IMSAlphabet.h:87
container::iterator iterator
Definition: IMSAlphabet.h:91
IMSAlphabet(const IMSAlphabet &alphabet)
Definition: IMSAlphabet.h:122
Holds an indexed list of bio-chemical elements.
Definition: IMSAlphabet.h:82
container::const_iterator const_iterator
Definition: IMSAlphabet.h:92
std::string name_type
Type of element&#39;s name.
Definition: IMSElement.h:63
bool operator()(const element_type &el1, const element_type &el2) const
Definition: IMSAlphabet.h:321
std::vector< element_type > container
Definition: IMSAlphabet.h:89
const element_type & getElement(size_type index) const
Definition: IMSAlphabet.h:143
void push_back(const element_type &element)
Definition: IMSAlphabet.h:249
std::ostream & operator<<(std::ostream &os, const IMSAlphabet &alphabet)

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:01 using doxygen 1.8.13