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

« back to all changes in this revision

Viewing changes to source/APPLICATIONS/TOPP/FeatureFinderIsotopeWavelet.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: Clemens Groepl $
 
25
// $Authors:  Clemens Groepl, Marc Sturm $
 
26
// --------------------------------------------------------------------------
 
27
 
 
28
#include <OpenMS/FORMAT/MzMLFile.h>
 
29
#include <OpenMS/FORMAT/FeatureXMLFile.h>
 
30
#include <OpenMS/KERNEL/StandardTypes.h>
 
31
#include <OpenMS/KERNEL/RangeUtils.h>
 
32
#include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/FeatureFinder_impl.h>
 
33
#include <OpenMS/APPLICATIONS/TOPPBase.h>
 
34
 
 
35
using namespace OpenMS;
 
36
using namespace std;
 
37
 
 
38
//-------------------------------------------------------------
 
39
//Doxygen docu
 
40
//-------------------------------------------------------------
 
41
 
 
42
/**
 
43
  @page TOPP_FeatureFinderIsotopeWavelet FeatureFinderIsotopeWavelet
 
44
 
 
45
        @brief The feature detection application for quantitation.
 
46
 
 
47
<CENTER>
 
48
        <table>
 
49
                <tr>
 
50
      <td ALIGN = "center" BGCOLOR="#EBEBEB" ROWSPAN=1> pot. predecessor tools </td>
 
51
      <td VALIGN="middle" ROWSPAN=3> \f$ \longrightarrow \f$ FeatureFinderIsotopeWavelet \f$ \longrightarrow \f$</td>
 
52
                        <td ALIGN = "center" BGCOLOR="#EBEBEB"> pot. successor tools </td>
 
53
                </tr>
 
54
                <tr>
 
55
      <td VALIGN="middle" ALIGN = "center" ROWSPAN=1> @ref TOPP_NoiseFilterSGolay </td>
 
56
      <td VALIGN="middle" ALIGN = "center" ROWSPAN=1> @ref TOPP_MapAlignerPoseClustering @n (or another alignment tool) </td>
 
57
    </tr>
 
58
                <tr>
 
59
      <td VALIGN="middle" ALIGN = "center" ROWSPAN=1> @ref TOPP_NoiseFilterGaussian </td>
 
60
      <td VALIGN="middle" ALIGN = "center" ROWSPAN=1> @ref TOPP_FeatureLinkerUnlabeled @n (or another feature grouping tool) </td>
 
61
                </tr>
 
62
        </table>
 
63
</CENTER>
 
64
 
 
65
        This module identifies "features" in a LC/MS map. By feature, we understand a peptide in a MS sample that
 
66
        reveals a characteristic isotope distribution. The algorithm
 
67
        computes positions in rt and m/z dimension and a charge estimate
 
68
        of each peptide.
 
69
 
 
70
        The algorithm identifies pronounced regions of the data around so-called <tt>seeds</tt>.
 
71
        In the next step, we iteratively fit a model of the isotope profile and the retention time to
 
72
        these data points. Data points with a low probability under this model are removed from the
 
73
        feature region. The intensity of the feature is then given by the sum of the data points included
 
74
        in its regions.
 
75
 
 
76
        How to find suitable parameters and details of the different algorithms implemented are described
 
77
        in the @ref TOPP_example_featuredetection "TOPP tutorial".
 
78
 
 
79
        @note that the wavelet transform is very slow on high-resolution spectra (i.e. FT, Orbitrap). We recommend
 
80
        to use a noise or intensity filter to remove spurious points first and to speed-up the feature detection process.
 
81
 
 
82
        Specialized tools are available for some experimental techniques: @ref TOPP_SILACAnalyzer, @ref TOPP_ITRAQAnalyzer.
 
83
 
 
84
        <B>The command line parameters of this tool are:</B>
 
85
  @verbinclude TOPP_FeatureFinderIsotopeWavelet.cli
 
86
 
 
87
        For the parameters of the algorithm section see the algorithms documentation: @n
 
88
    @ref OpenMS::FeatureFinderAlgorithmIsotopeWavelet "isotope_wavelet" @n
 
89
 
 
90
*/
 
91
 
 
92
// We do not want this class to show up in the docu:
 
93
/// @cond TOPPCLASSES
 
94
 
 
95
class TOPPFeatureFinderIsotopeWavelet
 
96
        : public TOPPBase
 
97
{
 
98
 public:
 
99
  TOPPFeatureFinderIsotopeWavelet()
 
100
    : TOPPBase("FeatureFinderIsotopeWavelet","Detects two-dimensional features in LC-MS data.")
 
101
        {
 
102
        }
 
103
 
 
104
 protected:
 
105
        void registerOptionsAndFlags_()
 
106
        {
 
107
                registerInputFile_("in","<file>","","input file");
 
108
                setValidFormats_("in",StringList::create("mzML"));
 
109
                registerOutputFile_("out","<file>","","output file");
 
110
                setValidFormats_("out",StringList::create("featureXML"));
 
111
                addEmptyLine_();
 
112
    addText_("All other options of the FeatureFinder are set in the 'algorithm' section of the INI file.\n");
 
113
 
 
114
                registerSubsection_("algorithm","Algorithm section");
 
115
        }
 
116
 
 
117
        Param getSubsectionDefaults_(const String& /*section*/) const
 
118
        {
 
119
    return FeatureFinder().getParameters(FeatureFinderAlgorithmIsotopeWavelet<Peak1D,Feature>::getProductName());
 
120
        }
 
121
 
 
122
  ExitCodes main_(int , const char**)
 
123
  {
 
124
    //input file names
 
125
    String in = getStringOption_("in");
 
126
 
 
127
    //prevent loading of fragment spectra
 
128
    PeakFileOptions options;
 
129
    options.setMSLevels(vector<Int>(1,1));
 
130
 
 
131
    //reading input data
 
132
    MzMLFile f;
 
133
    f.getOptions() = options;
 
134
    f.setLogType(log_type_);
 
135
 
 
136
    PeakMap exp;
 
137
    f.load(in, exp);
 
138
    exp.updateRanges();
 
139
 
 
140
    //no seeds supported
 
141
    FeatureMap<> seeds;
 
142
 
 
143
    //setup of FeatureFinder
 
144
    FeatureFinder ff;
 
145
    ff.setLogType(log_type_);
 
146
 
 
147
    // A map for the resulting features
 
148
    FeatureMap<> features;
 
149
 
 
150
    // get parameters specific for the feature finder
 
151
    Param feafi_param = getParam_().copy("algorithm:",true);
 
152
    writeDebug_("Parameters passed to FeatureFinder", feafi_param, 3);
 
153
 
 
154
    // Apply the feature finder
 
155
    ff.run(FeatureFinderAlgorithmIsotopeWavelet<Peak1D, Feature>::getProductName(), exp, features, feafi_param, seeds);
 
156
    features.applyMemberFunction(&UniqueIdInterface::setUniqueId);
 
157
 
 
158
    // DEBUG
 
159
    if (debug_level_ > 10)
 
160
    {
 
161
      FeatureMap<>::Iterator it;
 
162
      for (it = features.begin(); it != features.end(); ++it)
 
163
      {
 
164
        if (!it->isMetaEmpty())
 
165
        {
 
166
          vector<String> keys;
 
167
          it->getKeys(keys);
 
168
          LOG_INFO << "Feature " << it->getUniqueId() << endl;
 
169
          for (Size i = 0; i < keys.size(); i++)
 
170
          {
 
171
            LOG_INFO << "  " << keys[i] << " = " << it->getMetaValue(keys[i]) << endl;
 
172
          }
 
173
        }
 
174
      }
 
175
    }
 
176
 
 
177
    //-------------------------------------------------------------
 
178
    // writing files
 
179
    //-------------------------------------------------------------
 
180
 
 
181
    //annotate output with data processing info
 
182
    addDataProcessing_(features, getProcessingInfo_(DataProcessing::QUANTITATION));
 
183
 
 
184
    // write features to user specified output file
 
185
    FeatureXMLFile map_file;
 
186
    String out = getStringOption_("out");
 
187
 
 
188
    map_file.store(out,features);
 
189
 
 
190
    return EXECUTION_OK;
 
191
  }
 
192
};
 
193
 
 
194
 
 
195
int main( int argc, const char** argv )
 
196
{
 
197
  TOPPFeatureFinderIsotopeWavelet tool;
 
198
        return tool.main(argc,argv);
 
199
}
 
200
 
 
201
/// @endcond