1
// -*- mode: C++; tab-width: 2; -*-
4
// --------------------------------------------------------------------------
5
// OpenMS Mass Spectrometry Framework
6
// --------------------------------------------------------------------------
7
// Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
9
// This library is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU Lesser General Public
11
// License as published by the Free Software Foundation; either
12
// version 2.1 of the License, or (at your option) any later version.
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
// Lesser General Public License for more details.
19
// You should have received a copy of the GNU Lesser General Public
20
// License along with this library; if not, write to the Free Software
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
// --------------------------------------------------------------------------
25
// $Authors: Marc Sturm $
26
// --------------------------------------------------------------------------
28
#include <OpenMS/FORMAT/MzMLFile.h>
30
#include <OpenMS/APPLICATIONS/TOPPBase.h>
32
using namespace OpenMS;
35
//-------------------------------------------------------------
37
//-------------------------------------------------------------
40
@page TOPP_MapNormalizer MapNormalizer
42
@brief Normalizes peak intensities to the percentage of the maximum intensity in the HPLC-MS map.
47
<td ALIGN = "center" BGCOLOR="#EBEBEB"> pot. predecessor tools </td>
48
<td VALIGN="middle" ROWSPAN=2> \f$ \longrightarrow \f$ MapNormalizer \f$ \longrightarrow \f$</td>
49
<td ALIGN = "center" BGCOLOR="#EBEBEB"> pot. successor tools </td>
52
<td VALIGN="middle" ALIGN = "center" ROWSPAN=1> @ref TOPP_PeakPickerWavelet </td>
53
<td VALIGN="middle" ALIGN = "center" ROWSPAN=1> any tool operating on MS peak data @n (in mzML format)</td>
58
<B>The command line parameters of this tool are:</B>
59
@verbinclude TOPP_MapNormalizer.cli
62
// We do not want this class to show up in the docu:
65
class TOPPMapNormalizer
70
: TOPPBase("MapNormalizer","Normalizes peak intensities in an MS run.")
77
void registerOptionsAndFlags_()
79
registerInputFile_("in","<file>","","input file ");
80
setValidFormats_("in",StringList::create("mzML"));
81
registerOutputFile_("out","<file>","","output file ");
82
setValidFormats_("out",StringList::create("mzML"));
85
ExitCodes main_(int , const char**)
88
//-------------------------------------------------------------
90
//-------------------------------------------------------------
92
String in = getStringOption_("in");
93
String out = getStringOption_("out");
95
//-------------------------------------------------------------
97
//-------------------------------------------------------------
99
MSExperiment<Peak1D> exp;
103
//-------------------------------------------------------------
105
//-------------------------------------------------------------
107
//determine maximum peak
109
DoubleReal max = exp.getMaxInt() / 100.0;
111
for (MSExperiment<Peak1D>::Iterator it = exp.begin(); it!= exp.end(); ++it)
113
if (it->getMSLevel() < 2)
115
for (MSExperiment<Peak1D>::SpectrumType::Iterator it2 = it->begin(); it2!= it->end(); ++it2)
117
it2->setIntensity( it2->getIntensity() / max);
123
/// @todo add chromatogram support for normalization, e.g. for MRM stuff (Andreas)
125
vector<MSChromatogram<> > chroms = exp.getChromatograms();
127
for (vector<MSChromatogram<> >::iterator it = chroms.begin(); it != chroms.end(); ++it)
129
for (MSChromatogram<>::Iterator it2 = it->begin(); it2 != it->end(); ++it2)
131
sum += it2->getIntensity();
135
for (vector<MSChromatogram<> >::iterator it = chroms.begin(); it != chroms.end(); ++it)
137
for (MSChromatogram<>::Iterator it2 = it->begin(); it2 != it->end(); ++it2)
139
it2->setIntensity(it2->getIntensity() / sum * 1000000.0);
143
exp.setChromatograms(chroms);
146
//-------------------------------------------------------------
148
//-------------------------------------------------------------
150
//annotate output with data processing info
151
addDataProcessing_(exp, getProcessingInfo_(DataProcessing::NORMALIZATION));
160
int main( int argc, const char** argv )
162
TOPPMapNormalizer tool;
163
return tool.main(argc,argv);