~ubuntu-branches/ubuntu/wily/openms/wily

« back to all changes in this revision

Viewing changes to source/APPLICATIONS/TOPP/MapNormalizer.C

  • Committer: Package Import Robot
  • Author(s): Filippo Rusconi
  • Date: 2012-11-12 15:58:12 UTC
  • Revision ID: package-import@ubuntu.com-20121112155812-vr15wtg9b50cuesg
Tags: upstream-1.9.0
ImportĀ upstreamĀ versionĀ 1.9.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- mode: C++; tab-width: 2; -*-
 
2
// vi: set ts=2:
 
3
//
 
4
// --------------------------------------------------------------------------
 
5
//                   OpenMS Mass Spectrometry Framework
 
6
// --------------------------------------------------------------------------
 
7
//  Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
 
8
//
 
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.
 
13
//
 
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.
 
18
//
 
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
 
22
//
 
23
// --------------------------------------------------------------------------
 
24
// $Maintainer: $
 
25
// $Authors: Marc Sturm $
 
26
// --------------------------------------------------------------------------
 
27
 
 
28
#include <OpenMS/FORMAT/MzMLFile.h>
 
29
 
 
30
#include <OpenMS/APPLICATIONS/TOPPBase.h>
 
31
 
 
32
using namespace OpenMS;
 
33
using namespace std;
 
34
 
 
35
//-------------------------------------------------------------
 
36
//Doxygen docu
 
37
//-------------------------------------------------------------
 
38
 
 
39
/**
 
40
        @page TOPP_MapNormalizer MapNormalizer
 
41
 
 
42
        @brief Normalizes peak intensities to the percentage of the maximum intensity in the HPLC-MS map.
 
43
 
 
44
<CENTER>
 
45
        <table>
 
46
                <tr>
 
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>
 
50
                </tr>
 
51
                <tr>
 
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>
 
54
                </tr>
 
55
        </table>
 
56
</CENTER>
 
57
 
 
58
        <B>The command line parameters of this tool are:</B>
 
59
        @verbinclude TOPP_MapNormalizer.cli
 
60
*/
 
61
 
 
62
// We do not want this class to show up in the docu:
 
63
/// @cond TOPPCLASSES
 
64
 
 
65
class TOPPMapNormalizer
 
66
        : public TOPPBase
 
67
{
 
68
        public:
 
69
                TOPPMapNormalizer()
 
70
                        : TOPPBase("MapNormalizer","Normalizes peak intensities in an MS run.")
 
71
                {
 
72
 
 
73
                }
 
74
 
 
75
        protected:
 
76
 
 
77
                void registerOptionsAndFlags_()
 
78
                {
 
79
                        registerInputFile_("in","<file>","","input file ");
 
80
                        setValidFormats_("in",StringList::create("mzML"));
 
81
                        registerOutputFile_("out","<file>","","output file ");
 
82
                setValidFormats_("out",StringList::create("mzML"));
 
83
                }
 
84
 
 
85
                ExitCodes main_(int , const char**)
 
86
                {
 
87
 
 
88
                        //-------------------------------------------------------------
 
89
                        // parameter handling
 
90
                        //-------------------------------------------------------------
 
91
 
 
92
                        String in = getStringOption_("in");
 
93
                        String out = getStringOption_("out");
 
94
 
 
95
                        //-------------------------------------------------------------
 
96
                        // loading input
 
97
                        //-------------------------------------------------------------
 
98
 
 
99
                        MSExperiment<Peak1D> exp;
 
100
                        MzMLFile f;
 
101
                        f.load(in,exp);
 
102
 
 
103
                        //-------------------------------------------------------------
 
104
                        // calculations
 
105
                        //-------------------------------------------------------------
 
106
 
 
107
                        //determine maximum peak
 
108
                        exp.updateRanges();
 
109
                        DoubleReal max = exp.getMaxInt() / 100.0;
 
110
 
 
111
                        for (MSExperiment<Peak1D>::Iterator it = exp.begin(); it!= exp.end(); ++it)
 
112
                        {
 
113
                                if (it->getMSLevel() < 2)
 
114
                                {
 
115
                                        for (MSExperiment<Peak1D>::SpectrumType::Iterator it2 = it->begin(); it2!= it->end(); ++it2)
 
116
                                        {
 
117
                                                it2->setIntensity( it2->getIntensity() / max);
 
118
                                        }
 
119
                                }
 
120
                        }
 
121
 
 
122
 
 
123
                        /// @todo add chromatogram support for normalization, e.g. for MRM stuff (Andreas)
 
124
                  /*
 
125
                        vector<MSChromatogram<> > chroms = exp.getChromatograms();
 
126
                        DoubleReal sum(0);
 
127
      for (vector<MSChromatogram<> >::iterator it = chroms.begin(); it != chroms.end(); ++it)
 
128
      {
 
129
        for (MSChromatogram<>::Iterator it2 = it->begin(); it2 != it->end(); ++it2)
 
130
        {
 
131
                                        sum += it2->getIntensity();
 
132
                                }
 
133
                        }
 
134
 
 
135
                        for (vector<MSChromatogram<> >::iterator it = chroms.begin(); it != chroms.end(); ++it)
 
136
                        {
 
137
                                for (MSChromatogram<>::Iterator it2 = it->begin(); it2 != it->end(); ++it2)
 
138
                                {
 
139
                                        it2->setIntensity(it2->getIntensity() / sum * 1000000.0);
 
140
                                }
 
141
                        }
 
142
 
 
143
                        exp.setChromatograms(chroms);
 
144
                  */
 
145
 
 
146
                        //-------------------------------------------------------------
 
147
                        // writing output
 
148
                        //-------------------------------------------------------------
 
149
 
 
150
                        //annotate output with data processing info
 
151
                        addDataProcessing_(exp, getProcessingInfo_(DataProcessing::NORMALIZATION));
 
152
 
 
153
                        f.store(out,exp);
 
154
 
 
155
                        return EXECUTION_OK;
 
156
                }
 
157
};
 
158
 
 
159
 
 
160
int main( int argc, const char** argv )
 
161
{
 
162
        TOPPMapNormalizer tool;
 
163
        return tool.main(argc,argv);
 
164
}
 
165
 
 
166
/// @endcond