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
1
// --------------------------------------------------------------------------
2
// OpenMS -- Open-Source Mass Spectrometry
3
// --------------------------------------------------------------------------
4
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5
// ETH Zurich, and Freie Universitaet Berlin 2002-2013.
7
// This software is released under a three-clause BSD license:
8
// * Redistributions of source code must retain the above copyright
9
// notice, this list of conditions and the following disclaimer.
10
// * Redistributions in binary form must reproduce the above copyright
11
// notice, this list of conditions and the following disclaimer in the
12
// documentation and/or other materials provided with the distribution.
13
// * Neither the name of any author or any participating institution
14
// may be used to endorse or promote products derived from this software
15
// without specific prior written permission.
16
// For a full list of authors, refer to the file AUTHORS.
17
// --------------------------------------------------------------------------
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
// ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22
// INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
30
// --------------------------------------------------------------------------
24
31
// $Maintainer: Andreas Bertsch $
37
44
//-------------------------------------------------------------
40
@page UTILS_DeMeanderize DeMeanderize
42
@brief Repairs MALDI experiments which were spotted line by line.
46
<B>The command line parameters of this tool are:</B>
47
@verbinclude UTILS_DeMeanderize.cli
47
@page UTILS_DeMeanderize DeMeanderize
49
@brief Repairs MALDI experiments which were spotted line by line.
53
<B>The command line parameters of this tool are:</B>
54
@verbinclude UTILS_DeMeanderize.cli
55
<B>INI file documentation of this tool:</B>
56
@htmlinclude UTILS_DeMeanderize.html
50
59
// We do not want this class to show up in the docu:
51
60
/// @cond TOPPCLASSES
53
class TOPPDeMeanderize
62
class TOPPDeMeanderize :
58
: TOPPBase("DeMeanderize","Orders the spectra of MALDI spotting plates correctly.", false)
64
void registerOptionsAndFlags_()
66
registerInputFile_("in","<mzML-file>","","Input experiment file, containing the wrongly sorted spectra.");
67
setValidFormats_("in", StringList::create("mzML"));
68
registerOutputFile_("out","<mzML-file>","","Output experiment file with correctly sorted spectra.");
69
setValidFormats_("out", StringList::create("mzML"));
70
registerIntOption_("num_spots_per_row", "<integer>", 48, "Number of spots in one column, until next row is spotted.", false);
71
setMinInt_("num_spots_per_row", 1);
72
registerDoubleOption_("RT_distance", "<integer>", 1.0, "RT distance between two spots which is used to calculated pseudo RT.", false, true);
73
setMinFloat_("RT_distance", 0.0);
76
ExitCodes main_(int , const char**)
78
//-------------------------------------------------------------
80
//-------------------------------------------------------------
81
String in(getStringOption_("in"));
82
String out(getStringOption_("out"));
83
Size num_spots_per_row(getIntOption_("num_spots_per_row"));
84
DoubleReal RT_distance(getDoubleOption_("RT_distance"));
86
//-------------------------------------------------------------
88
//-------------------------------------------------------------
92
f.setLogType(log_type_);
95
//-------------------------------------------------------------
97
//-------------------------------------------------------------
100
pl.setLogType(log_type_);
101
pl.startProgress(0, exp.size(), "Assigning pseudo RTs.");
102
Size num_ms1(0), num_ms1_base(0), row_counter(0);
103
bool row_to_reverse(false);
104
DoubleReal actual_RT(0);
105
for (Size i = 0; i != exp.size(); ++i)
110
actual_RT = (DoubleReal)(num_ms1_base + (num_spots_per_row - row_counter)) * RT_distance;
111
writeDebug_("RT=" + String(actual_RT) + " (modified, row_counter=" + String(row_counter) + ")", 1);
115
actual_RT = (DoubleReal)num_ms1 * RT_distance;
116
writeDebug_("RT=" + String(actual_RT), 1);
119
exp[i].setRT(actual_RT);
121
if (exp[i].getMSLevel() == 1)
123
if (++row_counter >= num_spots_per_row)
128
row_to_reverse = false;
132
row_to_reverse = true;
138
num_ms1_base = num_ms1;
144
// sort the spectra according to their new RT
147
//-------------------------------------------------------------
149
//-------------------------------------------------------------
67
TOPPBase("DeMeanderize", "Orders the spectra of MALDI spotting plates correctly.", false)
73
void registerOptionsAndFlags_()
75
registerInputFile_("in", "<mzML-file>", "", "Input experiment file, containing the wrongly sorted spectra.");
76
setValidFormats_("in", StringList::create("mzML"));
77
registerOutputFile_("out", "<mzML-file>", "", "Output experiment file with correctly sorted spectra.");
78
setValidFormats_("out", StringList::create("mzML"));
79
registerIntOption_("num_spots_per_row", "<integer>", 48, "Number of spots in one column, until next row is spotted.", false);
80
setMinInt_("num_spots_per_row", 1);
81
registerDoubleOption_("RT_distance", "<integer>", 1.0, "RT distance between two spots which is used to calculated pseudo RT.", false, true);
82
setMinFloat_("RT_distance", 0.0);
85
ExitCodes main_(int, const char **)
87
//-------------------------------------------------------------
89
//-------------------------------------------------------------
90
String in(getStringOption_("in"));
91
String out(getStringOption_("out"));
92
Size num_spots_per_row(getIntOption_("num_spots_per_row"));
93
DoubleReal RT_distance(getDoubleOption_("RT_distance"));
95
//-------------------------------------------------------------
97
//-------------------------------------------------------------
101
f.setLogType(log_type_);
104
//-------------------------------------------------------------
106
//-------------------------------------------------------------
109
pl.setLogType(log_type_);
110
pl.startProgress(0, exp.size(), "Assigning pseudo RTs.");
111
Size num_ms1(0), num_ms1_base(0), row_counter(0);
112
bool row_to_reverse(false);
113
DoubleReal actual_RT(0);
114
for (Size i = 0; i != exp.size(); ++i)
119
actual_RT = (DoubleReal)(num_ms1_base + (num_spots_per_row - row_counter)) * RT_distance;
120
writeDebug_("RT=" + String(actual_RT) + " (modified, row_counter=" + String(row_counter) + ")", 1);
124
actual_RT = (DoubleReal)num_ms1 * RT_distance;
125
writeDebug_("RT=" + String(actual_RT), 1);
128
exp[i].setRT(actual_RT);
130
if (exp[i].getMSLevel() == 1)
132
if (++row_counter >= num_spots_per_row)
137
row_to_reverse = false;
141
row_to_reverse = true;
147
num_ms1_base = num_ms1;
153
// sort the spectra according to their new RT
156
//-------------------------------------------------------------
158
//-------------------------------------------------------------
158
int main( int argc, const char** argv )
168
int main(int argc, const char ** argv)
160
TOPPDeMeanderize tool;
161
return tool.main(argc,argv);
170
TOPPDeMeanderize tool;
171
return tool.main(argc, argv);