OpenMS
IMSElement.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-2023.
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 #pragma once
37 
38 #include <string>
39 #include <iosfwd>
41 
42 namespace OpenMS
43 {
44  namespace ims
45  {
46 
58  class OPENMS_DLLAPI IMSElement
59  {
60 public:
62  typedef std::string name_type;
63 
66 
69 
72 
75 
78 
81  {}
82 
84  IMSElement(const IMSElement & element) :
85  name_(element.name_),
86  sequence_(element.sequence_),
87  isotopes_(element.isotopes_)
88  {}
89 
91  IMSElement(const name_type & name,
92  const isotopes_type & isotopes) :
93  name_(name),
94  sequence_(name),
95  isotopes_(isotopes)
96  {}
97 
99  IMSElement(const name_type & name,
100  mass_type mass) :
101  name_(name),
102  sequence_(name),
103  isotopes_(mass)
104  {}
105 
107  IMSElement(const name_type & name,
108  nominal_mass_type nominal_mass = 0) :
109  name_(name),
110  sequence_(name),
111  isotopes_(nominal_mass)
112  {}
113 
120  const name_type & getName() const
121  {
122  return name_;
123  }
124 
131  void setName(const name_type & name)
132  {
133  this->name_ = name;
134  }
135 
141  const name_type & getSequence() const
142  {
143  return sequence_;
144  }
145 
151  void setSequence(const name_type & sequence)
152  {
153  this->sequence_ = sequence;
154  }
155 
162  {
163  return isotopes_.getNominalMass();
164  }
165 
172  mass_type getMass(size_type index = 0) const
173  {
174  return isotopes_.getMass(index);
175  }
176 
183  {
184  return isotopes_.getAverageMass();
185  }
186 
193  mass_type getIonMass(int electrons_number = 1) const
194  {
195  return this->getMass() - electrons_number * ELECTRON_MASS_IN_U;
196  }
197 
204  {
205  return isotopes_;
206  }
207 
214  {
215  this->isotopes_ = isotopes;
216  }
217 
224  IMSElement & operator=(const IMSElement & element);
225 
233  bool operator==(const IMSElement & element) const;
234 
242  bool operator!=(const IMSElement & element) const;
243 
245  virtual ~IMSElement() {}
246 
247 private:
250 
253 
256  };
257 
264  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const IMSElement & element);
265 
266  } // namespace ims
267 } // namespace OpenMS
268 
Represents a chemical atom with name and isotope distribution.
Definition: IMSElement.h:59
isotopes_type::mass_type mass_type
Type of isotope mass.
Definition: IMSElement.h:68
const name_type & getName() const
Definition: IMSElement.h:120
IMSElement(const name_type &name, nominal_mass_type nominal_mass=0)
Constructor with name and nominal mass.
Definition: IMSElement.h:107
IMSElement(const name_type &name, const isotopes_type &isotopes)
Constructor with name and isotope distribution.
Definition: IMSElement.h:91
void setName(const name_type &name)
Definition: IMSElement.h:131
isotopes_type::size_type size_type
Type of isotopes size.
Definition: IMSElement.h:74
mass_type getIonMass(int electrons_number=1) const
Definition: IMSElement.h:193
nominal_mass_type getNominalMass() const
Definition: IMSElement.h:161
void setIsotopeDistribution(const IMSIsotopeDistribution &isotopes)
Definition: IMSElement.h:213
name_type name_
Element's name.
Definition: IMSElement.h:249
mass_type getAverageMass() const
Definition: IMSElement.h:182
IMSElement()
Empty constructor.
Definition: IMSElement.h:80
IMSElement & operator=(const IMSElement &element)
isotopes_type::nominal_mass_type nominal_mass_type
Type of distribution nominal mass.
Definition: IMSElement.h:71
void setSequence(const name_type &sequence)
Definition: IMSElement.h:151
std::string name_type
Type of element's name.
Definition: IMSElement.h:62
bool operator!=(const IMSElement &element) const
IMSElement(const name_type &name, mass_type mass)
Constructor with name and mass of single isotope.
Definition: IMSElement.h:99
virtual ~IMSElement()
Default destructor.
Definition: IMSElement.h:245
const IMSIsotopeDistribution & getIsotopeDistribution() const
Definition: IMSElement.h:203
IMSElement(const IMSElement &element)
Copy constructor.
Definition: IMSElement.h:84
const name_type & getSequence() const
Definition: IMSElement.h:141
bool operator==(const IMSElement &element) const
name_type sequence_
Element's sequence.
Definition: IMSElement.h:252
IMSIsotopeDistribution isotopes_type
Type of element's isotope distribution.
Definition: IMSElement.h:65
static const mass_type ELECTRON_MASS_IN_U
Mass of electron.
Definition: IMSElement.h:77
isotopes_type isotopes_
Element's isotope distribution.
Definition: IMSElement.h:255
mass_type getMass(size_type index=0) const
Definition: IMSElement.h:172
Represents a distribution of isotopes restricted to the first K elements.
Definition: IMSIsotopeDistribution.h:88
peaks_container::size_type size_type
Type of peaks container's size.
Definition: IMSIsotopeDistribution.h:132
double mass_type
Type of isotope mass.
Definition: IMSIsotopeDistribution.h:92
unsigned int nominal_mass_type
Type of isotope nominal mass.
Definition: IMSIsotopeDistribution.h:98
std::ostream & operator<<(std::ostream &os, const IMSAlphabet &alphabet)
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48