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

« back to all changes in this revision

Viewing changes to source/APPLICATIONS/TOPP/SpectraFilterWindowMower.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: Mathias Walzer$
 
25
// $Authors: $
 
26
// --------------------------------------------------------------------------
 
27
 
 
28
 
 
29
#include <OpenMS/APPLICATIONS/TOPPBase.h>
 
30
#include <OpenMS/FILTERING/TRANSFORMERS/WindowMower.h>
 
31
#include <OpenMS/FORMAT/MzMLFile.h>
 
32
 
 
33
#include <typeinfo>
 
34
 
 
35
using namespace OpenMS;
 
36
using namespace std;
 
37
 
 
38
/**
 
39
  @page TOPP_SpectraFilterWindowMower SpectraFilterWindowMower
 
40
 
 
41
        @brief Filters the top Peaks in the given spectra according to a given schema/thresholdset
 
42
        
 
43
<CENTER>
 
44
        <table>
 
45
                <tr>
 
46
                        <td ALIGN = "center" BGCOLOR="#EBEBEB"> pot. predecessor tools </td>
 
47
                        <td VALIGN="middle" ROWSPAN=2> \f$ \longrightarrow \f$ SpectraFilter \f$ \longrightarrow \f$</td>
 
48
                        <td ALIGN = "center" BGCOLOR="#EBEBEB"> pot. successor tools </td>
 
49
                </tr>
 
50
                <tr>
 
51
      <td VALIGN="middle" ALIGN = "center" ROWSPAN=1> @ref TOPP_PeakPickerWavelet </td>
 
52
                        <td VALIGN="middle" ALIGN = "center" ROWSPAN=1> any tool operating on MS peak data @n (in mzML format)</td>
 
53
                </tr>
 
54
        </table>
 
55
</CENTER>
 
56
 
 
57
 
 
58
 
 
59
        <B>The command line parameters of this tool are:</B>
 
60
  @verbinclude TOPP_SpectraFilterWindowMower.cli
 
61
 
 
62
        For the parameters of the algorithm section see the class documentation: @n
 
63
                @ref OpenMS::WindowMower @n
 
64
*/
 
65
 
 
66
 
 
67
// We do not want this class to show up in the docu:
 
68
/// @cond TOPPCLASSES
 
69
 
 
70
class TOPPSpectraFilterWindowMower
 
71
        : public TOPPBase
 
72
{
 
73
        public:
 
74
    TOPPSpectraFilterWindowMower()
 
75
      : TOPPBase("SpectraFilterWindowMower", "Applies thresholdfilter to peak spectra.")
 
76
                {
 
77
                }
 
78
 
 
79
        protected:
 
80
 
 
81
                void registerOptionsAndFlags_()
 
82
                {
 
83
                        registerInputFile_("in", "<file>", "", "input file ");
 
84
                        setValidFormats_("in",StringList::create("mzML"));
 
85
                        registerOutputFile_("out", "<file>", "", "output file ");
 
86
                setValidFormats_("out",StringList::create("mzML"));
 
87
 
 
88
                        // register one section for each algorithm
 
89
                        registerSubsection_("algorithm","Algorithm parameter subsection.");
 
90
                        
 
91
                }
 
92
                
 
93
                Param getSubsectionDefaults_(const String& /*section*/) const
 
94
                {
 
95
                        return WindowMower().getParameters();
 
96
                }
 
97
                
 
98
                ExitCodes main_(int , const char**)
 
99
                {
 
100
                        //-------------------------------------------------------------
 
101
                        // parameter handling
 
102
                        //-------------------------------------------------------------
 
103
 
 
104
                        //input/output files
 
105
                        String in(getStringOption_("in"));
 
106
                        String out(getStringOption_("out"));
 
107
 
 
108
      //-------------------------------------------------------------
 
109
      // loading input
 
110
      //-------------------------------------------------------------
 
111
 
 
112
      MSExperiment<> exp;
 
113
      MzMLFile f;
 
114
      f.setLogType(log_type_);
 
115
      f.load(in, exp);
 
116
 
 
117
      //-------------------------------------------------------------
 
118
      // if meta data arrays are present, remove them and warn
 
119
      //-------------------------------------------------------------
 
120
                        if (exp.clearMetaDataArrays())
 
121
                        {
 
122
                                writeLog_("Warning: Spectrum meta data arrays cannot be sorted. They are deleted.");
 
123
                        }
 
124
 
 
125
      //-------------------------------------------------------------
 
126
      // filter
 
127
      //-------------------------------------------------------------
 
128
                        Param filter_param = getParam_().copy("algorithm:", true);
 
129
                        writeDebug_("Used filter parameters", filter_param, 3);
 
130
                        
 
131
                        WindowMower filter;
 
132
                        filter.setParameters(filter_param);
 
133
                        filter.filterPeakMap(exp);
 
134
 
 
135
                        //-------------------------------------------------------------
 
136
                        // writing output
 
137
                        //-------------------------------------------------------------
 
138
 
 
139
                        //annotate output with data processing info
 
140
                        addDataProcessing_(exp, getProcessingInfo_(DataProcessing::FILTERING));
 
141
 
 
142
                        f.store(out, exp);
 
143
 
 
144
                        return EXECUTION_OK;
 
145
                }
 
146
};
 
147
 
 
148
/// @endcond
 
149
 
 
150
 
 
151
int main( int argc, const char** argv )
 
152
{
 
153
  TOPPSpectraFilterWindowMower tool;
 
154
        return tool.main(argc,argv);
 
155
}
 
156