File: tutorial_kernel.html

package info (click to toggle)
openms 1.11.1-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 436,688 kB
  • ctags: 150,907
  • sloc: cpp: 387,126; xml: 71,547; python: 7,764; ansic: 2,626; php: 2,499; sql: 737; ruby: 342; sh: 325; makefile: 128
file content (185 lines) | stat: -rw-r--r-- 18,934 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<HTML>
<HEAD>
<TITLE>The kernel classes</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
<LINK HREF="style_ini.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<A href="index.html">Home</A> &nbsp;&middot;
<A href="classes.html">Classes</A> &nbsp;&middot;
<A href="annotated.html">Annotated Classes</A> &nbsp;&middot;
<A href="modules.html">Modules</A> &nbsp;&middot;
<A href="functions_func.html">Members</A> &nbsp;&middot;
<A href="namespaces.html">Namespaces</A> &nbsp;&middot;
<A href="pages.html">Related Pages</A>
<HR style="height:1px; border:none; border-top:1px solid #c0c0c0;">
<!-- Generated by Doxygen 1.8.5 -->
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">The kernel classes </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>The OpenMS kernel contains the datastructures that store the actual MS data, i.e. raw data points, peaks, features, spectra, maps. The classes described in this section can be found in the <em>KERNEL</em> folder.</p>
<h1><a class="anchor" id="kernel_datapoints"></a>
Raw data point, Peak, Feature, ...</h1>
<p>In general, there are three types of data points: raw data points, peaks and picked peaks. Raw data points provide members to store position (mass-to-charge ratio, retention time, ...) and intensity. Peaks are derived from raw data points and add an interface to store meta information. Picked peaks are derived from peaks and have additional members for peak shape information: charge, width, signal-to-noise ratio and many more.</p>
<p>The kernel data points exist in three versions: one-dimensional, two-dimensional and d-dimensional.</p>
<div class="image">
<img src="Kernel_DataPoints.png" alt="Kernel_DataPoints.png"/>
<div class="caption">
Data structures for MS data points</div></div>
 <dl class="section user"><dt>one-dimensional data points</dt><dd>The one-dimensional data points are most important, the two-dimensional and d-dimensional data points are needed rarely. The base class of the one-dimensional data points is <em>Peak1D</em>. It provides members to store the mass-to-charge ratio (<em>getMZ</em> and <em>setMZ</em>) and the intensity (<em>getIntensity</em> and <em>setIntensity</em>). <br/>
 <em>RichPeak1D</em> is derived from <em>Peak1D</em> and adds an interface for metadata (see <a class="el" href="tutorial_metadata.html#metadata_metainfo">MetaInfo</a>).</dd></dl>
<dl class="section user"><dt>two-dimensional data points</dt><dd>The two-dimensional data points are needed when geometry algorithms are applied to the data points. A special case is the <em>Feature</em> class, which needs a two-dimensional position (m/z and RT). <br/>
 The base class of the two-dimensional data points is <em>Peak2D</em>. It provides the same interface as <em>Peak1D</em> and additional members for the retention time (<em>getRT</em> and <em>setRT</em>). <br/>
 <em>RichPeak2D</em> is derived from <em>Peak2D</em> and adds an interface for metadata. <br/>
 <em>Feature</em> is derived from <em>RichPeak2D</em> and adds information about the convex hull of the feature, fitting quality and so on.</dd></dl>
<dl class="section user"><dt>d-dimensional data points</dt><dd>The d-dimensional data points are needed only in special cases, e.g. in template classes that must operate on any number of dimensions. <br/>
 The base class of the d-dimensional data points is <em>DPeak</em>. The methods to access the position are <em>getPosition</em> and <em>setPosition</em>. <br/>
 Note that the one-dimensional and two-dimensional data points also have the methods <em>getPosition</em> and <em>setPosition</em>. They are needed in order to be able to write algorithms that can operate on all data point types. It is, however, recommended not to use these members unless you really write such a generic algorithm.</dd></dl>
<h1><a class="anchor" id="kernel_spectra"></a>
Spectra</h1>
<p>The most important container for raw data and peaks is <em>MSSpectrum</em>. It is a template class that takes the peak type as template argument. The default peak type is <em>RichPeak1D</em>. Possible other peak types are classes derived from <em>Peak1D</em> or classes providing the same interface. <br/>
 <em>MSSpectrum</em> is a container for 1-dimensional peak data. It is derived from <em>SpectrumSettings</em>, a container for the meta data of a spectrum. Here, only MS data handling is explained, <em>SpectrumSettings</em> is described in section <a class="el" href="tutorial_metadata.html#metadata_spectrum">Meta data of a spectrum</a>.</p>
<p>In the following example (Tutorial_MSSpectrum.C) program, a <em>MSSpectrum</em> is filled with peaks, sorted according to mass-to-charge ratio and a selection of peak positions is displayed.</p>
<p>First we create a spectrum and insert peaks with descending mass-to-charge ratios:  <div class="fragment"><div class="line"><a class="code" href="classInt.html">Int</a> <a class="code" href="RNPxl_8C.html#a217dbf8b442f20279ea00b898af96f52">main</a>()</div>
<div class="line">{</div>
<div class="line">  <a class="code" href="classOpenMS_1_1MSSpectrum.html">MSSpectrum&lt;&gt;</a> spectrum;</div>
<div class="line">  Peak1D peak;</div>
<div class="line"></div>
<div class="line">  <span class="keywordflow">for</span> (<a class="code" href="classReal.html">Real</a> mz = 1500.0; mz &gt;= 500; mz -= 100.0)</div>
<div class="line">  {</div>
<div class="line">    peak.setMZ(mz);</div>
<div class="line">    spectrum.push_back(peak);</div>
<div class="line">  }</div>
</div><!-- fragment --> Then we sort the peaks according to ascending mass-to-charge ratio. <div class="fragment"><div class="line"></div>
<div class="line">  spectrum.<a class="code" href="classOpenMS_1_1MSSpectrum.html#a86f7b200260209865e730a2e4fcaa628">sortByPosition</a>();</div>
</div><!-- fragment --> Finally we print the peak positions of those peaks between 800 and 1000 Thomson. For printing all the peaks in the spectrum, we simply would have used the STL-conform methods <em>begin()</em> and <em>end()</em>. <div class="fragment"><div class="line"></div>
<div class="line">  <a class="code" href="classOpenMS_1_1MSSpectrum.html#a6d64276a665c3c0dca8fb4ade3c8b477">MSSpectrum&lt;&gt;::Iterator</a> it;</div>
<div class="line">  <span class="keywordflow">for</span> (it = spectrum.<a class="code" href="classOpenMS_1_1MSSpectrum.html#a808327302a2ba3fb630ea132d32db942">MZBegin</a>(800.0); it != spectrum.<a class="code" href="classOpenMS_1_1MSSpectrum.html#add06770712321b6e489bbdbcd123c888">MZEnd</a>(1000.0); ++it)</div>
<div class="line">  {</div>
<div class="line">    cout &lt;&lt; it-&gt;getMZ() &lt;&lt; endl;</div>
<div class="line">  }</div>
<div class="line"></div>
<div class="line">  <span class="keywordflow">return</span> 0;</div>
<div class="line">} <span class="comment">//end of main</span></div>
</div><!-- fragment --></p>
<dl class="section user"><dt>Typedefs</dt><dd>For convenience, the following type definitions are defined in <em><a class="el" href="StandardTypes_8h.html">OpenMS/KERNEL/StandardTypes.h</a></em>. <div class="fragment"><div class="line"><span class="keyword">typedef</span> MSSpectrum&lt;RichPeak1D&gt; <a class="code" href="group__Kernel.html#gae09df17325d781f23b1486a2db006e0d">RichPeakSpectrum</a>;</div>
<div class="line"><span class="keyword">typedef</span> MSSpectrum&lt;Peak1D&gt; <a class="code" href="group__Kernel.html#ga3ba16951dc40c7a6c7457f3452e096ab">PeakSpectrum</a>;</div>
</div><!-- fragment --></dd></dl>
<h1><a class="anchor" id="kernel_maps"></a>
Maps</h1>
<p>Although raw data maps, peak maps and feature maps are conceptually very similar. They are stored in different data types. For raw data and peak maps, the default container is <em>MSExperiment</em>, which is an array of <em>MSSpectrum</em> instances. Just as <em>MSSpectrum</em> it is a template class with the peak type as template parameter.</p>
<p>In contrast to raw data and peak maps, feature maps are no collection of one-dimensional spectra, but an array of two-dimensional <em>Feature</em> instances. The main datastructure for feature maps is called <em>FeatureMap</em>.</p>
<p>Although <em>MSExperiment</em> and <em>FeatureMap</em> differ in the data they store, they also have things in common. Both store meta data that is valid for the whole map, i.e. sample description and instrument description. This data is stored in the common base class <em>ExperimentalSettings</em>.</p>
<dl class="section user"><dt>MSExperiment</dt><dd>The following figure shows the big picture of the kernel datastructures. <em>MSExperiment</em> is derived from <em>ExperimentalSettings</em> (meta data of the experiment) and from <em>vector&lt;MSSpectrum&gt;</em>. The one-dimensional spectrum <em>MSSpectrum</em> is derived from SpectrumSettings (meta data of a spectrum. <br/>
 Since MSSpectrum can store different peak types derived from <em>Peak1D</em>, all the data containers are template classes that take the peak type as template argument.</dd></dl>
<div class="image">
<img src="Kernel.png" alt="Kernel.png"/>
<div class="caption">
Overview of the main kernel datastructures</div></div>
 <dl class="section user"><dt>Typedefs</dt><dd>For convenience, the following map types are defined in <em><a class="el" href="StandardTypes_8h.html">OpenMS/KERNEL/StandardTypes.h</a></em>. <div class="fragment"><div class="line"><span class="keyword">typedef</span> MSExperiment&lt;RichPeak1D&gt; <a class="code" href="group__Kernel.html#ga194ebcb2ab563f6bb680c2b1f94bcde7">RichPeakMap</a>;</div>
<div class="line"><span class="keyword">typedef</span> MSExperiment&lt;Peak1D&gt; <a class="code" href="group__Kernel.html#gac459ab9d68b68f31561c7763c7da61ef">PeakMap</a>;</div>
</div><!-- fragment --></dd></dl>
<p>The following example program (Tutorial_MSExperiment.C) creates a <em>MSExperiment</em> containing four <em>MSSpectrum</em> instances. Then it iterates over an area and prints the peak positions in the area:</p>
<p>First we create the spectra in a for-loop and set the retention time and MS level. Survey scans have a MS level of 1, MS/MS scans would have a MS level of 2, and so on.  <div class="fragment"><div class="line"><a class="code" href="classInt.html">Int</a> <a class="code" href="RNPxl_8C.html#a217dbf8b442f20279ea00b898af96f52">main</a>()</div>
<div class="line">{</div>
<div class="line">  PeakMap exp;</div>
<div class="line"></div>
<div class="line">  <span class="keywordflow">for</span> (<a class="code" href="group__Concept.html#gaf9ecec2d692138fab9167164a457cbd4">Size</a> i = 0; i &lt; 4; ++i)</div>
<div class="line">  {</div>
<div class="line">    PeakSpectrum spectrum;</div>
<div class="line">    spectrum.<a class="code" href="classOpenMS_1_1MSSpectrum.html#aac8c50f318154e9e5b7b01aee806e17f">setRT</a>(i);</div>
<div class="line">    spectrum.setMSLevel(1);</div>
</div><!-- fragment --> Then we fill each spectrum with several peaks. As all spectra would have the same peaks otherwise, we add the retention time to the mass-to-charge ratio of each peak. <div class="fragment"><div class="line">    <span class="keywordflow">for</span> (<a class="code" href="classReal.html">Real</a> mz = 500.0; mz &lt;= 900; mz += 100.0)</div>
<div class="line">    {</div>
<div class="line">      Peak1D peak;</div>
<div class="line">      peak.setMZ(mz + i);</div>
<div class="line">      spectrum.push_back(peak);</div>
<div class="line">    }</div>
<div class="line">    exp.addSpectrum(spectrum);</div>
<div class="line">  } <span class="comment">//end of creation</span></div>
</div><!-- fragment --> Finally, we iterate over the RT range (2,3) and the m/z range (603,802) and print the peak positions. <div class="fragment"><div class="line"></div>
<div class="line">  <span class="keywordflow">for</span> (PeakMap::AreaIterator it = exp.areaBegin(2.0, 3.0, 603.0, 802.0); it != exp.areaEnd(); ++it)</div>
<div class="line">  {</div>
<div class="line">    cout &lt;&lt; it.getRT() &lt;&lt; <span class="stringliteral">&quot; - &quot;</span> &lt;&lt; it-&gt;getMZ() &lt;&lt; endl;</div>
<div class="line">  }</div>
</div><!-- fragment --> The output of this loop is: </p>
<div class="fragment"><div class="line">2 - 702</div>
<div class="line">2 - 802</div>
<div class="line">3 - 603</div>
<div class="line">3 - 703</div>
</div><!-- fragment --><p> For printing all the peaks in the experiment, we could have used the STL-iterators of the experiment to iterate over the spectra and the STL-iterators of the spectra to iterate over the peaks: <div class="fragment"><div class="line"></div>
<div class="line">  <span class="keywordflow">for</span> (PeakMap::Iterator s_it = exp.begin(); s_it != exp.end(); ++s_it)</div>
<div class="line">  {</div>
<div class="line">    <span class="keywordflow">for</span> (PeakSpectrum::Iterator p_it = s_it-&gt;begin(); p_it != s_it-&gt;end(); ++p_it)</div>
<div class="line">    {</div>
<div class="line">      cout &lt;&lt; s_it-&gt;getRT() &lt;&lt; <span class="stringliteral">&quot; - &quot;</span> &lt;&lt; p_it-&gt;getMZ() &lt;&lt; endl;</div>
<div class="line">    }</div>
<div class="line">  }</div>
<div class="line"></div>
<div class="line">  <span class="keywordflow">return</span> 0;</div>
<div class="line">} <span class="comment">//end of main</span></div>
</div><!-- fragment --></p>
<dl class="section user"><dt>FeatureMap</dt><dd><em>FeatureMap</em>, the container for features, is simply a <em>vector&lt;Feature&gt;</em>. Additionally, it is derived from <em>ExperimentalSettings</em>, to store the meta information. Just like <em>MSExperiment</em>, it is a template class. It takes the feature type as template argument.</dd></dl>
<p>The following example (Tutorial_FeatureMap.C) shows how to insert two features into a map and iterate over the features.  <div class="fragment"><div class="line"><a class="code" href="classInt.html">Int</a> <a class="code" href="RNPxl_8C.html#a217dbf8b442f20279ea00b898af96f52">main</a>()</div>
<div class="line">{</div>
<div class="line">  <a class="code" href="classOpenMS_1_1FeatureMap.html">FeatureMap&lt;&gt;</a> map;</div>
<div class="line"></div>
<div class="line">  Feature feature;</div>
<div class="line">  feature.setRT(15.0);</div>
<div class="line">  feature.setMZ(571.3);</div>
<div class="line">  map.push_back(feature); <span class="comment">//append feature 1</span></div>
<div class="line">  feature.setRT(23.3);</div>
<div class="line">  feature.setMZ(1311.3);</div>
<div class="line">  map.push_back(feature); <span class="comment">//append feature 2</span></div>
<div class="line"></div>
<div class="line"></div>
<div class="line">  <span class="keywordflow">for</span> (<a class="code" href="classOpenMS_1_1FeatureMap.html#ad436ba4f307bb17e3a999bf315125b33">FeatureMap&lt;&gt;::Iterator</a> it = map.begin(); it != map.end(); ++it)</div>
<div class="line">  {</div>
<div class="line">    cout &lt;&lt; it-&gt;getRT() &lt;&lt; <span class="stringliteral">&quot; - &quot;</span> &lt;&lt; it-&gt;getMZ() &lt;&lt; endl;</div>
<div class="line">  }</div>
<div class="line"></div>
<div class="line">  <span class="keywordflow">return</span> 0;</div>
<div class="line">} <span class="comment">//end of main</span></div>
</div><!-- fragment --></p>
<dl class="section user"><dt>RangeManager</dt><dd>All peak and feature containers (<em>MSSpectrum</em>, <em>MSExperiment</em>, <em>FeatureMap</em>) are also derived from <em>RangeManager</em>. This class facilitates the handling of MS data ranges. It allows to calculate and store both the position range and the intensity range of the container.</dd></dl>
<p>The following example (Tutorial_RangeManager.C) shows the functionality of the class <em>RangeManger</em> using a <em>FeatureMap</em>. First a <em>FeatureMap</em> with two features is created, then the ranges are calulated and printed:  <div class="fragment"><div class="line"><a class="code" href="classInt.html">Int</a> <a class="code" href="RNPxl_8C.html#a217dbf8b442f20279ea00b898af96f52">main</a>()</div>
<div class="line">{</div>
<div class="line">  <a class="code" href="classOpenMS_1_1FeatureMap.html">FeatureMap&lt;&gt;</a> map;</div>
<div class="line"></div>
<div class="line">  Feature feature;</div>
<div class="line">  feature.setIntensity(461.3f);</div>
<div class="line">  feature.setRT(15.0);</div>
<div class="line">  feature.setMZ(571.3);</div>
<div class="line">  map.push_back(feature);</div>
<div class="line">  feature.setIntensity(12213.5f);</div>
<div class="line">  feature.setRT(23.3);</div>
<div class="line">  feature.setMZ(1311.3);</div>
<div class="line">  map.push_back(feature);</div>
<div class="line"></div>
<div class="line">  <span class="comment">//calculate the ranges</span></div>
<div class="line">  map.<a class="code" href="classOpenMS_1_1FeatureMap.html#adda2fd1aa19da6622530d9073fbcf66d">updateRanges</a>();</div>
<div class="line"></div>
<div class="line">  cout &lt;&lt; <span class="stringliteral">&quot;Int: &quot;</span> &lt;&lt; map.<a class="code" href="classOpenMS_1_1RangeManager.html#afe0be2a3600705a1471df7caf6e9f07c">getMinInt</a>() &lt;&lt; <span class="stringliteral">&quot; - &quot;</span> &lt;&lt; map.<a class="code" href="classOpenMS_1_1RangeManager.html#a2aae292c90f0f138170dd774601a7139">getMaxInt</a>() &lt;&lt; endl;</div>
<div class="line">  cout &lt;&lt; <span class="stringliteral">&quot;RT:  &quot;</span> &lt;&lt; map.<a class="code" href="classOpenMS_1_1RangeManager.html#ad7e9497afbc70b1bd40dba2874802954">getMin</a>()[0] &lt;&lt; <span class="stringliteral">&quot; - &quot;</span> &lt;&lt; map.<a class="code" href="classOpenMS_1_1RangeManager.html#ab54df5a3894df5cebc88022e8684ff65">getMax</a>()[0] &lt;&lt; endl;</div>
<div class="line">  cout &lt;&lt; <span class="stringliteral">&quot;m/z: &quot;</span> &lt;&lt; map.<a class="code" href="classOpenMS_1_1RangeManager.html#ad7e9497afbc70b1bd40dba2874802954">getMin</a>()[1] &lt;&lt; <span class="stringliteral">&quot; - &quot;</span> &lt;&lt; map.<a class="code" href="classOpenMS_1_1RangeManager.html#ab54df5a3894df5cebc88022e8684ff65">getMax</a>()[1] &lt;&lt; endl;</div>
<div class="line"></div>
<div class="line">  <span class="keywordflow">return</span> 0;</div>
<div class="line">} <span class="comment">//end of main</span></div>
</div><!-- fragment --></p>
<p>The output of this program is: </p>
<div class="fragment"><div class="line"><a class="code" href="classInt.html">Int</a>: 461.3 - 12213.5</div>
<div class="line">RT:  15 - 23.3</div>
<div class="line">m/z: 571.3 - 1311.3</div>
</div><!-- fragment --> </div></div><!-- contents -->
<HR style="height:1px; border:none; border-top:1px solid #c0c0c0;">
<TABLE width="100%" border="0">
<TR>
<TD><font color="#c0c0c0">OpenMS / TOPP release 1.11.1</font></TD>
<TD align="right"><font color="#c0c0c0">Documentation generated on Thu Nov 14 2013 11:19:24 using doxygen 1.8.5</font></TD>
</TR>
</TABLE>
</BODY>
</HTML>