tandemparameters.cpp 12.8 KB
Newer Older
1
2
3
4
5
6
7
8
/**
 * \file /core/tandem_run/tandemparameters.cpp
 * \date 19/9/2017
 * \author Olivier Langella
 * \brief handles X!Tandem parameters
 */

/*******************************************************************************
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 * Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>.
 *
 * This file is part of XTPcpp.
 *
 *     XTPcpp is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     XTPcpp is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with XTPcpp.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Contributors:
 *     Olivier Langella <olivier.langella@u-psud.fr> - initial API and
 *implementation
 ******************************************************************************/
30
31

#include "tandemparameters.h"
32
#include <QDebug>
33
#include <pappsomspp/exception/exceptionnotfound.h>
Langella Olivier's avatar
Langella Olivier committed
34
#include <pappsomspp/exception/exceptionnotpossible.h>
35

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 *
specific parameters for the modified TPP tandem version :
http://tools.proteomecenter.org/wiki/index.php?title=TPP:X%21Tandem_and_the_TPP

<note label="scoring, algorithm" type="input">k-score</note>
<note label="spectrum, use conditioning" type="input">no</note>
<note label="scoring, minimum ion count" type="input">1</note>
new labels :
"protein, taxon" https://www.thegpm.org/TANDEM/api/pt.html
"protein, homolog management"
"refine, sequence path" https://www.thegpm.org/TANDEM/api/rsp.html
 "refine, tic percent" https://www.thegpm.org/TANDEM/api/rtp.html
 "output, log path" https://www.thegpm.org/TANDEM/api/olp.html
 "output, message" https://www.thegpm.org/TANDEM/api/om.html
  "output, sequence path" https://www.thegpm.org/TANDEM/api/osp.html
   "output, path" https://www.thegpm.org/TANDEM/api/opath.html
Langella Olivier's avatar
Langella Olivier committed
53
54
55
  "protein, use annotations" https://www.thegpm.org/TANDEM/api/pua.html


Langella Olivier's avatar
Langella Olivier committed
56
57
   obsolete, not documented :
  "refine, maximum missed cleavage sites" 3
Langella Olivier's avatar
Langella Olivier committed
58
   "protein, use minimal annotations" yes no
Langella Olivier's avatar
Langella Olivier committed
59
   "scoring, pluggable scoring" yes no
60
61
*/

62
63
TandemParameters::TandemParameters()
{
64
}
65
66
TandemParameters::~TandemParameters()
{
67
68
}

69
70
TandemParameters::TandemParameters(const TandemParameters &other)
{
Langella Olivier's avatar
Langella Olivier committed
71
72
73
  qDebug() << "TandemParameters::TandemParameters copy begin";
  //_map_label_value = other._map_label_value;
  _method_name = other._method_name;
Olivier Langella's avatar
Olivier Langella committed
74

Langella Olivier's avatar
Langella Olivier committed
75
76
77
  QMap<QString, QString>::const_iterator i =
    other._map_label_value.constBegin();
  while(i != other._map_label_value.constEnd())
78
    {
Langella Olivier's avatar
Langella Olivier committed
79
80
81
82
      qDebug() << "TandemParameters::TandemParameters copy " << i.key() << " "
               << i.value();
      _map_label_value.insert(i.key(), i.value());
      i++; // added
Olivier Langella's avatar
Olivier Langella committed
83
    }
Langella Olivier's avatar
Langella Olivier committed
84
  qDebug() << "TandemParameters::TandemParameters copy end";
85
}
Langella Olivier's avatar
Langella Olivier committed
86
87


88
89
90
bool
TandemParameters::equals(const TandemParameters &other) const
{
Langella Olivier's avatar
Langella Olivier committed
91
  if(_method_name != other._method_name)
92
    {
Langella Olivier's avatar
Langella Olivier committed
93
      return false;
Langella Olivier's avatar
Langella Olivier committed
94
    }
Langella Olivier's avatar
Langella Olivier committed
95
  if(_map_label_value.size() != other._map_label_value.size())
96
    {
Langella Olivier's avatar
Langella Olivier committed
97
      return false;
Langella Olivier's avatar
Langella Olivier committed
98
    }
Langella Olivier's avatar
Langella Olivier committed
99
100
  QMap<QString, QString>::const_iterator i = _map_label_value.constBegin();
  while(i != _map_label_value.constEnd())
101
    {
Langella Olivier's avatar
Langella Olivier committed
102
      if(i.value() != other.getValue(i.key()))
103
        {
Langella Olivier's avatar
Langella Olivier committed
104
          return false;
Langella Olivier's avatar
Langella Olivier committed
105
        }
Langella Olivier's avatar
Langella Olivier committed
106
      i++; // added
Langella Olivier's avatar
Langella Olivier committed
107
    }
Langella Olivier's avatar
Langella Olivier committed
108
  return true;
Langella Olivier's avatar
Langella Olivier committed
109
110
}

111
112
113
const QString
TandemParameters::getLabelCategory(const QString &value) const
{
114

Langella Olivier's avatar
Langella Olivier committed
115
116
117
  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
           << value;
  return value.split(", ").at(0);
118
}
119
120
121
const QString &
TandemParameters::getValue(const QString &label) const
{
Langella Olivier's avatar
Langella Olivier committed
122
123
124
125
  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
           << label;
  QMap<QString, QString>::const_iterator it = _map_label_value.constFind(label);
  if(it == _map_label_value.end())
126
    {
Langella Olivier's avatar
Langella Olivier committed
127
128
129
130
      throw pappso::ExceptionNotFound(
        QObject::tr("X!Tandem preset label \"%1\" not found in method \"%2\"")
          .arg(label)
          .arg(_method_name));
131
    }
132
  qDebug();
Langella Olivier's avatar
Langella Olivier committed
133
  return it.value();
134
}
135
136
137
void
TandemParameters::setParamLabelValue(const QString &label, const QString &value)
{
138
  qDebug() << label;
Langella Olivier's avatar
Langella Olivier committed
139
140
141
142
143
144
  // list path
  //<note type="input" label="list path, default
  // parameters">/gorgone/pappso/tmp/temp_condor_job24872841484824316495370334631825647/QExactive_analysis_FDR_nosemi.xml</note>
  //<note type="input" label="list path, taxonomy
  // information">/gorgone/pappso/tmp/temp_condor_job24872841484824316495370334631825647/database.xml</note>
  if(getLabelCategory(label) == "list path")
145
    {
Langella Olivier's avatar
Langella Olivier committed
146
      return;
147
    }
148

149
  qDebug() << label;
Langella Olivier's avatar
Langella Olivier committed
150
151
  if((label == "spectrum, parent monoisotopic mass error units") ||
     (label == "spectrum, fragment monoisotopic mass error units"))
152
    {
Langella Olivier's avatar
Langella Olivier committed
153
      if((value != "Da") && (value != "Daltons") && (value != "ppm"))
154
        {
Langella Olivier's avatar
Langella Olivier committed
155
156
157
158
          throw pappso::ExceptionNotPossible(
            QObject::tr("\"%1\" value must be Daltons or ppm (not \"%2\")")
              .arg(label)
              .arg(value));
Langella Olivier's avatar
Langella Olivier committed
159
160
        }
    }
Langella Olivier's avatar
Langella Olivier committed
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
  else if((label == "spectrum, parent monoisotopic mass isotope error") ||
          (label == "spectrum, use neutral loss window") ||
          (label == "spectrum, use contrast angle") ||
          (label == "protein, cleavage semi") ||
          (label == "protein, quick acetyl") ||
          (label == "protein, quick pyrolidone") ||
          (label == "protein, stP bias") ||
          (label == "scoring, cyclic permutation") ||
          (label == "scoring, include reverse") ||
          (label == "scoring, y ions") || (label == "scoring, b ions") ||
          (label == "scoring, c ions") || (label == "scoring, z ions") ||
          (label == "scoring, a ions") || (label == "scoring, x ions") ||
          (label == "refine") ||
          (label ==
           "refine, use potential modifications for full refinement") ||
          (label == "refine, cleavage semi") ||
          (label == "refine, unanticipated cleavage") ||
          (label == "refine, spectrum synthesis") ||
          (label == "refine, point mutations") ||
          (label == "output, spectra") || (label == "output, proteins") ||
          (label == "output, sequences") ||
          (label == "output, one sequence copy") ||
          (label == "output, parameters") || (label == "output, performance") ||
          (label == "output, histograms") ||
          (label == "output, path hashing") ||
          (label == "spectrum, use conditioning") ||
          (label == "protein, homolog management") ||
          (label == "protein, use minimal annotations") ||
          (label == "protein, use annotations") ||
190
191
192
          (label == "scoring, pluggable scoring") ||
          (label == "output, mzid") ||
          (label == "spectrum, use noise suppression"))
193
    {
Langella Olivier's avatar
Langella Olivier committed
194
      if((value != "yes") && (value != "no"))
195
        {
Langella Olivier's avatar
Langella Olivier committed
196
197
198
199
          throw pappso::ExceptionNotPossible(
            QObject::tr("%1 value must be yes or no (not %2)")
              .arg(label)
              .arg(value));
Langella Olivier's avatar
Langella Olivier committed
200
201
        }
    }
Langella Olivier's avatar
Langella Olivier committed
202

Langella Olivier's avatar
Langella Olivier committed
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
  else if((label == "spectrum, parent monoisotopic mass error minus") ||
          (label == "spectrum, parent monoisotopic mass error plus") ||
          (label == "spectrum, dynamic range") ||
          (label == "spectrum, minimum parent m+h") ||
          (label == "protein, cleavage C-terminal mass change") ||
          (label == "protein, cleavage N-terminal mass change") ||
          (label == "protein, C-terminal residue modification mass") ||
          (label == "protein, N-terminal residue modification mass") ||
          (label == "refine, maximum valid expectation value") ||
          (label == "spectrum, fragment monoisotopic mass error") ||
          (label == "spectrum, neutral loss mass") ||
          (label == "spectrum, neutral loss window") ||
          (label == "spectrum, minimum fragment mz") ||
          (label == "output, maximum valid expectation value") ||
          (label == "output, maximum valid protein expectation value") ||
          (label == "refine, tic percent")
219
220


Langella Olivier's avatar
Langella Olivier committed
221
  )
Langella Olivier's avatar
Langella Olivier committed
222

223
    {
224

Langella Olivier's avatar
Langella Olivier committed
225
226
227
      bool ok;
      QString value_bis = value.simplified();
      if(value_bis.isEmpty())
228
        {
Langella Olivier's avatar
Langella Olivier committed
229
          value_bis = "0.0";
230
        }
Langella Olivier's avatar
Langella Olivier committed
231
232
233
234
235
236
237
      value_bis.toDouble(&ok);
      if(!ok)
        { // not an integer
          throw pappso::ExceptionNotPossible(
            QObject::tr("\"%1\" value must be a number (not \"%2\")")
              .arg(label)
              .arg(value));
Langella Olivier's avatar
Langella Olivier committed
238
239
        }
    }
Langella Olivier's avatar
Langella Olivier committed
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
  else if((label == "protein, cleavage site") ||
          (label == "protein, modified residue mass file") ||
          (label == "residue, modification mass") ||
          (label == "residue, modification mass 1") ||
          (label == "residue, modification mass 2") ||
          (label == "residue, potential modification mass") ||
          (label == "residue, potential modification motif") ||
          (label == "refine, potential N-terminus modifications") ||
          (label == "refine, potential C-terminus modifications") ||
          (label == "refine, modification mass") ||
          (label == "refine, modification mass 1") ||
          (label == "refine, modification mass 2") ||
          (label == "refine, potential modification mass") ||
          (label == "refine, potential modification mass 1") ||
          (label == "refine, potential modification mass 2") ||
          (label == "refine, potential modification motif") ||
          (label == "refine, potential modification motif 1") ||
          (label == "refine, potential modification motif 2") ||
          (label == "output, sort results by") ||
          (label == "output, xsl path") || (label == "spectrum, path") ||
          (label == "scoring, algorithm") || (label == "protein, taxon") ||
          (label == "refine, sequence path") || (label == "output, log path") ||
          (label == "output, message") || (label == "output, sequence path") ||
263
264
265
266
267
268
269
          (label == "output, path") ||
          (label == "residue, potential modification mass 1") ||
          (label == "residue, potential modification mass 2") ||
          (label == "residue, potential modification mass 3") ||
          (label == "residue, potential modification motif 1") ||
          (label == "residue, potential modification motif 2") ||
          (label == "residue, potential modification motif 3"))
270
    {
Langella Olivier's avatar
Langella Olivier committed
271
      // string
272
    }
Langella Olivier's avatar
Langella Olivier committed
273
274
275
276
277
278
279
280
281
  else if((label == "spectrum, maximum parent charge") ||
          (label == "spectrum, total peaks") ||
          (label == "spectrum, minimum peaks") ||
          (label == "spectrum, sequence batch size") ||
          (label == "spectrum, threads") ||
          (label == "scoring, minimum ion count") ||
          (label == "scoring, maximum missed cleavage sites") ||
          (label == "output, histogram column width") ||
          (label == "refine, maximum missed cleavage sites"))
282
    {
283

Langella Olivier's avatar
Langella Olivier committed
284
285
286
287
288
289
290
291
      bool ok;
      value.toInt(&ok);
      if(!ok)
        { // not an integer
          throw pappso::ExceptionNotPossible(
            QObject::tr("\"%1\" value must be an integer (not \"%2\")")
              .arg(label)
              .arg(value));
292
293
        }
    }
Langella Olivier's avatar
Langella Olivier committed
294
  else if(label == "spectrum, fragment mass type")
295
    {
Langella Olivier's avatar
Langella Olivier committed
296
      if((value != "monoisotopic") && (value != "average"))
297
298
        {
          throw pappso::ExceptionNotPossible(
Langella Olivier's avatar
Langella Olivier committed
299
300
            QObject::tr(
              "\"%1\" value must be monoisotopic or average (not \"%2\")")
301
302
              .arg(label)
              .arg(value));
Langella Olivier's avatar
Langella Olivier committed
303
304
        }
    }
Langella Olivier's avatar
Langella Olivier committed
305
  // tandem input parameter label "output, results" for value "valid" not known.
306

Langella Olivier's avatar
Langella Olivier committed
307
308
309
310
311
  else if(label == "output, results")
    {
      /*
      if((value != "all") && (value != "valid"))
      {
312
        throw pappso::ExceptionNotPossible(
Langella Olivier's avatar
Langella Olivier committed
313
          QObject::tr("\"%1\" value must be valid or all (not \"%2\")")
314
315
            .arg(label)
            .arg(value));
Langella Olivier's avatar
Langella Olivier committed
316
317
318
319
320
321
322
323
324
325
326
      }
      */
    }
  else
    {

      throw pappso::ExceptionNotPossible(
        QObject::tr(
          "tandem input parameter label \"%1\" for value \"%2\" not known.")
          .arg(label)
          .arg(value));
327
328
    }

Langella Olivier's avatar
Langella Olivier committed
329

Langella Olivier's avatar
Langella Olivier committed
330
331
332
333
334
335
336
337
338
339
  // text "protein, cleavage site" "protein, modified residue mass file"
  // "residue, modification mass"  || (label == "refine, potential N-terminus
  // modifications") || (label == "refine, potential C-terminus modifications")
  // spectrum, neutral loss mass
  // spectrum, neutral loss window
  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
           << label;
  _map_label_value.insert(label, value);
  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
           << label;
340
}
341
342
343
void
TandemParameters::setMethodName(const QString &method)
{
Langella Olivier's avatar
Langella Olivier committed
344
  _method_name = method;
345
}
346
347
348
const QString &
TandemParameters::getMethodName() const
{
Langella Olivier's avatar
Langella Olivier committed
349
  return _method_name;
350
}
351
352
353
const QMap<QString, QString> &
TandemParameters::getMapLabelValue() const
{
Langella Olivier's avatar
Langella Olivier committed
354
  return _map_label_value;
355
}