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
29 struct OPENMS_DLLAPI OSWHierarchy
30 {
32 enum Level
33 {
38 SIZE_OF_VALUES
39 };
41 static const char* LevelName[SIZE_OF_VALUES];
42 };
43
54 struct OPENMS_DLLAPI OSWIndexTrace
55 {
56 int idx_prot = -1;
57 int idx_pep = -1;
58 int idx_feat = -1;
59 int idx_trans = -1;
60 OSWHierarchy::Level lowest = OSWHierarchy::Level::SIZE_OF_VALUES;
61
63 bool isSet() const
64 {
65 return lowest != OSWHierarchy::Level::SIZE_OF_VALUES;
66 }
67
68 };
69
80 struct OPENMS_DLLAPI OSWTransition
81 {
82 public:
84 OSWTransition() = default;
86 OSWTransition(const std::string& annotation, const UInt32 id, const float product_mz, const char type, const bool is_decoy);
87 OSWTransition(const OSWTransition& rhs) = default;
88 OSWTransition& operator=(const OSWTransition& rhs) = default;
89 OSWTransition(OSWTransition&& rhs) = default;
91 ~OSWTransition() = default;
92
94 const std::string& getAnnotation() const
95 {
96 return annotation_;
97 }
99 UInt32 getID() const
100 {
101 return id_;
102 }
104 float getProductMZ() const
105 {
106 return product_mz_;
107 }
109 char getType() const
110 {
111 return type_;
112 }
114 bool isDecoy() const
115 {
116 return is_decoy_;
117 }
118
119 private:
120 std::string annotation_;
123 char type_;
125 };
126
135 class OPENMS_DLLAPI OSWPeakGroup
136 {
137 public:
139 static constexpr float QVALUE_MISSING = -1;
140
142 OSWPeakGroup() = default;
143
145 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);
146
148 OSWPeakGroup(const OSWPeakGroup& rhs) = default;
149
151 OSWPeakGroup& operator=(const OSWPeakGroup& rhs) = default;
152
154 OSWPeakGroup(OSWPeakGroup&& rhs) = default;
155
158
160 float getRTExperimental() const
161 {
162 return rt_experimental_;
163 }
165 float getRTLeftWidth() const
166 {
167 return rt_left_width_;
168 }
170 float getRTRightWidth() const
171 {
172 return rt_right_width_;
173 }
175 float getRTDelta() const
176 {
177 return rt_delta_;
178 }
180 float getQValue() const
181 {
182 return q_value_;
183 }
185 const std::vector<UInt32>& getTransitionIDs() const
186 {
187 return transition_ids_;
188 }
189
190 private:
191 float rt_experimental_{ 0 };
192 float rt_left_width_{ 0 };
193 float rt_right_width_{ 0 };
194 float rt_delta_{ 0 };
195 float q_value_{ -1 };
196 std::vector<UInt32> transition_ids_;
197 };
198
209 class OPENMS_DLLAPI OSWPeptidePrecursor
210 {
211 public:
215 OSWPeptidePrecursor(const std::string& seq, const short charge, const bool decoy, const float precursor_mz, std::vector<OSWPeakGroup>&& features);
224
226 const std::string& getSequence() const
227 {
228 return seq_;
229 }
231 short getCharge() const
232 {
233 return charge_;
234 }
236 bool isDecoy() const
237 {
238 return decoy_;
239 }
241 float getPCMz() const
242 {
243 return precursor_mz_;
244 }
246 const std::vector<OSWPeakGroup>& getFeatures() const
247 {
248 return features_;
249 }
250
251 private:
252 std::string seq_;
253 short charge_{0};
254 bool decoy_{false};
255 float precursor_mz_{0};
256 std::vector<OSWPeakGroup> features_;
257 };
258
264 class OPENMS_DLLAPI OSWProtein
265 {
266 public:
268 OSWProtein() = default;
270 OSWProtein(const std::string& accession, const Size id, std::vector<OSWPeptidePrecursor>&& peptides);
272 OSWProtein(const OSWProtein& rhs) = default;
274 OSWProtein& operator=(const OSWProtein& rhs) = default;
276 OSWProtein(OSWProtein&& rhs) = default;
278 OSWProtein& operator=(OSWProtein&& rhs) = default;
279
281 const std::string& getAccession() const
282 {
283 return accession_;
284 }
285
287 Size getID() const
288 {
289 return id_;
290 }
291
293 const std::vector<OSWPeptidePrecursor>& getPeptidePrecursors() const
294 {
295 return peptides_;
296 }
297
298 private:
299 std::string accession_;
301 std::vector<OSWPeptidePrecursor> peptides_;
302 };
303
304
314 class OPENMS_DLLAPI OSWData
315 {
316 public:
319 {
320 transitions_.emplace(tr.getID(), tr);
321 }
322
324 {
325 UInt32 id = tr.getID();
326 transitions_.emplace(id, std::move(tr));
327 }
328
334 void addProtein(OSWProtein&& prot);
335
338 const std::vector<OSWProtein>& getProteins() const
339 {
340 return proteins_;
341 }
342
349 void setProtein(const Size index, OSWProtein&& protein)
350 {
351 checkTransitions_(protein);
352 proteins_[index] = std::move(protein);
353 }
354
357 {
358 return transitions_.size();
359 }
360
362 const OSWTransition& getTransition(const UInt32 id) const
363 {
364 return transitions_.at(id);
365 }
366
368 const std::map<UInt32, OSWTransition>& getTransitions() const
369 {
370 return transitions_;
371 }
372
373 void setSqlSourceFile(const std::string& filename)
374 {
375 source_file_ = filename;
376 }
377
378 const std::string& getSqlSourceFile() const
379 {
380 return source_file_;
381 }
382
383 void setRunID(const UInt64 run_id)
384 {
385 run_id_ = run_id;
386 }
387
389 {
390 return run_id_;
391 }
392
394 void clear();
395
398
412 void buildNativeIDResolver(const MSExperiment& chrom_traces);
413
416 UInt fromNativeID(int transition_id) const;
417
418 protected:
422 void checkTransitions_(const OSWProtein& prot) const;
423
424 private:
425 std::map<UInt32, OSWTransition> transitions_;
426 std::vector<OSWProtein> proteins_;
427 std::string source_file_;
429 std::map<UInt32, UInt32> transID_to_index_;
430 };
431
432
433} // 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:315
const std::string & getSqlSourceFile() const
Definition OSWData.h:378
void addProtein(OSWProtein &&prot)
void setSqlSourceFile(const std::string &filename)
Definition OSWData.h:373
std::vector< OSWProtein > proteins_
Definition OSWData.h:426
std::map< UInt32, OSWTransition > transitions_
Definition OSWData.h:425
UInt64 run_id_
the ID of this run from the SQL RUN table
Definition OSWData.h:428
void clearProteins()
only forget protein data
UInt fromNativeID(int transition_id) const
const std::vector< OSWProtein > & getProteins() const
Definition OSWData.h:338
void setProtein(const Size index, OSWProtein &&protein)
Definition OSWData.h:349
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:429
void clear()
forget all data
UInt64 getRunID() const
Definition OSWData.h:388
void checkTransitions_(const OSWProtein &prot) const
void setRunID(const UInt64 run_id)
Definition OSWData.h:383
const std::map< UInt32, OSWTransition > & getTransitions() const
get all transitions mapped by their ID (UInt32)
Definition OSWData.h:368
void addTransition(const OSWTransition &tr)
Adds a transition; do this before adding Proteins.
Definition OSWData.h:318
std::string source_file_
remember from which sql OSW file this data is loaded (to lazy load more data)
Definition OSWData.h:427
Size transitionCount() const
get the total number of transitions (chromatograms)
Definition OSWData.h:356
void addTransition(OSWTransition &&tr)
Definition OSWData.h:323
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:362
A peak group (also called feature) is defined on a small RT range (leftWidth to rightWidth) in a grou...
Definition OSWData.h:136
const std::vector< UInt32 > & getTransitionIDs() const
get the transition ids (can be mapped to the chromatogram XICs in sqMass data)
Definition OSWData.h:185
float getRTRightWidth() const
RT position in seconds of the right border.
Definition OSWData.h:170
OSWPeakGroup(const OSWPeakGroup &rhs)=default
Copy c'tor.
float getRTExperimental() const
observed RT apex position in seconds of the feature
Definition OSWData.h:160
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:175
float getRTLeftWidth() const
RT position in seconds of the left border.
Definition OSWData.h:165
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:196
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:180
A peptide with a charge state.
Definition OSWData.h:210
OSWPeptidePrecursor & operator=(OSWPeptidePrecursor &&rhs)=default
move assignment operator
bool isDecoy() const
is this a decoy feature (from a decoy protein)
Definition OSWData.h:236
std::string seq_
Definition OSWData.h:252
short getCharge() const
precursor charge
Definition OSWData.h:231
float getPCMz() const
m/z of this charged peptide
Definition OSWData.h:241
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 std::string & getSequence() const
the peptide sequence (incl. mods)
Definition OSWData.h:226
OSWPeptidePrecursor(const OSWPeptidePrecursor &rhs)=default
Copy c'tor.
OSWPeptidePrecursor(const std::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
const std::vector< OSWPeakGroup > & getFeatures() const
candidate explanations
Definition OSWData.h:246
std::vector< OSWPeakGroup > features_
Definition OSWData.h:256
A Protein is the highest entity and contains one or more peptides which were found/traced.
Definition OSWData.h:265
OSWProtein(OSWProtein &&rhs)=default
move c'tor
OSWProtein(const OSWProtein &rhs)=default
Copy c'tor.
Size getID() const
Protein ID as recorded by the OSW file (the PROTEIN_ID column in the sqlite schema).
Definition OSWData.h:287
OSWProtein & operator=(const OSWProtein &rhs)=default
assignment operator
OSWProtein(const std::string &accession, const Size id, std::vector< OSWPeptidePrecursor > &&peptides)
custom c'tor which fills all the members with data; all members are read-only
std::vector< OSWPeptidePrecursor > peptides_
Definition OSWData.h:301
OSWProtein & operator=(OSWProtein &&rhs)=default
move assignment operator
OSWProtein()=default
just a dummy feature to allow for acceptor output values etc
std::string accession_
Definition OSWData.h:299
const std::vector< OSWPeptidePrecursor > & getPeptidePrecursors() const
Charged peptide precursors that map to this protein.
Definition OSWData.h:293
const std::string & getAccession() const
Protein accession (UniProt-style identifier supplied at construction).
Definition OSWData.h:281
Size id_
Definition OSWData.h:300
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:30
Level
Tree levels in top-down order.
Definition OSWData.h:33
@ TRANSITION
One fragment-ion transition under a feature (OSWTransition).
Definition OSWData.h:37
@ PEPTIDE
Charged peptide precursor under a protein (OSWPeptidePrecursor).
Definition OSWData.h:35
@ PROTEIN
Top-level protein record (OSWProtein).
Definition OSWData.h:34
@ FEATURE
One candidate peak group (chromatographic feature) under a peptide (OSWPeakGroup).
Definition OSWData.h:36
Index path into the OSWData tree from the root down to a specific node.
Definition OSWData.h:55
bool isSet() const
true if the trace points somewhere (lowest != SIZE_OF_VALUES); false if it is default-constructed.
Definition OSWData.h:63
High-level meta-data of one fragment-ion transition referenced by an OSWPeakGroup.
Definition OSWData.h:81
OSWTransition(const std::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
UInt32 id_
ID as used in OSWPeakGroup::transition_ids.
Definition OSWData.h:121
OSWTransition & operator=(const OSWTransition &rhs)=default
bool is_decoy_
is this a decoy transition (from a decoy protein/peptide)
Definition OSWData.h:124
bool isDecoy() const
is this a decoy transition (from a decoy protein/peptide)
Definition OSWData.h:114
OSWTransition(const OSWTransition &rhs)=default
UInt32 getID() const
ID as used in OSWPeakGroup::transition_ids.
Definition OSWData.h:99
OSWTransition()=default
default c'tor
OSWTransition(OSWTransition &&rhs)=default
float product_mz_
observed product m/z value
Definition OSWData.h:122
OSWTransition & operator=(OSWTransition &&rhs)=default
char getType() const
b, y
Definition OSWData.h:109
char type_
b, y,
Definition OSWData.h:123
float getProductMZ() const
observed product m/z value
Definition OSWData.h:104
const std::string & getAnnotation() const
e.g. y5/-0.002
Definition OSWData.h:94
std::string annotation_
e.g. y5/-0.002
Definition OSWData.h:120