OpenMS  2.8.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-2021.
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;
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 
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);
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 
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
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:73
Holds all or partial information from an OSW file.
Definition: OSWData.h:305
void setSqlSourceFile(const String &filename)
Definition: OSWData.h:363
void addProtein(OSWProtein &&prot)
std::vector< OSWProtein > proteins_
Definition: OSWData.h:416
std::map< UInt32, OSWTransition > transitions_
Definition: OSWData.h:415
const std::map< UInt32, OSWTransition > & getTransitions() const
get all transitions mapped by their ID (UInt32)
Definition: OSWData.h:358
UInt64 run_id_
the ID of this run from the SQL RUN table
Definition: OSWData.h:418
String source_file_
remember from which sql OSW file this data is loaded (to lazy load more data)
Definition: OSWData.h:417
void clearProteins()
only forget protein data
UInt fromNativeID(int transition_id) const
void setProtein(const Size index, OSWProtein &&protein)
Definition: OSWData.h:339
void buildNativeIDResolver(const MSExperiment &chrom_traces)
Create an internal mapping from the nativeIDs of all chromatograms (extracted by OpenSwathWorkflow (e...
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
void clear()
forget all data
UInt64 getRunID() const
Definition: OSWData.h:378
void checkTransitions_(const OSWProtein &prot) const
void setRunID(const UInt64 run_id)
Definition: OSWData.h:373
const String & getSqlSourceFile() const
Definition: OSWData.h:368
const std::vector< OSWProtein > & getProteins() const
Definition: OSWData.h:328
void addTransition(const OSWTransition &tr)
Adds a transition; do this before adding Proteins.
Definition: OSWData.h:308
Size transitionCount() const
get the total number of transitions (chromatograms)
Definition: OSWData.h:346
void addTransition(OSWTransition &&tr)
Definition: OSWData.h:313
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
Definition: OSWData.h:134
float getRTRightWidth() const
RT position in seconds of the right border.
Definition: OSWData.h:168
OSWPeakGroup(const OSWPeakGroup &rhs)=default
Copy c'tor.
OSWPeakGroup & operator=(const OSWPeakGroup &rhs)=default
copy assignment
float getRTExperimental() const
observed RT apex position in seconds of the feature
Definition: OSWData.h:158
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)
custom c'tor which fills all the members with data; all members are read-only
float getRTDelta() const
RT difference in seconds to the expected RT.
Definition: OSWData.h:173
OSWPeakGroup & operator=(OSWPeakGroup &&rhs)=default
move assignment
const std::vector< UInt32 > & getTransitionIDs() const
get the transition ids (can be mapped to the chromatogram XICs in sqMass data)
Definition: OSWData.h:183
float getRTLeftWidth() const
RT position in seconds of the left border.
Definition: OSWData.h:163
OSWPeakGroup()=default
just a dummy feature to allow for acceptor output values etc
std::vector< UInt32 > transition_ids_
Definition: OSWData.h:194
OSWPeakGroup(OSWPeakGroup &&rhs)=default
move c'tor
float getQValue() const
this might return QVALUE_MISSING if q-value is not annotated in the OSW file
Definition: OSWData.h:178
A peptide with a charge state.
Definition: OSWData.h:206
String seq_
Definition: OSWData.h:248
bool isDecoy() const
is this a decoy feature (from a decoy protein)
Definition: OSWData.h:232
OSWPeptidePrecursor & operator=(const OSWPeptidePrecursor &rhs)=default
assignment operator
short getCharge() const
precursor charge
Definition: OSWData.h:227
float getPCMz() const
m/z of this charged peptide
Definition: OSWData.h:237
OSWPeptidePrecursor(const String &seq, const short charge, const bool decoy, const float precursor_mz, std::vector< OSWPeakGroup > &&features)
custom c'tor which fills all the members with data; all members are read-only
OSWPeptidePrecursor(OSWPeptidePrecursor &&rhs)=default
move c'tor
OSWPeptidePrecursor & operator=(OSWPeptidePrecursor &&rhs)=default
move assignment operator
OSWPeptidePrecursor()=default
just a dummy feature to allow for acceptor output values etc
const String & getSequence() const
the peptide sequence (incl. mods)
Definition: OSWData.h:222
OSWPeptidePrecursor(const OSWPeptidePrecursor &rhs)=default
Copy c'tor.
const std::vector< OSWPeakGroup > & getFeatures() const
candidate explanations
Definition: OSWData.h:242
std::vector< OSWPeakGroup > features_
Definition: OSWData.h:252
A Protein is the highest entity and contains one or more peptides which were found/traced.
Definition: OSWData.h:260
OSWProtein & operator=(OSWProtein &&rhs)=default
move assignment operator
OSWProtein & operator=(const OSWProtein &rhs)=default
assignment operator
OSWProtein(OSWProtein &&rhs)=default
move c'tor
OSWProtein(const OSWProtein &rhs)=default
Copy c'tor.
Size getID() const
Definition: OSWData.h:280
const std::vector< OSWPeptidePrecursor > & getPeptidePrecursors() const
Definition: OSWData.h:285
std::vector< OSWPeptidePrecursor > peptides_
Definition: OSWData.h:293
OSWProtein(const String &accession, const Size id, std::vector< OSWPeptidePrecursor > &&peptides)
custom c'tor which fills all the members with data; all members are read-only
const String & getAccession() const
Definition: OSWData.h:275
OSWProtein()=default
just a dummy feature to allow for acceptor output values etc
String accession_
Definition: OSWData.h:291
Size id_
Definition: OSWData.h:292
A more convenient string class.
Definition: String.h:60
OPENMS_UINT32_TYPE UInt32
Unsigned integer type (32bit)
Definition: Types.h:63
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
hierarchy levels of the OSWData tree
Definition: OSWData.h:48
Level
the actual levels
Definition: OSWData.h:51
@ TRANSITION
Definition: OSWData.h:55
@ PEPTIDE
Definition: OSWData.h:53
@ PROTEIN
Definition: OSWData.h:52
@ FEATURE
Definition: OSWData.h:54
Definition: OSWData.h:66
bool isSet() const
is the trace default constructed (=false), or does it point somewhere (=true)?
Definition: OSWData.h:74
high-level meta data of a transition
Definition: OSWData.h:83
const String & getAnnotation() const
e.g. y5/-0.002
Definition: OSWData.h:96
UInt32 id_
ID as used in OSWPeakGroup::transition_ids.
Definition: OSWData.h:123
String annotation_
e.g. y5/-0.002
Definition: OSWData.h:122
bool is_decoy_
is this a decoy transition (from a decoy protein/peptide)
Definition: OSWData.h:126
bool isDecoy() const
is this a decoy transition (from a decoy protein/peptide)
Definition: OSWData.h:116
OSWTransition(const OSWTransition &rhs)=default
OSWTransition & operator=(OSWTransition &&rhs)=default
OSWTransition & operator=(const OSWTransition &rhs)=default
UInt32 getID() const
ID as used in OSWPeakGroup::transition_ids.
Definition: OSWData.h:101
OSWTransition()=default
default c'tor
OSWTransition(OSWTransition &&rhs)=default
OSWTransition(const String &annotation, const UInt32 id, const float product_mz, const char type, const bool is_decoy)
custom c'tor which fills all the members with data; all members are read-only
float product_mz_
observed product m/z value
Definition: OSWData.h:124
char getType() const
b, y
Definition: OSWData.h:111
char type_
b, y,
Definition: OSWData.h:125
float getProductMZ() const
observed product m/z value
Definition: OSWData.h:106