Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
TargetedExperimentHelper.h
Go to the documentation of this file.
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.
6 //
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.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Andreas Bertsch $
32 // $Authors: Andreas Bertsch $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_ANALYSIS_TARGETED_TARGETEDEXPERIMENTHELPER_H
36 #define OPENMS_ANALYSIS_TARGETED_TARGETEDEXPERIMENTHELPER_H
37 
39 #include <OpenMS/METADATA/CVTerm.h>
41 
42 #include <boost/numeric/conversion/cast.hpp>
43 
44 namespace OpenMS
45 {
52  namespace TargetedExperimentHelper
53  {
54 
55  struct Configuration :
56  public CVTermList
57  {
60  std::vector<CVTermList> validations;
61 
63  {
64  if (this != &rhs)
65  {
70  }
71  return *this;
72  }
73 
74  };
75 
76  struct CV
77  {
78  CV(const String & new_id, const String & new_fullname, const String & new_version, const String & new_URI) :
79  id(new_id),
80  fullname(new_fullname),
81  version(new_version),
82  URI(new_URI)
83  {
84 
85  }
86 
91 
92  bool operator==(const CV & cv) const
93  {
94  return id == cv.id &&
95  fullname == cv.fullname &&
96  version == cv.version &&
97  URI == cv.URI;
98  }
99 
100  };
101 
102  struct Protein :
103  public CVTermList
104  {
106  CVTermList()
107  {
108  }
109 
112 
113  bool operator==(const Protein & rhs) const
114  {
115  return CVTermList::operator==(rhs) &&
116  id == rhs.id &&
117  sequence == rhs.sequence;
118  }
119 
120  Protein & operator=(const Protein & rhs)
121  {
122  if (&rhs != this)
123  {
125  id = rhs.id;
126  sequence = rhs.sequence;
127  }
128  return *this;
129  }
130 
131  };
132 
133  class OPENMS_DLLAPI RetentionTime :
134  public CVTermList
135  {
136 public:
137 
139  CVTermList()
140  {
141  }
142 
144  CVTermList(rhs),
145  software_ref(rhs.software_ref)
146  {
147  }
148 
149  virtual ~RetentionTime()
150  {
151  }
152 
154  {
155  if (&rhs != this)
156  {
158  software_ref = rhs.software_ref;
159  }
160  return *this;
161  }
162 
163  bool operator==(const RetentionTime & rhs) const
164  {
165  return CVTermList::operator==(rhs) &&
166  software_ref == rhs.software_ref;
167  }
168 
170  };
171 
172  class OPENMS_DLLAPI Compound :
173  public CVTermList
174  {
175 public:
176 
178  CVTermList()
179  {
180  }
181 
182  Compound(const Compound & rhs) :
183  CVTermList(rhs),
184  id(rhs.id),
185  rts(rhs.rts)
186  {
187  }
188 
189  Compound & operator=(const Compound & rhs)
190  {
191  if (this != &rhs)
192  {
194  id = rhs.id;
195  rts = rhs.rts;
196  }
197  return *this;
198  }
199 
200  bool operator==(const Compound & rhs) const
201  {
202  return CVTermList::operator==(rhs) &&
203  id == rhs.id &&
204  rts == rhs.rts;
205  }
206 
208  std::vector<RetentionTime> rts;
209  };
210 
211  class OPENMS_DLLAPI Peptide :
212  public CVTermList
213  {
214 public:
215 
216  struct Modification :
217  public CVTermList
218  {
220  int location;
222  };
223 
225  CVTermList()
226  {
227  charge_ = -1;
228  peptide_group_label_ = -1;
229 
230  // we store the actual labels in a static vector which allows us to
231  // store each label only once.
232  static std::vector<String> * init_peptide_group_labels_ = 0;
233  if (init_peptide_group_labels_ == 0)
234  {
235  init_peptide_group_labels_ = new std::vector<String>;
236  }
237  peptide_group_labels_ = init_peptide_group_labels_;
238  }
239 
240  Peptide(const Peptide & rhs) :
241  CVTermList(rhs),
242  rts(rhs.rts),
243  id(rhs.id),
244  protein_refs(rhs.protein_refs),
245  evidence(rhs.evidence),
246  sequence(rhs.sequence),
247  mods(rhs.mods),
248  charge_(rhs.charge_),
249  peptide_group_label_(rhs.peptide_group_label_),
250  peptide_group_labels_(rhs.peptide_group_labels_)
251  {
252  }
253 
254  Peptide & operator=(const Peptide & rhs)
255  {
256  if (this != &rhs)
257  {
259  rts = rhs.rts;
260  id = rhs.id;
261  protein_refs = rhs.protein_refs;
262  evidence = rhs.evidence;
263  sequence = rhs.sequence;
264  mods = rhs.mods;
265  charge_ = rhs.charge_;
266  peptide_group_label_ = rhs.peptide_group_label_;
267  peptide_group_labels_ = rhs.peptide_group_labels_;
268  }
269  return *this;
270  }
271 
272  bool operator==(const Peptide & rhs) const
273  {
274  return CVTermList::operator==(rhs) &&
275  rts == rhs.rts &&
276  id == rhs.id &&
277  protein_refs == rhs.protein_refs &&
278  evidence == rhs.evidence &&
279  sequence == rhs.sequence &&
280  mods == rhs.mods &&
281  charge_ == rhs.charge_ &&
282  peptide_group_label_ == rhs.peptide_group_label_ &&
283  peptide_group_labels_ == rhs.peptide_group_labels_;
284  }
285 
286  void setChargeState(int charge)
287  {
288  charge_ = charge;
289  }
290 
291  int getChargeState() const
292  {
293  return charge_;
294  }
295 
296  void setPeptideGroupLabel(const String & label)
297  {
298  for (Size i = 0; i < peptide_group_labels_->size(); i++)
299  {
300  if ((*peptide_group_labels_)[i] == label)
301  {
302  peptide_group_label_ = (Int)i;
303  return;
304  }
305  }
306 
307  // not found, add it to the list
308  peptide_group_label_ = (Int)peptide_group_labels_->size();
309  peptide_group_labels_->push_back(label);
310  }
311 
313  {
314  if (peptide_group_label_ == -1)
315  {
316  return "";
317  }
318  return (*peptide_group_labels_)[peptide_group_label_];
319  }
320 
321  double getRetentionTime() const
322  {
323  // some guesstimate which would be the retention time that the user
324  // would like to have...
325  if (rts.empty() || rts[0].getCVTerms()["MS:1000896"].empty())
326  {
327  throw Exception::IllegalArgument(__FILE__, __LINE__, __PRETTY_FUNCTION__,
328  "No retention time information (CV term 1000896) available");
329  }
330  return rts[0].getCVTerms()["MS:1000896"][0].getValue().toString().toDouble();
331  }
332 
333  std::vector<RetentionTime> rts;
335  std::vector<String> protein_refs;
338  std::vector<Modification> mods;
339 
340 protected:
341  int charge_;
343  std::vector<String> * peptide_group_labels_;
344  };
345 
346  struct OPENMS_DLLAPI Contact :
347  public CVTermList
348  {
350  CVTermList()
351  {
352  }
353 
355 
356  bool operator==(const Contact & rhs) const
357  {
358  return CVTermList::operator==(rhs) &&
359  id == rhs.id;
360  }
361 
362  Contact & operator=(const Contact & rhs)
363  {
364  if (&rhs != this)
365  {
367  id = rhs.id;
368  }
369  return *this;
370  }
371 
372  };
373 
374  struct OPENMS_DLLAPI Publication :
375  public CVTermList
376  {
378  CVTermList()
379  {
380  }
381 
383 
384  bool operator==(const Publication & rhs) const
385  {
386  return CVTermList::operator==(rhs) &&
387  id == rhs.id;
388  }
389 
391  {
392  if (&rhs != this)
393  {
395  id = rhs.id;
396  }
397  return *this;
398  }
399 
400  };
401 
402  struct OPENMS_DLLAPI Instrument :
403  public CVTermList
404  {
406  CVTermList()
407  {
408  }
409 
411 
412  bool operator==(const Instrument & rhs) const
413  {
414  return CVTermList::operator==(rhs) &&
415  id == rhs.id;
416  }
417 
419  {
420  if (&rhs != this)
421  {
423  id = rhs.id;
424  }
425  return *this;
426  }
427 
428  };
429 
430  struct OPENMS_DLLAPI Prediction :
431  public CVTermList
432  {
434  CVTermList()
435  {
436  }
437 
440 
441  bool operator==(const Prediction & rhs) const
442  {
443  return CVTermList::operator==(rhs) &&
444  contact_ref == rhs.contact_ref &&
445  software_ref == rhs.software_ref;
446  }
447 
449  {
450  if (&rhs != this)
451  {
453  software_ref = rhs.software_ref;
454  contact_ref = rhs.contact_ref;
455  }
456  return *this;
457  }
458 
459  };
460 
461  struct OPENMS_DLLAPI TraMLProduct :
462  public CVTermList
463  {
465  CVTermList()
466  {
467  charge_ = -1;
468  }
469 
470  bool operator==(const TraMLProduct & rhs) const
471  {
472  return CVTermList::operator==(rhs) &&
473  charge_ == rhs.charge_ &&
474  configuration_list_ == rhs.configuration_list_ &&
475  interpretation_list_ == rhs.interpretation_list_;
476  }
477 
479  {
480  if (&rhs != this)
481  {
483  charge_ = rhs.charge_;
484  configuration_list_ = rhs.configuration_list_;
485  interpretation_list_ = rhs.interpretation_list_;
486  }
487  return *this;
488  }
489 
490  void setChargeState(int charge)
491  {
492  charge_ = charge;
493  }
494 
495  int getChargeState() const
496  {
497  return charge_;
498  }
499 
500  const std::vector<Configuration> & getConfigurationList() const
501  {
502  return configuration_list_;
503  }
504 
505  void addConfiguration(const Configuration configuration)
506  {
507  return configuration_list_.push_back(configuration);
508  }
509 
510  void replaceCVTerms(Map<String, std::vector<CVTerm> > & cv_terms)
511  {
512  cv_terms_ = cv_terms;
513  }
514 
515  const std::vector<CVTermList> & getInterpretationList() const
516  {
517  return interpretation_list_;
518  }
519 
520  void addInterpretation(const CVTermList interpretation)
521  {
522  return interpretation_list_.push_back(interpretation);
523  }
524 
525 private:
526  int charge_;
527  std::vector<Configuration> configuration_list_;
528  std::vector<CVTermList> interpretation_list_;
529 
530  };
531 
533  OPENMS_DLLAPI OpenMS::AASequence getAASequence(const Peptide& peptide);
534 
536  OPENMS_DLLAPI void setModification(int location, int max_size, String modification, OpenMS::AASequence & aas);
537 
538  }
539 } // namespace OpenMS
540 
541 #endif // OPENMS_ANALYSIS_TARGETED_TARGETEDEXPERIMENTHELPER_H
void addConfiguration(const Configuration configuration)
Definition: TargetedExperimentHelper.h:505
Peptide(const Peptide &rhs)
Definition: TargetedExperimentHelper.h:240
bool operator==(const Contact &rhs) const
Definition: TargetedExperimentHelper.h:356
virtual ~RetentionTime()
Definition: TargetedExperimentHelper.h:149
CVTermList evidence
Definition: TargetedExperimentHelper.h:336
A more convenient string class.
Definition: String.h:56
Protein & operator=(const Protein &rhs)
Definition: TargetedExperimentHelper.h:120
Representation of controlled vocabulary term list.
Definition: CVTermList.h:54
void setChargeState(int charge)
Definition: TargetedExperimentHelper.h:490
Compound & operator=(const Compound &rhs)
Definition: TargetedExperimentHelper.h:189
Configuration & operator=(const Configuration &rhs)
Definition: TargetedExperimentHelper.h:62
int location
Definition: TargetedExperimentHelper.h:220
String id
Definition: TargetedExperimentHelper.h:354
String URI
Definition: TargetedExperimentHelper.h:90
const std::vector< Configuration > & getConfigurationList() const
Definition: TargetedExperimentHelper.h:500
Definition: TargetedExperimentHelper.h:374
Compound()
Definition: TargetedExperimentHelper.h:177
String instrument_ref
Definition: TargetedExperimentHelper.h:59
String software_ref
Definition: TargetedExperimentHelper.h:438
TraMLProduct & operator=(const TraMLProduct &rhs)
Definition: TargetedExperimentHelper.h:478
std::vector< CVTermList > interpretation_list_
Definition: TargetedExperimentHelper.h:528
Prediction & operator=(const Prediction &rhs)
Definition: TargetedExperimentHelper.h:448
OpenMS::AASequence getAASequence(const Peptide &peptide)
helper function that converts a Peptide object to a AASequence object
String getPeptideGroupLabel() const
Definition: TargetedExperimentHelper.h:312
Representation of a peptide/protein sequence.
Definition: AASequence.h:84
String fullname
Definition: TargetedExperimentHelper.h:88
Peptide & operator=(const Peptide &rhs)
Definition: TargetedExperimentHelper.h:254
CVTermList & operator=(const CVTermList &rhs)
Assignment operator.
bool operator==(const Instrument &rhs) const
Definition: TargetedExperimentHelper.h:412
Definition: TargetedExperimentHelper.h:346
std::vector< String > * peptide_group_labels_
Definition: TargetedExperimentHelper.h:343
Contact & operator=(const Contact &rhs)
Definition: TargetedExperimentHelper.h:362
void addInterpretation(const CVTermList interpretation)
Definition: TargetedExperimentHelper.h:520
TraMLProduct()
Definition: TargetedExperimentHelper.h:464
CV(const String &new_id, const String &new_fullname, const String &new_version, const String &new_URI)
Definition: TargetedExperimentHelper.h:78
int getChargeState() const
Definition: TargetedExperimentHelper.h:291
std::vector< Configuration > configuration_list_
Definition: TargetedExperimentHelper.h:527
RetentionTime & operator=(const RetentionTime &rhs)
Definition: TargetedExperimentHelper.h:153
std::vector< RetentionTime > rts
Definition: TargetedExperimentHelper.h:333
std::vector< RetentionTime > rts
Definition: TargetedExperimentHelper.h:208
Peptide()
Definition: TargetedExperimentHelper.h:224
void setModification(int location, int max_size, String modification, OpenMS::AASequence &aas)
helper function that sets a modifiction on a AASequence object
Protein()
Definition: TargetedExperimentHelper.h:105
A method or algorithm argument contains illegal values.
Definition: Exception.h:634
int charge_
Definition: TargetedExperimentHelper.h:341
bool operator==(const Protein &rhs) const
Definition: TargetedExperimentHelper.h:113
Definition: TargetedExperimentHelper.h:55
std::vector< CVTermList > validations
Definition: TargetedExperimentHelper.h:60
String id
Definition: TargetedExperimentHelper.h:334
Definition: TargetedExperimentHelper.h:461
Instrument()
Definition: TargetedExperimentHelper.h:405
void replaceCVTerms(Map< String, std::vector< CVTerm > > &cv_terms)
Definition: TargetedExperimentHelper.h:510
bool operator==(const CVTermList &cv_term_list) const
equality operator
Instrument & operator=(const Instrument &rhs)
Definition: TargetedExperimentHelper.h:418
Int peptide_group_label_
Definition: TargetedExperimentHelper.h:342
String id
Definition: TargetedExperimentHelper.h:87
String contact_ref
Definition: TargetedExperimentHelper.h:439
Publication & operator=(const Publication &rhs)
Definition: TargetedExperimentHelper.h:390
String sequence
Definition: TargetedExperimentHelper.h:111
RetentionTime()
Definition: TargetedExperimentHelper.h:138
bool operator==(const RetentionTime &rhs) const
Definition: TargetedExperimentHelper.h:163
Definition: TargetedExperimentHelper.h:172
std::vector< Modification > mods
Definition: TargetedExperimentHelper.h:338
std::vector< String > protein_refs
Definition: TargetedExperimentHelper.h:335
void setChargeState(int charge)
Definition: TargetedExperimentHelper.h:286
String id
Definition: TargetedExperimentHelper.h:382
Prediction()
Definition: TargetedExperimentHelper.h:433
Definition: TargetedExperimentHelper.h:76
void setPeptideGroupLabel(const String &label)
Definition: TargetedExperimentHelper.h:296
String sequence
Definition: TargetedExperimentHelper.h:337
Definition: TargetedExperimentHelper.h:216
bool operator==(const CV &cv) const
Definition: TargetedExperimentHelper.h:92
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:144
String id
Definition: TargetedExperimentHelper.h:110
int getChargeState() const
Definition: TargetedExperimentHelper.h:495
bool operator==(const Publication &rhs) const
Definition: TargetedExperimentHelper.h:384
RetentionTime(const RetentionTime &rhs)
Definition: TargetedExperimentHelper.h:143
Definition: TargetedExperimentHelper.h:402
String id
Definition: TargetedExperimentHelper.h:207
Definition: TargetedExperimentHelper.h:133
String id
Definition: TargetedExperimentHelper.h:410
Definition: TargetedExperimentHelper.h:430
Definition: TargetedExperimentHelper.h:102
String contact_ref
Definition: TargetedExperimentHelper.h:58
bool operator==(const Compound &rhs) const
Definition: TargetedExperimentHelper.h:200
DoubleReal mono_mass_delta
Definition: TargetedExperimentHelper.h:221
DoubleReal avg_mass_delta
Definition: TargetedExperimentHelper.h:219
String software_ref
Definition: TargetedExperimentHelper.h:169
bool operator==(const Prediction &rhs) const
Definition: TargetedExperimentHelper.h:441
double getRetentionTime() const
Definition: TargetedExperimentHelper.h:321
int Int
Signed integer type.
Definition: Types.h:100
Compound(const Compound &rhs)
Definition: TargetedExperimentHelper.h:182
Map class based on the STL map (containing serveral convenience functions)
Definition: Map.h:50
Publication()
Definition: TargetedExperimentHelper.h:377
String version
Definition: TargetedExperimentHelper.h:89
bool operator==(const TraMLProduct &rhs) const
Definition: TargetedExperimentHelper.h:470
bool operator==(const Peptide &rhs) const
Definition: TargetedExperimentHelper.h:272
int charge_
Definition: TargetedExperimentHelper.h:526
Definition: TargetedExperimentHelper.h:211
Contact()
Definition: TargetedExperimentHelper.h:349
const std::vector< CVTermList > & getInterpretationList() const
Definition: TargetedExperimentHelper.h:515

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:21 using doxygen 1.8.5