This section contains a short introduction to three data structures you will definitely need when programming with OpenMS. The data structures module of the class documentation contains many more classes, which are not mentioned here in detail. The classes described in this section can be found in the DATASTRUCTURES folder.
The OpenMS string implementation String is based on the STL std::string. In order to make the OpenMS string class more convenient, a lot of methods have been implemented in addition to the methods provided by the base class. A selection of the added functionality is given here:
Many OpenMS classes, especially the kernel classes, need to store some kind of d-dimensional coordinates. The template class DPosition is used for that purpose. The interface of DPosition is pretty straightforward. The operator[] is used to access the coordinate of the different dimensions. The dimensionality is stored in the enum value DIMENSION. The following example (Tutorial_DPosition.cpp) shows how to print a DPosition to the standard output stream.
First we need to include the header file for DPosition and iostream. Then we import all the OpenMS symbols to the scope with the using directive.
The first commands in the main method initialize a 2-dimensional DPosition : Finally we print the content of the DPosition to the standard output stream:The output of our first little OpenMS program is the following:
Another important data structure we need to look at in detail is DRange. It defines a d-dimensional, half-open interval through its two DPosition members. These members are accessed by the minPosition() and maxPosition() methods and can be set by the setMin() and setMax() methods.
DRange maintains the invariant that minPosition() is geometrically less or equal to maxPosition(), i.e. for each dimension x. The following example (Tutorial_DRange.cpp) demonstrates this behaviour.
This time, we skip everything before the main method. In the main method, we create a range and assign values to min and max. Note that the minimum value of the first dimension is larger than the maximum value.
The output is:
As you can see, the minimum value of dimension one was adjusted in order to make the maximum of 1 conform with the invariant.
DIntervalBase is the closed interval counterpart (and base class) of DRange. Another class derived from DIntervalBase is DBoundingBox. It also represents a closed interval, but differs in the methods. Please have a look at the class documentation for details.
Most algorithms of OpenMS and some of the TOPP tools have many parameters. The parameters are stored in instances of Param. This class is similar to a Windows INI file. The actual parameters (type, name and value) are stored in sections. Sections can contain parameters and sub-sections, which leads to a tree-like structure. The values are stored in DataValue.
Parameter names are given as a string including the sections and subsections in which ':' is used as a delimiter.
The following example (Tutorial_Param.cpp) shows how a file description is given.
OpenMS / TOPP release 2.3.0 | Documentation generated on Tue Jan 9 2018 18:22:05 using doxygen 1.8.13 |