OpenMS
Loading...
Searching...
No Matches
QPXIdentity.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
11#include <OpenMS/config.h>
12
14
15#include <cstdint>
16#include <optional>
17#include <string>
18#include <unordered_map>
19#include <variant>
20#include <vector>
21
22namespace OpenMS
23{
24
52namespace QPXIdentity
53{
64 using FeatureLinks = std::unordered_map<Int64, Int64>;
65
67 struct Null {};
68
76 struct Float32
77 {
78 float value;
79 };
80
82 using Value = std::variant<Null,
83 std::string,
84 Int64,
85 Float32,
86 std::vector<Int32>,
87 std::vector<std::string>>;
88
102 OPENMS_DLLAPI std::string formatFloat(float value);
103
115 OPENMS_DLLAPI std::string canonical(const std::vector<Value>& values,
116 const std::vector<size_t>& unordered_list_indices = {});
117
126 OPENMS_DLLAPI Int64 deriveId(const std::vector<Value>& values,
127 const std::vector<size_t>& unordered_list_indices = {});
128
129 // -------------------------------------------------------------------------------------
130 // Per-view identities
131 //
132 // The composite and its ORDER are declared once, here, and every exporter goes through
133 // these functions. The order is part of the hash, so a call site assembling its own vector
134 // would be one argument swap away from ids that no other reader can reproduce.
135 //
136 // These are the composites qpxc hard-codes for OpenMS `-out_qpx` input
137 // (qpx/converters/openms/converter.py), so a conversion re-derives the same values.
138 // -------------------------------------------------------------------------------------
139
141 OPENMS_DLLAPI extern const char* const FEATURE_COMPOSITE;
143 OPENMS_DLLAPI extern const char* const PSM_COMPOSITE;
145 OPENMS_DLLAPI extern const char* const PG_COMPOSITE;
146
162 OPENMS_DLLAPI Int64 featureId(const std::string& run_file_name,
163 const std::string& peptidoform,
164 Int64 charge,
165 std::optional<float> rt,
166 const std::vector<Int32>& scan,
167 float observed_mz);
168
180 OPENMS_DLLAPI Int64 psmId(const std::string& run_file_name,
181 const std::vector<Int32>& scan,
182 const std::string& peptidoform,
183 Int64 charge);
184
202 OPENMS_DLLAPI Int64 pgId(const std::vector<std::string>& pg_accessions,
203 const std::vector<std::string>& grouped_runs,
204 const std::optional<std::string>& label);
205
206} // namespace QPXIdentity
207
208} // namespace OpenMS
int64_t Int64
Signed integer type (64bit)
Definition Types.h:40
float value
Definition QPXIdentity.h:78
const char *const PSM_COMPOSITE
Footer identity_composite for the psm view.
const char *const FEATURE_COMPOSITE
Footer identity_composite for the feature view.
const char *const PG_COMPOSITE
Footer identity_composite for the pg view.
std::unordered_map< Int64, Int64 > FeatureLinks
The feature↔PSM edge of one QPX collection, as psm_id → feature_id.
Definition QPXIdentity.h:64
Int64 featureId(const std::string &run_file_name, const std::string &peptidoform, Int64 charge, std::optional< float > rt, const std::vector< Int32 > &scan, float observed_mz)
feature_id from a feature row's persisted column values
Int64 pgId(const std::vector< std::string > &pg_accessions, const std::vector< std::string > &grouped_runs, const std::optional< std::string > &label)
pg_id from a protein-group row's persisted column values
std::string formatFloat(float value)
Render one float32 the way Python's repr writes it inside JSON.
Int64 deriveId(const std::vector< Value > &values, const std::vector< size_t > &unordered_list_indices={})
Derive an opaque signed 64-bit identity from a composite.
std::string canonical(const std::vector< Value > &values, const std::vector< size_t > &unordered_list_indices={})
Canonical JSON encoding of an identity composite.
std::variant< Null, std::string, Int64, Float32, std::vector< Int32 >, std::vector< std::string > > Value
JSON array of strings (grouped_runs)
Definition QPXIdentity.h:87
Int64 psmId(const std::string &run_file_name, const std::vector< Int32 > &scan, const std::string &peptidoform, Int64 charge)
psm_id from a psm row's persisted column values
A float32 composite component.
Definition QPXIdentity.h:77
A composite component that is JSON null (a null column value)
Definition QPXIdentity.h:67
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19