OpenMS  2.6.0
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-2020.
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 <vector>
39 #include <string>
40 #include <iosfwd>
41 
43 
46 
47 namespace OpenMS
48 {
49 
50  namespace ims
51  {
52 
81  class OPENMS_DLLAPI IMSAlphabet
82  {
83 
84 public:
88  typedef std::vector<element_type> container;
89  typedef container::size_type size_type;
90  typedef container::iterator iterator;
91  typedef container::const_iterator const_iterator;
92  typedef std::vector<name_type> name_container;
93  typedef name_container::iterator name_iterator;
94  typedef name_container::const_iterator const_name_iterator;
95  typedef std::vector<mass_type> mass_container;
96  typedef mass_container::iterator mass_iterator;
97  typedef mass_container::const_iterator const_mass_iterator;
98  typedef std::vector<mass_type> masses_type;
99 
104 
105 
111  explicit IMSAlphabet(const container & elements) :
112  elements_(elements)
113  {}
114 
115 
121  IMSAlphabet(const IMSAlphabet & alphabet) :
122  elements_(alphabet.elements_)
123  {}
124 
130  size_type size() const
131  {
132  return elements_.size();
133  }
134 
142  const element_type & getElement(size_type index) const
143  {
144  return elements_[index];
145  }
146 
157  void setElement(const name_type & name, mass_type mass, bool forced = false);
158 
165  bool erase(const name_type & name);
166 
175  const element_type & getElement(const name_type & name) const;
176 
183  const name_type & getName(size_type index) const;
184 
194  mass_type getMass(const name_type & name) const;
195 
203  mass_type getMass(size_type index) const;
204 
211  masses_type getMasses(size_type isotope_index = 0) const;
212 
218  masses_type getAverageMasses() const;
219 
227  bool hasName(const name_type & name) const;
228 
238  void push_back(const name_type & name, mass_type value)
239  {
240  push_back(element_type(name, value));
241  }
242 
248  void push_back(const element_type & element)
249  {
250  elements_.push_back(element);
251  }
252 
256  void clear()
257  {
258  elements_.clear();
259  }
260 
266  virtual void sortByNames();
267 
268 
274  virtual void sortByValues();
275 
276 
286  virtual void load(const std::string & fname);
287 
288 
300  virtual void load(const std::string & fname, IMSAlphabetParser<> * parser);
301 
302 
306  virtual ~IMSAlphabet() {}
307 
308 private:
313 
317  class OPENMS_DLLAPI MassSortingCriteria_
318  {
319 public:
320  bool operator()(const element_type & el1,
321  const element_type & el2) const
322  {
323  return el1.getMass() < el2.getMass();
324  }
325 
326  };
327 
328  };
329 
336  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const IMSAlphabet & alphabet);
337 
338  } // namespace ims
339 
340 } // namespace OpenMS
341 
OpenMS::MultiGradient
A gradient of multiple colors and arbitrary distances between colors.
Definition: MultiGradient.h:67
OpenMS::ims::IMSAlphabet::const_mass_iterator
mass_container::const_iterator const_mass_iterator
Definition: IMSAlphabet.h:97
OpenMS::ims::IMSAlphabet::push_back
void push_back(const name_type &name, mass_type value)
Definition: IMSAlphabet.h:238
OpenMS::TOPPBase
Base class for TOPP applications.
Definition: TOPPBase.h:144
OpenMS::Matrix::resize
void resize(size_type i, size_type j, value_type value=value_type())
Definition: Matrix.h:243
OpenMS::ims::IMSAlphabet::element_type
IMSElement element_type
Definition: IMSAlphabet.h:85
double
OpenMS::Internal::DIntervalBase::minX
CoordinateType minX() const
Accessor for min_ coordinate minimum.
Definition: DIntervalBase.h:243
OpenMS::ims::IMSAlphabet::mass_iterator
mass_container::iterator mass_iterator
Definition: IMSAlphabet.h:96
OpenMS::FeatureMap::Iterator
Base::iterator Iterator
Definition: FeatureMap.h:143
OpenMS::ims::IMSAlphabet::masses_type
std::vector< mass_type > masses_type
Definition: IMSAlphabet.h:98
OpenMS::ims::IMSAlphabet::mass_container
std::vector< mass_type > mass_container
Definition: IMSAlphabet.h:95
OpenMS::ims::IMSAlphabet::const_name_iterator
name_container::const_iterator const_name_iterator
Definition: IMSAlphabet.h:94
OpenMS::MzMLFile
File adapter for MzML files.
Definition: MzMLFile.h:55
OpenMS::ims::IMSAlphabet::name_iterator
name_container::iterator name_iterator
Definition: IMSAlphabet.h:93
OpenMS::String
A more convenient string class.
Definition: String.h:59
OpenMS::MSExperiment::begin
Iterator begin()
Definition: MSExperiment.h:157
OpenMS::DRange< 1 >
OpenMS::String::trim
String & trim()
removes whitespaces (space, tab, line feed, carriage return) at the beginning and the end of the stri...
MzMLFile.h
OpenMS::ims::IMSElement::name_type
std::string name_type
Type of element's name.
Definition: IMSElement.h:62
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
OpenMS::ims::IMSAlphabet::iterator
container::iterator iterator
Definition: IMSAlphabet.h:90
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
FeatureXMLFile.h
OpenMS::ListUtils::contains
static bool contains(const std::vector< T > &container, const E &elem)
Checks whether the element elem is contained in the given container.
Definition: ListUtils.h:146
IMSElement.h
OpenMS::StringListUtils::toUpper
static void toUpper(StringList &sl)
Transforms all strings contained in the passed StringList to upper case.
MultiGradient.h
OpenMS::ims::IMSAlphabet::IMSAlphabet
IMSAlphabet()
Definition: IMSAlphabet.h:103
OpenMS::ims::IMSAlphabet::mass_type
element_type::mass_type mass_type
Definition: IMSAlphabet.h:86
OpenMS::MultiGradient::getDefaultGradientLinearIntensityMode
static MultiGradient getDefaultGradientLinearIntensityMode()
Returns the default gradient for linear intensity mode.
OpenMS::ims::IMSAlphabet
Holds an indexed list of bio-chemical elements.
Definition: IMSAlphabet.h:81
OpenMS::Matrix::sizePair
std::pair< Size, Size > sizePair() const
Definition: Matrix.h:269
OpenMS::Internal::DIntervalBase::minY
CoordinateType minY() const
Accessor for max_ coordinate minimum.
Definition: DIntervalBase.h:249
OpenMS::MSExperiment::getMaxRT
CoordinateType getMaxRT() const
returns the maximal retention time value
OpenMS::Matrix::getValue
const_reference getValue(size_type const i, size_type const j) const
Definition: Matrix.h:165
OpenMS::ims::IMSAlphabet::IMSAlphabet
IMSAlphabet(const IMSAlphabet &alphabet)
Definition: IMSAlphabet.h:121
OpenMS::ims::IMSAlphabet::const_iterator
container::const_iterator const_iterator
Definition: IMSAlphabet.h:91
OpenMS::MSExperiment::size
Size size() const
Definition: MSExperiment.h:127
OpenMS::MSExperiment::getPrecursorSpectrum
ConstIterator getPrecursorSpectrum(ConstIterator iterator) const
Returns the precursor spectrum of the scan pointed to by iterator.
OpenMS::Math::BilinearInterpolation
Provides access to bilinearly interpolated values (and derivatives) from discrete data points....
Definition: BilinearInterpolation.h:72
OpenMS::ims::IMSAlphabet::container
std::vector< element_type > container
Definition: IMSAlphabet.h:88
OpenMS::ConvexHull2D
A 2-dimensional hull representation in [counter]clockwise direction - depending on axis labelling.
Definition: ConvexHull2D.h:72
OpenMS::InPrecursorMZRange
Predicate that determines if a spectrum's precursor is within a certain m/z range.
Definition: RangeUtils.h:394
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::MSExperiment::Iterator
std::vector< SpectrumType >::iterator Iterator
Mutable iterator.
Definition: MSExperiment.h:111
Exception.h
OpenMS::ims::IMSAlphabet::push_back
void push_back(const element_type &element)
Definition: IMSAlphabet.h:248
OpenMS::MSExperiment::getMaxMZ
CoordinateType getMaxMZ() const
returns the maximal m/z value
OpenMS::ims::IMSAlphabet::getElement
const element_type & getElement(size_type index) const
Definition: IMSAlphabet.h:142
OpenMS::MzMLFile::load
void load(const String &filename, PeakMap &map)
Loads a map from a MzML file. Spectra and chromatograms are sorted by default (this can be disabled u...
int
OpenMS::FeatureXMLFile::load
void load(const String &filename, FeatureMap &feature_map)
loads the file with name filename into map and calls updateRanges().
FeatureMap.h
RangeUtils.h
OpenMS::Math::BilinearInterpolation::getData
ContainerType & getData()
Returns the internal random access container storing the data.
Definition: BilinearInterpolation.h:510
IMSAlphabetParser.h
OpenMS::DBoundingBox< 2 >
OpenMS::Math::BilinearInterpolation::setMapping_1
void setMapping_1(KeyType const &scale, KeyType const &inside_low, KeyType const &outside_low)
Specifies the mapping from "outside" to "inside" coordinates by the following data:
Definition: BilinearInterpolation.h:713
OpenMS::String::toQString
QString toQString() const
Conversion to Qt QString.
OpenMS::Math
Math namespace.
Definition: BilinearInterpolation.h:42
OpenMS::Math::BilinearInterpolation::addValue
void addValue(KeyType arg_pos_0, KeyType arg_pos_1, ValueType arg_value)
Performs bilinear resampling. The arg_value is split up and added to the data points around arg_pos....
Definition: BilinearInterpolation.h:316
OpenMS::String::toUpper
String & toUpper()
Converts the string to uppercase.
OpenMS::ims::IMSAlphabet::name_container
std::vector< name_type > name_container
Definition: IMSAlphabet.h:92
OpenMS::StringList
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
BilinearInterpolation.h
main
int main(int argc, const char **argv)
Definition: INIFileEditor.cpp:73
OpenMS::Internal::DIntervalBase::maxY
CoordinateType maxY() const
Accessor for max_ coordinate maximum.
Definition: DIntervalBase.h:261
OpenMS::Constants::h
const double h
LinearResampler.h
OPENMS_LOG_ERROR
#define OPENMS_LOG_ERROR
Macro to be used if non-fatal error are reported (processing continues)
Definition: LogStream.h:455
OpenMS::FeatureMap
A container for features.
Definition: FeatureMap.h:97
OpenMS::ims::IMSAlphabet::size
size_type size() const
Definition: IMSAlphabet.h:130
OpenMS::ims::IMSElement
Represents a chemical atom with name and isotope distribution.
Definition: IMSElement.h:58
OpenMS::ims::IMSAlphabet::MassSortingCriteria_::operator()
bool operator()(const element_type &el1, const element_type &el2) const
Definition: IMSAlphabet.h:320
OpenMS::PeakFileOptions::setRTRange
void setRTRange(const DRange< 1 > &range)
restricts the range of RT values for peaks to load
OpenMS::MSExperiment::end
Iterator end()
Definition: MSExperiment.h:167
OpenMS::MSExperiment::getSpectra
const std::vector< MSSpectrum > & getSpectra() const
returns the spectrum list
OpenMS::FeatureXMLFile
This class provides Input/Output functionality for feature maps.
Definition: FeatureXMLFile.h:68
OpenMS::ims::IMSAlphabet::clear
void clear()
Definition: IMSAlphabet.h:256
OpenMS::ims::IMSAlphabet::MassSortingCriteria_
Private class-functor to sort out elements in mass ascending order.
Definition: IMSAlphabet.h:317
OpenMS::ConvexHull2D::getBoundingBox
DBoundingBox< 2 > getBoundingBox() const
returns the bounding box of the feature hull points
OpenMS::MSExperiment::updateRanges
void updateRanges() override
Updates minimum and maximum position/intensity.
OpenMS::Internal::DIntervalBase::maxX
CoordinateType maxX() const
Accessor for min_ coordinate maximum.
Definition: DIntervalBase.h:255
OpenMS::ims::operator<<
std::ostream & operator<<(std::ostream &os, const IMSAlphabet &alphabet)
OpenMS::ims::IMSElement::getMass
mass_type getMass(size_type index=0) const
Definition: IMSElement.h:172
OpenMS::PeakFileOptions::setMZRange
void setMZRange(const DRange< 1 > &range)
restricts the range of MZ values for peaks to load
OpenMS::MSExperiment::ConstIterator
std::vector< SpectrumType >::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSExperiment.h:113
OpenMS::MultiGradient::getDefaultGradientLogarithmicIntensityMode
static MultiGradient getDefaultGradientLogarithmicIntensityMode()
Returns the default gradient for logarithmic intensity mode.
OpenMS::ims::IMSAlphabetParser<>
OpenMS::PeakFileOptions::setMSLevels
void setMSLevels(const std::vector< Int > &levels)
sets the desired MS levels for peaks to load
OpenMS::Exception::ElementNotFound
Element could not be found exception.
Definition: Exception.h:662
OpenMS::MultiGradient::fromString
void fromString(const std::string &gradient)
Sets the gradient by string representation.
OpenMS::String::suffix
String suffix(SizeType length) const
returns the suffix of length length
OpenMS::ims::IMSAlphabet::elements_
container elements_
Definition: IMSAlphabet.h:312
OpenMS::MSExperiment::getMinMZ
CoordinateType getMinMZ() const
returns the minimal m/z value
OpenMS::ims::IMSAlphabet::size_type
container::size_type size_type
Definition: IMSAlphabet.h:89
OpenMS::ims::IMSAlphabet::IMSAlphabet
IMSAlphabet(const container &elements)
Definition: IMSAlphabet.h:111
OpenMS::MzMLFile::getOptions
PeakFileOptions & getOptions()
Mutable access to the options for loading/storing.
OpenMS::ProgressLogger::setLogType
void setLogType(LogType type) const
Sets the progress log that should be used. The default type is NONE!
TOPPBase.h
OpenMS::ims::IMSAlphabet::name_type
element_type::name_type name_type
Definition: IMSAlphabet.h:87
OpenMS::ims::IMSAlphabet::~IMSAlphabet
virtual ~IMSAlphabet()
Definition: IMSAlphabet.h:306
OpenMS::MSExperiment::getMinRT
CoordinateType getMinRT() const
returns the minimal retention time value
OpenMS::Math::BilinearInterpolation::setMapping_0
void setMapping_0(KeyType const &scale, KeyType const &inside_low, KeyType const &outside_low)
Specifies the mapping from "outside" to "inside" coordinates by the following data:
Definition: BilinearInterpolation.h:670
OpenMS::MultiGradient::interpolatedColorAt
QColor interpolatedColorAt(double position) const
Returns the color as position.
StringListUtils.h