OpenMS
TargetedExperimentHelper.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: Andreas Bertsch $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
12 
13 #include <OpenMS/CONCEPT/Types.h>
15 #include <OpenMS/CONCEPT/Macros.h>
16 
18 #include <OpenMS/METADATA/CVTerm.h>
22 
23 #include <boost/numeric/conversion/cast.hpp>
24 
25 namespace OpenMS
26 {
27 
34  namespace TargetedExperimentHelper
35  {
36 
37  struct Configuration :
38  public CVTermList
39  {
42  std::vector<CVTermList> validations;
43  };
44 
45  struct CV
46  {
47  CV(const String & new_id, const String & new_fullname, const String & new_version, const String & new_URI) :
48  id(new_id),
49  fullname(new_fullname),
50  version(new_version),
51  URI(new_URI)
52  {
53 
54  }
55 
60 
61  bool operator==(const CV & cv) const
62  {
63  return id == cv.id &&
64  fullname == cv.fullname &&
65  version == cv.version &&
66  URI == cv.URI;
67  }
68 
69  };
70 
71  struct Protein :
72  public CVTermList
73  {
74  Protein() = default;
75  bool operator==(const Protein& rhs) const
76  {
77  return CVTermList::operator==(rhs) &&
78  id == rhs.id &&
79  sequence == rhs.sequence;
80  }
81 
84 
85  };
86 
97  class OPENMS_DLLAPI RetentionTime :
98  public CVTermListInterface
99  {
100 public:
101 
102  enum class RTUnit : std::int8_t
103  {
104  SECOND = 0,
105  MINUTE,
106  UNKNOWN,
107  SIZE_OF_RTUNIT
108  };
109 
110  enum class RTType : std::int8_t
111  {
112  LOCAL = 0,
113  NORMALIZED,
114  PREDICTED,
115  HPINS,
116  IRT,
117  UNKNOWN,
118  SIZE_OF_RTTYPE
119  };
120 
123  software_ref(""),
124  retention_time_unit(RTUnit::SIZE_OF_RTUNIT),
125  retention_time_type(RTType::SIZE_OF_RTTYPE),
126  retention_time_set_(false),
127  retention_time_(0.0)
128  // retention_time_width(0.0),
129  // retention_time_lower(0.0),
130  // retention_time_upper(0.0)
131  {
132  }
133 
134  RetentionTime(const RetentionTime &) = default;
135  RetentionTime(RetentionTime &&) noexcept = default;
136  virtual ~RetentionTime() = default;
137  RetentionTime & operator=(const RetentionTime &) & = default;
138  RetentionTime & operator=(RetentionTime &&) & = default;
139 
140  bool operator==(const RetentionTime & rhs) const
141  {
142  return CVTermListInterface::operator==(rhs) &&
143  software_ref == rhs.software_ref &&
144  retention_time_unit == rhs.retention_time_unit &&
145  retention_time_type == rhs.retention_time_type &&
146  retention_time_set_ == rhs.retention_time_set_ &&
147  retention_time_ == rhs.retention_time_;
148  }
149 
150  bool isRTset() const
151  {
152  return retention_time_set_;
153  }
154  void setRT(double rt)
155  {
156  retention_time_ = rt;
157  retention_time_set_ = true;
158  }
159  double getRT() const
160  {
161  OPENMS_PRECONDITION(isRTset(), "RT needs to be set")
162  return retention_time_;
163  }
164 
168 
169 private:
170 
173  // double retention_time_width;
174  // double retention_time_lower;
175  // double retention_time_upper;
176  };
177 
183  class OPENMS_DLLAPI PeptideCompound :
184  public CVTermList
185  {
186 public:
187  PeptideCompound() = default;
188  PeptideCompound(const PeptideCompound &) = default;
189  PeptideCompound(PeptideCompound &&) noexcept = default;
190  PeptideCompound & operator=(const PeptideCompound &) & = default;
191  PeptideCompound & operator=(PeptideCompound &&) & = default;
192 
193  bool operator==(const PeptideCompound & rhs) const
194  {
195  return CVTermList::operator==(rhs) &&
196  rts == rhs.rts &&
197  id == rhs.id &&
198  charge_ == rhs.charge_ &&
199  charge_set_ == rhs.charge_set_;
200  }
201 
203  void setChargeState(int charge)
204  {
205  charge_ = charge;
206  charge_set_ = true;
207  }
208 
210  bool hasCharge() const
211  {
212  return charge_set_;
213  }
214 
216  int getChargeState() const
217  {
218  OPENMS_PRECONDITION(charge_set_, "Cannot return charge which was never set")
219  return charge_;
220  }
221 
223  void setDriftTime(double dt)
224  {
225  drift_time_ = dt;
226  }
227 
229  double getDriftTime() const
230  {
231  return drift_time_;
232  }
233 
235 
237  bool hasRetentionTime() const
238  {
239  return (!rts.empty() && rts[0].isRTset());
240  }
241 
246  double getRetentionTime() const
247  {
248  if (!hasRetentionTime())
249  {
250  throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
251  "No retention time information available");
252  }
253  return rts[0].getRT();
254  }
255 
258  {
259  if (!hasRetentionTime())
260  {
261  throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
262  "No retention time information available");
263  }
264  return rts[0].retention_time_type;
265  }
266 
269  {
270  if (!hasRetentionTime())
271  {
272  throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
273  "No retention time information available");
274  }
275  return rts[0].retention_time_unit;
276  }
278 
280  std::vector<RetentionTime> rts;
281 
282 protected:
283  int charge_{0};
284  bool charge_set_{false};
285  double drift_time_{-1};
286  };
287 
294  class OPENMS_DLLAPI Compound :
295  public PeptideCompound
296  {
297 public:
298 
300  theoretical_mass(0.0)
301  {
302  }
303 
304  Compound(const Compound &) = default;
305  Compound(Compound &&) noexcept = default;
306  Compound & operator=(const Compound &) & = default;
307  Compound & operator=(Compound &&) & = default;
308 
309  bool operator==(const Compound & rhs) const
310  {
311  return PeptideCompound::operator==(rhs) &&
312  molecular_formula == rhs.molecular_formula &&
313  smiles_string == rhs.smiles_string &&
314  theoretical_mass == rhs.theoretical_mass;
315  }
316 
320 
321 protected:
322 
323  };
324 
331  class OPENMS_DLLAPI Peptide :
332  public PeptideCompound
333  {
334 public:
335  struct Modification :
336  public CVTermListInterface
337  {
342 
345  location(-1),
346  unimod_id(-1)
347  {
348  }
349 
350  };
351 
352  Peptide() = default;
353  Peptide(const Peptide &) = default;
354  Peptide(Peptide &&) noexcept = default;
355  Peptide & operator=(const Peptide &) & = default;
356  Peptide & operator=(Peptide &&) & = default;
357 
358  bool operator==(const Peptide & rhs) const
359  {
360  return PeptideCompound::operator==(rhs) &&
361  protein_refs == rhs.protein_refs &&
362  evidence == rhs.evidence &&
363  sequence == rhs.sequence &&
364  mods == rhs.mods &&
365  peptide_group_label_ == rhs.peptide_group_label_;
366  }
367 
379  void setPeptideGroupLabel(const String & label)
380  {
381  peptide_group_label_ = label;
382  }
383 
386  {
387  return peptide_group_label_;
388  }
390 
391  std::vector<String> protein_refs;
394  std::vector<Modification> mods;
395 
396 protected:
398  };
399 
400  struct OPENMS_DLLAPI Contact :
401  public CVTermList
402  {
404  CVTermList()
405  {
406  }
407 
408  bool operator==(const Contact & rhs) const
409  {
410  return CVTermList::operator==(rhs) &&
411  id == rhs.id;
412  }
413 
415  };
416 
417  struct OPENMS_DLLAPI Publication :
418  public CVTermList
419  {
421  CVTermList()
422  {
423  }
424 
425  bool operator==(const Publication & rhs) const
426  {
427  return CVTermList::operator==(rhs) &&
428  id == rhs.id;
429  }
430 
432  };
433 
434  struct OPENMS_DLLAPI Instrument :
435  public CVTermList
436  {
438  CVTermList()
439  {
440  }
441 
442  bool operator==(const Instrument & rhs) const
443  {
444  return CVTermList::operator==(rhs) &&
445  id == rhs.id;
446  }
447 
449  };
450 
451  struct OPENMS_DLLAPI Prediction :
452  public CVTermList
453  {
455  CVTermList()
456  {
457  }
458 
459  bool operator==(const Prediction & rhs) const
460  {
461  return CVTermList::operator==(rhs) &&
462  contact_ref == rhs.contact_ref &&
463  software_ref == rhs.software_ref;
464  }
465 
468  };
469 
476  struct OPENMS_DLLAPI Interpretation :
477  public CVTermListInterface
478  {
479 
480  /*
481  enum ResidueType
482  {
483  Full = 0, // with N-terminus and C-terminus
484  Internal, // internal, without any termini
485  NTerminal, // only N-terminus
486  CTerminal, // only C-terminus
487  AIon, // MS:1001229 N-terminus up to the C-alpha/carbonyl carbon bond
488  BIon, // MS:1001224 N-terminus up to the peptide bond
489  CIon, // MS:1001231 N-terminus up to the amide/C-alpha bond
490  XIon, // MS:1001228 amide/C-alpha bond up to the C-terminus
491  YIon, // MS:1001220 peptide bond up to the C-terminus
492  ZIon, // MS:1001230 C-alpha/carbonyl carbon bond
493  Precursor, // MS:1001523 Precursor ion
494  BIonMinusH20, // MS:1001222 b ion without water
495  YIonMinusH20, // MS:1001223 y ion without water
496  BIonMinusNH3, // MS:1001232 b ion without ammonia
497  YIonMinusNH3, // MS:1001233 y ion without ammonia
498  NonIdentified, // MS:1001240 Non-identified ion
499  Unannotated, // no stored annotation
500  SizeOfResidueType
501  };
502  */
503 
505 
506  unsigned char ordinal;
507  unsigned char rank;
509 
510  // Constructor
513  ordinal(0),
514  rank(0),
515  iontype(Residue::Unannotated) // Unannotated does not imply any MS OBO term
516  {
517  }
518 
522  bool operator==(const Interpretation & rhs) const
523  {
524  return CVTermListInterface::operator==(rhs) &&
525  ordinal == rhs.ordinal &&
526  rank == rhs.rank &&
527  iontype == rhs.iontype;
528  }
529 
530  bool operator!=(const Interpretation & rhs) const
531  {
532  return !(operator==(rhs));
533  }
535 
536  };
537 
544  struct OPENMS_DLLAPI TraMLProduct :
545  public CVTermListInterface
546  {
547  TraMLProduct() = default;
548  bool operator==(const TraMLProduct & rhs) const
549  {
550  return CVTermListInterface::operator==(rhs) &&
551  charge_ == rhs.charge_ &&
552  charge_set_ == rhs.charge_set_ &&
553  mz_ == rhs.mz_ &&
554  configuration_list_ == rhs.configuration_list_ &&
555  interpretation_list_ == rhs.interpretation_list_;
556  }
557 
558  void setChargeState(int charge)
559  {
560  charge_ = charge;
561  charge_set_ = true;
562  }
563 
565  bool hasCharge() const
566  {
567  return charge_set_;
568  }
569 
570  int getChargeState() const
571  {
572  OPENMS_PRECONDITION(charge_set_, "Cannot return charge which was never set")
573  return charge_;
574  }
575 
576  double getMZ() const
577  {
578  return mz_;
579  }
580 
581  void setMZ(double mz)
582  {
583  mz_ = mz;
584  }
585 
586  const std::vector<Configuration> & getConfigurationList() const
587  {
588  return configuration_list_;
589  }
590 
591  void addConfiguration(const Configuration& configuration)
592  {
593  configuration_list_.push_back(configuration);
594  }
595 
596  const std::vector<Interpretation> & getInterpretationList() const
597  {
598  return interpretation_list_;
599  }
600 
601  void addInterpretation(const Interpretation& interpretation)
602  {
603  interpretation_list_.push_back(interpretation);
604  }
605 
607  {
608  return interpretation_list_.clear();
609  }
610 
611 private:
612  int charge_{0};
613  bool charge_set_{false};
614  double mz_{0};
615  std::vector<Configuration> configuration_list_;
616  std::vector<Interpretation> interpretation_list_;
617  };
618 
620  OPENMS_DLLAPI OpenMS::AASequence getAASequence(const Peptide& peptide);
621 
623  OPENMS_DLLAPI void setModification(int location, int max_size, const String& modification, OpenMS::AASequence & aas);
624 
625  }
626 
627 } // namespace OpenMS
628 
Representation of a peptide/protein sequence.
Definition: AASequence.h:86
Interface to the controlled vocabulary term list.
Definition: CVTermListInterface.h:33
bool operator==(const CVTermListInterface &rhs) const
equality operator
Representation of controlled vocabulary term list.
Definition: CVTermList.h:28
bool operator==(const CVTermList &cv_term_list) const
equality operator
A method or algorithm argument contains illegal values.
Definition: Exception.h:629
Representation of an amino acid residue.
Definition: Residue.h:40
ResidueType
Definition: Residue.h:152
A more convenient string class.
Definition: String.h:34
Represents a compound (small molecule)
Definition: TargetedExperimentHelper.h:296
String molecular_formula
Definition: TargetedExperimentHelper.h:317
double theoretical_mass
Definition: TargetedExperimentHelper.h:319
Compound(Compound &&) noexcept=default
String smiles_string
Definition: TargetedExperimentHelper.h:318
Compound()
Definition: TargetedExperimentHelper.h:299
Base class to represent either a peptide or a compound.
Definition: TargetedExperimentHelper.h:185
std::vector< RetentionTime > rts
Definition: TargetedExperimentHelper.h:280
bool hasRetentionTime() const
Check whether compound or peptide has an annotated retention time.
Definition: TargetedExperimentHelper.h:237
double getRetentionTime() const
Gets compound or peptide retention time.
Definition: TargetedExperimentHelper.h:246
PeptideCompound(const PeptideCompound &)=default
String id
Definition: TargetedExperimentHelper.h:279
int getChargeState() const
Return the peptide or compound charge state.
Definition: TargetedExperimentHelper.h:216
bool operator==(const PeptideCompound &rhs) const
Definition: TargetedExperimentHelper.h:193
PeptideCompound(PeptideCompound &&) noexcept=default
void setChargeState(int charge)
Set the peptide or compound charge state.
Definition: TargetedExperimentHelper.h:203
RetentionTime::RTType getRetentionTimeType() const
Get compound or peptide retentiontime type.
Definition: TargetedExperimentHelper.h:257
bool hasCharge() const
Whether peptide or compound has set charge state.
Definition: TargetedExperimentHelper.h:210
RetentionTime::RTUnit getRetentionTimeUnit() const
Get compound or peptide retentiontime unit (minute/seconds)
Definition: TargetedExperimentHelper.h:268
double getDriftTime() const
Return the peptide or compound ion mobility drift time.
Definition: TargetedExperimentHelper.h:229
void setDriftTime(double dt)
Set the peptide or compound ion mobility drift time.
Definition: TargetedExperimentHelper.h:223
Represents a peptide (amino acid sequence)
Definition: TargetedExperimentHelper.h:333
String getPeptideGroupLabel() const
Get the peptide group label.
Definition: TargetedExperimentHelper.h:385
String sequence
Definition: TargetedExperimentHelper.h:393
CVTermList evidence
Definition: TargetedExperimentHelper.h:392
std::vector< Modification > mods
Definition: TargetedExperimentHelper.h:394
std::vector< String > protein_refs
Definition: TargetedExperimentHelper.h:391
void setPeptideGroupLabel(const String &label)
Set the peptide group label.
Definition: TargetedExperimentHelper.h:379
Peptide(Peptide &&) noexcept=default
String peptide_group_label_
Definition: TargetedExperimentHelper.h:397
This class stores a retention time structure that is used in TargetedExperiment (representing a TraML...
Definition: TargetedExperimentHelper.h:99
double getRT() const
Definition: TargetedExperimentHelper.h:159
String software_ref
Definition: TargetedExperimentHelper.h:165
RetentionTime(RetentionTime &&) noexcept=default
bool retention_time_set_
Definition: TargetedExperimentHelper.h:171
RetentionTime(const RetentionTime &)=default
RTUnit
Definition: TargetedExperimentHelper.h:103
RTType
Definition: TargetedExperimentHelper.h:111
RetentionTime()
Definition: TargetedExperimentHelper.h:121
RTUnit retention_time_unit
Definition: TargetedExperimentHelper.h:166
RTType retention_time_type
Definition: TargetedExperimentHelper.h:167
double retention_time_
Definition: TargetedExperimentHelper.h:172
bool isRTset() const
Definition: TargetedExperimentHelper.h:150
void setRT(double rt)
Definition: TargetedExperimentHelper.h:154
int32_t Int32
Signed integer type (32bit)
Definition: Types.h:26
#define OPENMS_PRECONDITION(condition, message)
Precondition macro.
Definition: openms/include/OpenMS/CONCEPT/Macros.h:94
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
OpenMS::AASequence getAASequence(const Peptide &peptide)
helper function that converts a Peptide object to a AASequence object
void setModification(int location, int max_size, const String &modification, OpenMS::AASequence &aas)
helper function that sets a modification on a AASequence object
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Definition: TargetedExperimentHelper.h:46
String fullname
Definition: TargetedExperimentHelper.h:57
bool operator==(const CV &cv) const
Definition: TargetedExperimentHelper.h:61
String version
Definition: TargetedExperimentHelper.h:58
String id
Definition: TargetedExperimentHelper.h:56
CV(const String &new_id, const String &new_fullname, const String &new_version, const String &new_URI)
Definition: TargetedExperimentHelper.h:47
String URI
Definition: TargetedExperimentHelper.h:59
Definition: TargetedExperimentHelper.h:39
String instrument_ref
Definition: TargetedExperimentHelper.h:41
std::vector< CVTermList > validations
Definition: TargetedExperimentHelper.h:42
String contact_ref
Definition: TargetedExperimentHelper.h:40
Definition: TargetedExperimentHelper.h:402
String id
Definition: TargetedExperimentHelper.h:414
bool operator==(const Contact &rhs) const
Definition: TargetedExperimentHelper.h:408
Contact()
Definition: TargetedExperimentHelper.h:403
Definition: TargetedExperimentHelper.h:436
bool operator==(const Instrument &rhs) const
Definition: TargetedExperimentHelper.h:442
String id
Definition: TargetedExperimentHelper.h:448
Instrument()
Definition: TargetedExperimentHelper.h:437
Product ion interpretation.
Definition: TargetedExperimentHelper.h:478
IonType iontype
which type of ion (b/y/z/ ...), see Residue::ResidueType
Definition: TargetedExperimentHelper.h:508
bool operator!=(const Interpretation &rhs) const
Definition: TargetedExperimentHelper.h:530
Interpretation()
Definition: TargetedExperimentHelper.h:511
Residue::ResidueType IonType
Interpretation IonType.
Definition: TargetedExperimentHelper.h:504
bool operator==(const Interpretation &rhs) const
Definition: TargetedExperimentHelper.h:522
unsigned char ordinal
MS:1000903 : product ion series ordinal (e.g. 8 for a y8 ion)
Definition: TargetedExperimentHelper.h:506
unsigned char rank
MS:1000926 : product interpretation rank (e.g. 1 for the most likely rank)
Definition: TargetedExperimentHelper.h:507
Definition: TargetedExperimentHelper.h:337
Int32 unimod_id
Definition: TargetedExperimentHelper.h:341
double mono_mass_delta
Definition: TargetedExperimentHelper.h:339
double avg_mass_delta
Definition: TargetedExperimentHelper.h:338
Int32 location
Definition: TargetedExperimentHelper.h:340
Modification()
Definition: TargetedExperimentHelper.h:343
Definition: TargetedExperimentHelper.h:453
String software_ref
Definition: TargetedExperimentHelper.h:466
Prediction()
Definition: TargetedExperimentHelper.h:454
String contact_ref
Definition: TargetedExperimentHelper.h:467
bool operator==(const Prediction &rhs) const
Definition: TargetedExperimentHelper.h:459
Definition: TargetedExperimentHelper.h:73
String sequence
Definition: TargetedExperimentHelper.h:83
String id
Definition: TargetedExperimentHelper.h:82
bool operator==(const Protein &rhs) const
Definition: TargetedExperimentHelper.h:75
Definition: TargetedExperimentHelper.h:419
bool operator==(const Publication &rhs) const
Definition: TargetedExperimentHelper.h:425
String id
Definition: TargetedExperimentHelper.h:431
Publication()
Definition: TargetedExperimentHelper.h:420
Represents a product ion.
Definition: TargetedExperimentHelper.h:546
void resetInterpretations()
Definition: TargetedExperimentHelper.h:606
void addConfiguration(const Configuration &configuration)
Definition: TargetedExperimentHelper.h:591
void addInterpretation(const Interpretation &interpretation)
Definition: TargetedExperimentHelper.h:601
const std::vector< Configuration > & getConfigurationList() const
Definition: TargetedExperimentHelper.h:586
void setMZ(double mz)
Definition: TargetedExperimentHelper.h:581
const std::vector< Interpretation > & getInterpretationList() const
Definition: TargetedExperimentHelper.h:596
int getChargeState() const
Definition: TargetedExperimentHelper.h:570
bool charge_set_
Whether product ion charge is set or not.
Definition: TargetedExperimentHelper.h:613
void setChargeState(int charge)
Definition: TargetedExperimentHelper.h:558
std::vector< Configuration > configuration_list_
Product ion configurations used.
Definition: TargetedExperimentHelper.h:615
int charge_
Product ion charge.
Definition: TargetedExperimentHelper.h:612
bool hasCharge() const
Whether product has set charge state.
Definition: TargetedExperimentHelper.h:565
std::vector< Interpretation > interpretation_list_
Product ion interpretation.
Definition: TargetedExperimentHelper.h:616
bool operator==(const TraMLProduct &rhs) const
Definition: TargetedExperimentHelper.h:548
double mz_
Product ion m/z.
Definition: TargetedExperimentHelper.h:614
double getMZ() const
Definition: TargetedExperimentHelper.h:576