OpenMS
Loading...
Searching...
No Matches
OSWData.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Chris Bielow $
6// $Authors: Chris Bielow $
7// --------------------------------------------------------------------------
8
9#pragma once
10
12
13#include <map>
14#include <vector>
15
16namespace OpenMS
17{
18 class MSExperiment;
19
21 struct OPENMS_DLLAPI OSWHierarchy
22 {
24 enum Level
25 {
30 SIZE_OF_VALUES
31 };
33 static const char* LevelName[SIZE_OF_VALUES];
34 };
35
39 struct OPENMS_DLLAPI OSWIndexTrace
40 {
41 int idx_prot = -1;
42 int idx_pep = -1;
43 int idx_feat = -1;
44 int idx_trans = -1;
45 OSWHierarchy::Level lowest = OSWHierarchy::Level::SIZE_OF_VALUES;
46
48 bool isSet() const
49 {
50 return lowest != OSWHierarchy::Level::SIZE_OF_VALUES;
51 }
52
53 };
54
56 struct OPENMS_DLLAPI OSWTransition
57 {
58 public:
60 OSWTransition() = default;
62 OSWTransition(const String& annotation, const UInt32 id, const float product_mz, const char type, const bool is_decoy);
63 OSWTransition(const OSWTransition& rhs) = default;
64 OSWTransition& operator=(const OSWTransition& rhs) = default;
65 OSWTransition(OSWTransition&& rhs) = default;
67 ~OSWTransition() = default;
68
70 const String& getAnnotation() const
71 {
72 return annotation_;
73 }
75 UInt32 getID() const
76 {
77 return id_;
78 }
80 float getProductMZ() const
81 {
82 return product_mz_;
83 }
85 char getType() const
86 {
87 return type_;
88 }
90 bool isDecoy() const
91 {
92 return is_decoy_;
93 }
94
95 private:
99 char type_;
101 };
102
107 class OPENMS_DLLAPI OSWPeakGroup
108 {
109 public:
111 static constexpr float QVALUE_MISSING = -1;
112
114 OSWPeakGroup() = default;
115
117 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);
118
120 OSWPeakGroup(const OSWPeakGroup& rhs) = default;
121
123 OSWPeakGroup& operator=(const OSWPeakGroup& rhs) = default;
124
126 OSWPeakGroup(OSWPeakGroup&& rhs) = default;
127
130
132 float getRTExperimental() const
133 {
134 return rt_experimental_;
135 }
137 float getRTLeftWidth() const
138 {
139 return rt_left_width_;
140 }
142 float getRTRightWidth() const
143 {
144 return rt_right_width_;
145 }
147 float getRTDelta() const
148 {
149 return rt_delta_;
150 }
152 float getQValue() const
153 {
154 return q_value_;
155 }
157 const std::vector<UInt32>& getTransitionIDs() const
158 {
159 return transition_ids_;
160 }
161
162 private:
163 float rt_experimental_{ 0 };
164 float rt_left_width_{ 0 };
165 float rt_right_width_{ 0 };
166 float rt_delta_{ 0 };
167 float q_value_{ -1 };
168 std::vector<UInt32> transition_ids_;
169 };
170
179 class OPENMS_DLLAPI OSWPeptidePrecursor
180 {
181 public:
185 OSWPeptidePrecursor(const String& seq, const short charge, const bool decoy, const float precursor_mz, std::vector<OSWPeakGroup>&& features);
194
196 const String& getSequence() const
197 {
198 return seq_;
199 }
201 short getCharge() const
202 {
203 return charge_;
204 }
206 bool isDecoy() const
207 {
208 return decoy_;
209 }
211 float getPCMz() const
212 {
213 return precursor_mz_;
214 }
216 const std::vector<OSWPeakGroup>& getFeatures() const
217 {
218 return features_;
219 }
220
221 private:
223 short charge_{0};
224 bool decoy_{false};
225 float precursor_mz_{0};
226 std::vector<OSWPeakGroup> features_;
227 };
228
233 class OPENMS_DLLAPI OSWProtein
234 {
235 public:
237 OSWProtein() = default;
239 OSWProtein(const String& accession, const Size id, std::vector<OSWPeptidePrecursor>&& peptides);
241 OSWProtein(const OSWProtein& rhs) = default;
243 OSWProtein& operator=(const OSWProtein& rhs) = default;
245 OSWProtein(OSWProtein&& rhs) = default;
247 OSWProtein& operator=(OSWProtein&& rhs) = default;
248
249 const String& getAccession() const
250 {
251 return accession_;
252 }
253
254 Size getID() const
255 {
256 return id_;
257 }
258
259 const std::vector<OSWPeptidePrecursor>& getPeptidePrecursors() const
260 {
261 return peptides_;
262 }
263
264 private:
267 std::vector<OSWPeptidePrecursor> peptides_;
268 };
269
270
278 class OPENMS_DLLAPI OSWData
279 {
280 public:
283 {
284 transitions_.emplace(tr.getID(), tr);
285 }
286
288 {
289 UInt32 id = tr.getID();
290 transitions_.emplace(id, std::move(tr));
291 }
292
298 void addProtein(OSWProtein&& prot);
299
302 const std::vector<OSWProtein>& getProteins() const
303 {
304 return proteins_;
305 }
306
313 void setProtein(const Size index, OSWProtein&& protein)
314 {
315 checkTransitions_(protein);
316 proteins_[index] = std::move(protein);
317 }
318
321 {
322 return transitions_.size();
323 }
324
326 const OSWTransition& getTransition(const UInt32 id) const
327 {
328 return transitions_.at(id);
329 }
330
332 const std::map<UInt32, OSWTransition>& getTransitions() const
333 {
334 return transitions_;
335 }
336
337 void setSqlSourceFile(const String& filename)
338 {
339 source_file_ = filename;
340 }
341
343 {
344 return source_file_;
345 }
346
347 void setRunID(const UInt64 run_id)
348 {
349 run_id_ = run_id;
350 }
351
353 {
354 return run_id_;
355 }
356
358 void clear();
359
362
376 void buildNativeIDResolver(const MSExperiment& chrom_traces);
377
380 UInt fromNativeID(int transition_id) const;
381
382 protected:
386 void checkTransitions_(const OSWProtein& prot) const;
387
388 private:
389 std::map<UInt32, OSWTransition> transitions_;
390 std::vector<OSWProtein> proteins_;
393 std::map<UInt32, UInt32> transID_to_index_;
394 };
395
396
397} // namespace OpenMS
In-Memory representation of a mass spectrometry run.
Definition MSExperiment.h:49
Holds all or partial information from an OSW file.
Definition OSWData.h:279
void setSqlSourceFile(const String &filename)
Definition OSWData.h:337
void addProtein(OSWProtein &&prot)
std::vector< OSWProtein > proteins_
Definition OSWData.h:390
std::map< UInt32, OSWTransition > transitions_
Definition OSWData.h:389
const String & getSqlSourceFile() const
Definition OSWData.h:342
UInt64 run_id_
the ID of this run from the SQL RUN table
Definition OSWData.h:392
String source_file_
remember from which sql OSW file this data is loaded (to lazy load more data)
Definition OSWData.h:391
void clearProteins()
only forget protein data
UInt fromNativeID(int transition_id) const
const std::vector< OSWProtein > & getProteins() const
Definition OSWData.h:302
void setProtein(const Size index, OSWProtein &&protein)
Definition OSWData.h:313
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:393
void clear()
forget all data
UInt64 getRunID() const
Definition OSWData.h:352
void checkTransitions_(const OSWProtein &prot) const
void setRunID(const UInt64 run_id)
Definition OSWData.h:347
const std::map< UInt32, OSWTransition > & getTransitions() const
get all transitions mapped by their ID (UInt32)
Definition OSWData.h:332
void addTransition(const OSWTransition &tr)
Adds a transition; do this before adding Proteins.
Definition OSWData.h:282
Size transitionCount() const
get the total number of transitions (chromatograms)
Definition OSWData.h:320
void addTransition(OSWTransition &&tr)
Definition OSWData.h:287
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:326
Definition OSWData.h:108
const std::vector< UInt32 > & getTransitionIDs() const
get the transition ids (can be mapped to the chromatogram XICs in sqMass data)
Definition OSWData.h:157
float getRTRightWidth() const
RT position in seconds of the right border.
Definition OSWData.h:142
OSWPeakGroup(const OSWPeakGroup &rhs)=default
Copy c'tor.
float getRTExperimental() const
observed RT apex position in seconds of the feature
Definition OSWData.h:132
OSWPeakGroup & operator=(OSWPeakGroup &&rhs)=default
move assignment
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:147
float getRTLeftWidth() const
RT position in seconds of the left border.
Definition OSWData.h:137
OSWPeakGroup()=default
just a dummy feature to allow for acceptor output values etc
OSWPeakGroup & operator=(const OSWPeakGroup &rhs)=default
copy assignment
std::vector< UInt32 > transition_ids_
Definition OSWData.h:168
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:152
A peptide with a charge state.
Definition OSWData.h:180
OSWPeptidePrecursor & operator=(OSWPeptidePrecursor &&rhs)=default
move assignment operator
String seq_
Definition OSWData.h:222
bool isDecoy() const
is this a decoy feature (from a decoy protein)
Definition OSWData.h:206
short getCharge() const
precursor charge
Definition OSWData.h:201
float getPCMz() const
m/z of this charged peptide
Definition OSWData.h:211
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=(const OSWPeptidePrecursor &rhs)=default
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:196
OSWPeptidePrecursor(const OSWPeptidePrecursor &rhs)=default
Copy c'tor.
const std::vector< OSWPeakGroup > & getFeatures() const
candidate explanations
Definition OSWData.h:216
std::vector< OSWPeakGroup > features_
Definition OSWData.h:226
A Protein is the highest entity and contains one or more peptides which were found/traced.
Definition OSWData.h:234
OSWProtein(OSWProtein &&rhs)=default
move c'tor
OSWProtein(const OSWProtein &rhs)=default
Copy c'tor.
Size getID() const
Definition OSWData.h:254
OSWProtein & operator=(const OSWProtein &rhs)=default
assignment operator
std::vector< OSWPeptidePrecursor > peptides_
Definition OSWData.h:267
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
OSWProtein & operator=(OSWProtein &&rhs)=default
move assignment operator
OSWProtein()=default
just a dummy feature to allow for acceptor output values etc
String accession_
Definition OSWData.h:265
const std::vector< OSWPeptidePrecursor > & getPeptidePrecursors() const
Definition OSWData.h:259
const String & getAccession() const
Definition OSWData.h:249
Size id_
Definition OSWData.h:266
A more convenient string class.
Definition String.h:34
uint32_t UInt32
Unsigned integer type (32bit)
Definition Types.h:33
uint64_t UInt64
Unsigned integer type (64bit)
Definition Types.h:47
unsigned int UInt
Unsigned integer type.
Definition Types.h:64
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
hierarchy levels of the OSWData tree
Definition OSWData.h:22
Level
the actual levels
Definition OSWData.h:25
@ TRANSITION
Definition OSWData.h:29
@ PEPTIDE
Definition OSWData.h:27
@ PROTEIN
Definition OSWData.h:26
@ FEATURE
Definition OSWData.h:28
Definition OSWData.h:40
bool isSet() const
is the trace default constructed (=false), or does it point somewhere (=true)?
Definition OSWData.h:48
high-level meta data of a transition
Definition OSWData.h:57
UInt32 id_
ID as used in OSWPeakGroup::transition_ids.
Definition OSWData.h:97
String annotation_
e.g. y5/-0.002
Definition OSWData.h:96
OSWTransition & operator=(const OSWTransition &rhs)=default
bool is_decoy_
is this a decoy transition (from a decoy protein/peptide)
Definition OSWData.h:100
bool isDecoy() const
is this a decoy transition (from a decoy protein/peptide)
Definition OSWData.h:90
OSWTransition(const OSWTransition &rhs)=default
UInt32 getID() const
ID as used in OSWPeakGroup::transition_ids.
Definition OSWData.h:75
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:98
OSWTransition & operator=(OSWTransition &&rhs)=default
const String & getAnnotation() const
e.g. y5/-0.002
Definition OSWData.h:70
char getType() const
b, y
Definition OSWData.h:85
char type_
b, y,
Definition OSWData.h:99
float getProductMZ() const
observed product m/z value
Definition OSWData.h:80