OpenMS
Loading...
Searching...
No Matches
USI.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: Timo Sachsenberg $
6// $Authors: Timo Sachsenberg $
7// --------------------------------------------------------------------------
8
9#pragma once
10
12#include <OpenMS/config.h>
13
14#include <optional>
15
16namespace OpenMS
17{
53 class OPENMS_DLLAPI USI
54 {
55 public:
57 enum class IndexType
58 {
59 SCAN,
60 INDEX,
61 NATIVEID
62 };
63
65
66
67 USI();
68
78 USI(const std::string& collection,
79 const std::string& ms_run,
80 IndexType index_type,
81 const std::string& index,
82 const std::string& interpretation = "");
83
90 explicit USI(const std::string& usi_string);
91
93 USI(const USI&) = default;
94
96 USI(USI&&) noexcept = default;
97
99 ~USI() = default;
101
103
104
105 USI& operator=(const USI&) = default;
106
108 USI& operator=(USI&&) noexcept = default;
110
112
113
114 bool operator==(const USI& rhs) const;
115
117 bool operator!=(const USI& rhs) const;
118
120 bool operator<(const USI& rhs) const;
122
124
125
132 bool isValid() const;
133
142 static bool isValidUSI(const std::string& usi_string);
143
165 static std::optional<USI> tryParse(const std::string& usi_string);
167
169
170
171 const std::string& getCollection() const;
172
174 void setCollection(const std::string& collection);
175
177 const std::string& getMSRun() const;
178
180 void setMSRun(const std::string& ms_run);
181
183 IndexType getIndexType() const;
184
186 void setIndexType(IndexType index_type);
187
189 const std::string& getIndex() const;
190
192 void setIndex(const std::string& index);
193
195 const std::string& getInterpretation() const;
196
198 void setInterpretation(const std::string& interpretation);
199
201 bool hasInterpretation() const;
203
205
206
211 std::string toString() const;
212
219 bool fromString(const std::string& usi_string);
221
223
224
236 static USI createFromScanNumber(const std::string& dataset_id,
237 const std::string& filename,
238 int scan_number,
239 const std::string& interpretation = "");
240
249 static USI createFromNativeID(const std::string& dataset_id,
250 const std::string& filename,
251 const std::string& native_id);
252
262 static std::optional<int> extractScanNumberFromNativeID(const std::string& native_id);
263
270 static std::string indexTypeToString(IndexType index_type);
271
279 static IndexType indexTypeFromString(const std::string& type_string);
280
291 static std::string extractBasename(const std::string& filepath);
293
295
296
297 static const std::string& getCVAccession();
298
300 static const std::string& getCVName();
302
303 protected:
304 std::string collection_;
305 std::string ms_run_;
306 IndexType index_type_;
307 std::string index_;
308 std::string interpretation_;
309
311 static const std::string USI_PREFIX;
312
314 static const std::string CV_ACCESSION;
315
317 static const std::string CV_NAME;
318 };
319
321 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const USI& usi);
322
323} // namespace OpenMS
Utility class for handling Universal Spectrum Identifiers (USI).
Definition USI.h:54
USI(const std::string &collection, const std::string &ms_run, IndexType index_type, const std::string &index, const std::string &interpretation="")
Construct a USI from its components.
IndexType
Supported index types in USI.
Definition USI.h:58
USI()
Default constructor (creates an empty/invalid USI)
USI(const std::string &usi_string)
Construct a USI from its string representation.
USI(USI &&) noexcept=default
Move constructor.
USI(const USI &)=default
Copy constructor.
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
STL namespace.