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 String& collection,
79 const String& ms_run,
80 IndexType index_type,
81 const String& index,
82 const String& interpretation = "");
83
90 explicit USI(const 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 String& usi_string);
143
165 static std::optional<USI> tryParse(const String& usi_string);
167
169
170
171 const String& getCollection() const;
172
174 void setCollection(const String& collection);
175
177 const String& getMSRun() const;
178
180 void setMSRun(const String& ms_run);
181
183 IndexType getIndexType() const;
184
186 void setIndexType(IndexType index_type);
187
189 const String& getIndex() const;
190
192 void setIndex(const String& index);
193
195 const String& getInterpretation() const;
196
198 void setInterpretation(const String& interpretation);
199
201 bool hasInterpretation() const;
203
205
206
211 String toString() const;
212
219 bool fromString(const String& usi_string);
221
223
224
236 static USI createFromScanNumber(const String& dataset_id,
237 const String& filename,
238 int scan_number,
239 const String& interpretation = "");
240
249 static USI createFromNativeID(const String& dataset_id,
250 const String& filename,
251 const String& native_id);
252
262 static std::optional<int> extractScanNumberFromNativeID(const String& native_id);
263
270 static String indexTypeToString(IndexType index_type);
271
279 static IndexType indexTypeFromString(const String& type_string);
280
291 static String extractBasename(const String& filepath);
293
295
296
297 static const String& getCVAccession();
298
300 static const String& getCVName();
302
303 protected:
304 String collection_;
305 String ms_run_;
306 IndexType index_type_;
307 String index_;
308 String interpretation_;
309
311 static const String USI_PREFIX;
312
314 static const String CV_ACCESSION;
315
317 static const String CV_NAME;
318 };
319
321 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const USI& usi);
322
323} // namespace OpenMS
A more convenient string class.
Definition String.h:34
Utility class for handling Universal Spectrum Identifiers (USI).
Definition USI.h:54
IndexType
Supported index types in USI.
Definition USI.h:58
USI(const String &usi_string)
Construct a USI from its string representation.
USI()
Default constructor (creates an empty/invalid USI)
USI(const String &collection, const String &ms_run, IndexType index_type, const String &index, const String &interpretation="")
Construct a USI from its components.
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.