OpenMS  3.0.0
OSWData.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-2022.
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: Chris Bielow $
32 // $Authors: Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
38 
39 #include <map>
40 #include <vector>
41 
42 namespace OpenMS
43 {
44  class MSExperiment;
45 
47  struct OPENMS_DLLAPI OSWHierarchy
48  {
50  enum Level
51  {
56  SIZE_OF_VALUES
57  };
59  static const char* LevelName[SIZE_OF_VALUES];
60  };
61 
65  struct OPENMS_DLLAPI OSWIndexTrace
66  {
67  int idx_prot = -1;
68  int idx_pep = -1;
69  int idx_feat = -1;
70  int idx_trans = -1;
71  OSWHierarchy::Level lowest = OSWHierarchy::Level::SIZE_OF_VALUES;
72 
74  bool isSet() const
75  {
76  return lowest != OSWHierarchy::Level::SIZE_OF_VALUES;
77  }
78 
79  };
80 
82  struct OPENMS_DLLAPI OSWTransition
83  {
84  public:
86  OSWTransition() = default;
88  OSWTransition(const String& annotation, const UInt32 id, const float product_mz, const char type, const bool is_decoy);
89  OSWTransition(const OSWTransition& rhs) = default;
90  OSWTransition& operator=(const OSWTransition& rhs) = default;
91  OSWTransition(OSWTransition&& rhs) = default;
92  OSWTransition& operator=(OSWTransition&& rhs) = default;
93  ~OSWTransition() = default;
94 
96  const String& getAnnotation() const
97  {
98  return annotation_;
99  }
101  UInt32 getID() const
102  {
103  return id_;
104  }
106  float getProductMZ() const
107  {
108  return product_mz_;
109  }
111  char getType() const
112  {
113  return type_;
114  }
116  bool isDecoy() const
117  {
118  return is_decoy_;
119  }
120 
121  private:
124  float product_mz_;
125  char type_;
126  bool is_decoy_;
127  };
128 
133  class OPENMS_DLLAPI OSWPeakGroup
134  {
135  public:
137  static constexpr float QVALUE_MISSING = -1;
138 
140  OSWPeakGroup() = default;
141 
143  OSWPeakGroup(const float rt_experimental, const float rt_left_width, const float rt_right_width, const float rt_delta, std::vector<UInt32>&& transition_ids, const float q_value = -1);
144 
146  OSWPeakGroup(const OSWPeakGroup& rhs) = default;
147 
149  OSWPeakGroup& operator=(const OSWPeakGroup& rhs) = default;
150 
152  OSWPeakGroup(OSWPeakGroup&& rhs) = default;
153 
155  OSWPeakGroup& operator=(OSWPeakGroup&& rhs) = default;
156 
158  float getRTExperimental() const
159  {
160  return rt_experimental_;
161  }
163  float getRTLeftWidth() const
164  {
165  return rt_left_width_;
166  }
168  float getRTRightWidth() const
169  {
170  return rt_right_width_;
171  }
173  float getRTDelta() const
174  {
175  return rt_delta_;
176  }
178  float getQValue() const
179  {
180  return q_value_;
181  }
183  const std::vector<UInt32>& getTransitionIDs() const
184  {
185  return transition_ids_;
186  }
187 
188  private:
189  float rt_experimental_{ 0 };
190  float rt_left_width_{ 0 };
191  float rt_right_width_{ 0 };
192  float rt_delta_{ 0 };
193  float q_value_{ -1 };
194  std::vector<UInt32> transition_ids_;
195  };
196 
205  class OPENMS_DLLAPI OSWPeptidePrecursor
206  {
207  public:
209  OSWPeptidePrecursor() = default;
211  OSWPeptidePrecursor(const String& seq, const short charge, const bool decoy, const float precursor_mz, std::vector<OSWPeakGroup>&& features);
213  OSWPeptidePrecursor(const OSWPeptidePrecursor& rhs) = default;
215  OSWPeptidePrecursor& operator=(const OSWPeptidePrecursor& rhs) = default;
217  OSWPeptidePrecursor(OSWPeptidePrecursor&& rhs) = default;
219  OSWPeptidePrecursor& operator=(OSWPeptidePrecursor&& rhs) = default;
220 
222  const String& getSequence() const
223  {
224  return seq_;
225  }
227  short getCharge() const
228  {
229  return charge_;
230  }
232  bool isDecoy() const
233  {
234  return decoy_;
235  }
237  float getPCMz() const
238  {
239  return precursor_mz_;
240  }
242  const std::vector<OSWPeakGroup>& getFeatures() const
243  {
244  return features_;
245  }
246 
247  private:
249  short charge_{0};
250  bool decoy_{false};
251  float precursor_mz_{0};
252  std::vector<OSWPeakGroup> features_;
253  };
254 
259  class OPENMS_DLLAPI OSWProtein
260  {
261  public:
263  OSWProtein() = default;
265  OSWProtein(const String& accession, const Size id, std::vector<OSWPeptidePrecursor>&& peptides);
267  OSWProtein(const OSWProtein& rhs) = default;
269  OSWProtein& operator=(const OSWProtein& rhs) = default;
271  OSWProtein(OSWProtein&& rhs) = default;
273  OSWProtein& operator=(OSWProtein&& rhs) = default;
274 
275  const String& getAccession() const
276  {
277  return accession_;
278  }
279 
280  Size getID() const
281  {
282  return id_;
283  }
284 
285  const std::vector<OSWPeptidePrecursor>& getPeptidePrecursors() const
286  {
287  return peptides_;
288  }
289 
290  private:
293  std::vector<OSWPeptidePrecursor> peptides_;
294  };
295 
296 
304  class OPENMS_DLLAPI OSWData
305  {
306  public:
308  void addTransition(const OSWTransition& tr)
309  {
310  transitions_.emplace(tr.getID(), tr);
311  }
312 
314  {
315  UInt32 id = tr.getID();
316  transitions_.emplace(id, std::move(tr));
317  }
318 
324  void addProtein(OSWProtein&& prot);
325 
328  const std::vector<OSWProtein>& getProteins() const
329  {
330  return proteins_;
331  }
332 
339  void setProtein(const Size index, OSWProtein&& protein)
340  {
341  checkTransitions_(protein);
342  proteins_[index] = std::move(protein);
343  }
344 
347  {
348  return transitions_.size();
349  }
350 
352  const OSWTransition& getTransition(const UInt32 id) const
353  {
354  return transitions_.at(id);
355  }
356 
358  const std::map<UInt32, OSWTransition>& getTransitions() const
359  {
360  return transitions_;
361  }
362 
363  void setSqlSourceFile(const String& filename)
364  {
365  source_file_ = filename;
366  }
367 
368  const String& getSqlSourceFile() const
369  {
370  return source_file_;
371  }
372 
373  void setRunID(const UInt64 run_id)
374  {
375  run_id_ = run_id;
376  }
377 
378  UInt64 getRunID() const
379  {
380  return run_id_;
381  }
382 
384  void clear();
385 
387  void clearProteins();
388 
402  void buildNativeIDResolver(const MSExperiment& chrom_traces);
403 
406  UInt fromNativeID(int transition_id) const;
407 
408  protected:
412  void checkTransitions_(const OSWProtein& prot) const;
413 
414  private:
415  std::map<UInt32, OSWTransition> transitions_;
416  std::vector<OSWProtein> proteins_;
419  std::map<UInt32, UInt32> transID_to_index_;
420  };
421 
422 
423 } // namespace OpenMS
OpenMS::OSWHierarchy::PEPTIDE
Definition: OSWData.h:53
OpenMS::OSWProtein::peptides_
std::vector< OSWPeptidePrecursor > peptides_
Definition: OSWData.h:293
OpenMS::UInt32
OPENMS_UINT32_TYPE UInt32
Unsigned integer type (32bit)
Definition: Types.h:63
OpenMS::OSWTransition::is_decoy_
bool is_decoy_
is this a decoy transition (from a decoy protein/peptide)
Definition: OSWData.h:126
OpenMS::UInt64
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
OpenMS::OSWTransition::id_
UInt32 id_
ID as used in OSWPeakGroup::transition_ids.
Definition: OSWData.h:123
OpenMS::OSWData::source_file_
String source_file_
remember from which sql OSW file this data is loaded (to lazy load more data)
Definition: OSWData.h:417
OpenMS::OSWProtein
A Protein is the highest entity and contains one or more peptides which were found/traced.
Definition: OSWData.h:259
OpenMS::OSWData::getTransition
const OSWTransition & getTransition(const UInt32 id) const
obtain a certain transition meta information with id (this matches the ID of a chromatogram in an sqM...
Definition: OSWData.h:352
OpenMS::OSWProtein::getID
Size getID() const
Definition: OSWData.h:280
OpenMS::OSWData::proteins_
std::vector< OSWProtein > proteins_
Definition: OSWData.h:416
OpenMS::OSWPeptidePrecursor
A peptide with a charge state.
Definition: OSWData.h:205
OpenMS::OSWTransition::getID
UInt32 getID() const
ID as used in OSWPeakGroup::transition_ids.
Definition: OSWData.h:101
OpenMS::OSWHierarchy::PROTEIN
Definition: OSWData.h:52
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::OSWTransition::getAnnotation
const String & getAnnotation() const
e.g. y5/-0.002
Definition: OSWData.h:96
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:70
OpenMS::OSWPeakGroup::getRTDelta
float getRTDelta() const
RT difference in seconds to the expected RT.
Definition: OSWData.h:173
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::OSWData::transID_to_index_
std::map< UInt32, UInt32 > transID_to_index_
map a Transition.ID (==native_id) to a chromatogram index in the sqMass experiment which contains the...
Definition: OSWData.h:419
OpenMS::OSWData::addTransition
void addTransition(OSWTransition &&tr)
Definition: OSWData.h:313
OpenMS::OSWTransition::isDecoy
bool isDecoy() const
is this a decoy transition (from a decoy protein/peptide)
Definition: OSWData.h:116
OpenMS::OSWIndexTrace::isSet
bool isSet() const
is the trace default constructed (=false), or does it point somewhere (=true)?
Definition: OSWData.h:74
OpenMS::OSWData::getRunID
UInt64 getRunID() const
Definition: OSWData.h:378
OpenMS::OSWPeakGroup::getTransitionIDs
const std::vector< UInt32 > & getTransitionIDs() const
get the transition ids (can be mapped to the chromatogram XICs in sqMass data)
Definition: OSWData.h:183
OpenMS::OSWData::transitionCount
Size transitionCount() const
get the total number of transitions (chromatograms)
Definition: OSWData.h:346
OpenMS::OSWData::setSqlSourceFile
void setSqlSourceFile(const String &filename)
Definition: OSWData.h:363
OpenMS::OSWPeptidePrecursor::getPCMz
float getPCMz() const
m/z of this charged peptide
Definition: OSWData.h:237
OpenMS::OSWData::getSqlSourceFile
const String & getSqlSourceFile() const
Definition: OSWData.h:368
OpenMS::OSWHierarchy::FEATURE
Definition: OSWData.h:54
OpenMS::OSWProtein::id_
Size id_
Definition: OSWData.h:292
OpenMS::OSWTransition::annotation_
String annotation_
e.g. y5/-0.002
Definition: OSWData.h:122
OpenMS::OSWTransition
high-level meta data of a transition
Definition: OSWData.h:82
OpenMS::OSWData::getTransitions
const std::map< UInt32, OSWTransition > & getTransitions() const
get all transitions mapped by their ID (UInt32)
Definition: OSWData.h:358
OpenMS::OSWPeptidePrecursor::getSequence
const String & getSequence() const
the peptide sequence (incl. mods)
Definition: OSWData.h:222
OpenMS::OSWHierarchy::Level
Level
the actual levels
Definition: OSWData.h:50
OpenMS::OSWTransition::getProductMZ
float getProductMZ() const
observed product m/z value
Definition: OSWData.h:106
OpenMS::OSWTransition::type_
char type_
b, y,
Definition: OSWData.h:125
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::OSWPeakGroup
Definition: OSWData.h:133
OpenMS::OSWPeakGroup::getRTExperimental
float getRTExperimental() const
observed RT apex position in seconds of the feature
Definition: OSWData.h:158
OpenMS::OSWPeakGroup::getQValue
float getQValue() const
this might return QVALUE_MISSING if q-value is not annotated in the OSW file
Definition: OSWData.h:178
OpenMS::OSWData::setRunID
void setRunID(const UInt64 run_id)
Definition: OSWData.h:373
OpenMS::OSWData::setProtein
void setProtein(const Size index, OSWProtein &&protein)
Definition: OSWData.h:339
OpenMS::OSWData::getProteins
const std::vector< OSWProtein > & getProteins() const
Definition: OSWData.h:328
OpenMS::OSWHierarchy
hierarchy levels of the OSWData tree
Definition: OSWData.h:47
OpenMS::OSWPeptidePrecursor::getCharge
short getCharge() const
precursor charge
Definition: OSWData.h:227
OpenMS::OSWData::transitions_
std::map< UInt32, OSWTransition > transitions_
Definition: OSWData.h:415
OpenMS::OSWData::addTransition
void addTransition(const OSWTransition &tr)
Adds a transition; do this before adding Proteins.
Definition: OSWData.h:308
OpenMS::OSWPeptidePrecursor::isDecoy
bool isDecoy() const
is this a decoy feature (from a decoy protein)
Definition: OSWData.h:232
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
OpenMS::OSWHierarchy::TRANSITION
Definition: OSWData.h:55
OpenMS::OSWProtein::getAccession
const String & getAccession() const
Definition: OSWData.h:275
OpenMS::OSWProtein::getPeptidePrecursors
const std::vector< OSWPeptidePrecursor > & getPeptidePrecursors() const
Definition: OSWData.h:285
OpenMS::OSWData::run_id_
UInt64 run_id_
the ID of this run from the SQL RUN table
Definition: OSWData.h:418
OpenMS::OSWTransition::product_mz_
float product_mz_
observed product m/z value
Definition: OSWData.h:124
OpenMS::OSWPeptidePrecursor::features_
std::vector< OSWPeakGroup > features_
Definition: OSWData.h:252
OpenMS::OSWProtein::accession_
String accession_
Definition: OSWData.h:291
String.h
OpenMS::OSWPeakGroup::getRTLeftWidth
float getRTLeftWidth() const
RT position in seconds of the left border.
Definition: OSWData.h:163
OpenMS::OSWPeakGroup::transition_ids_
std::vector< UInt32 > transition_ids_
Definition: OSWData.h:194
OpenMS::OSWData
Holds all or partial information from an OSW file.
Definition: OSWData.h:304
OpenMS::OSWPeptidePrecursor::seq_
String seq_
Definition: OSWData.h:248
OpenMS::OSWPeptidePrecursor::getFeatures
const std::vector< OSWPeakGroup > & getFeatures() const
candidate explanations
Definition: OSWData.h:242
OpenMS::OSWIndexTrace
Definition: OSWData.h:65
OpenMS::OSWTransition::getType
char getType() const
b, y
Definition: OSWData.h:111
OpenMS::OSWPeakGroup::getRTRightWidth
float getRTRightWidth() const
RT position in seconds of the right border.
Definition: OSWData.h:168