![]() |
OpenMS
|
Opaque QPX row identities (feature_id, psm_id, pg_id)
More...
Classes | |
| struct | Float32 |
A float32 composite component. More... | |
| struct | Null |
A composite component that is JSON null (a null column value) More... | |
Typedefs | |
| using | FeatureLinks = std::unordered_map< Int64, Int64 > |
The feature↔PSM edge of one QPX collection, as psm_id → feature_id. | |
| using | Value = std::variant< Null, std::string, Int64, Float32, std::vector< Int32 >, std::vector< std::string > > |
JSON array of strings (grouped_runs) | |
Functions | |
| std::string | formatFloat (float value) |
Render one float32 the way Python's repr writes it inside JSON. | |
| std::string | canonical (const std::vector< Value > &values, const std::vector< size_t > &unordered_list_indices={}) |
| Canonical JSON encoding of an identity composite. | |
| 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. | |
| 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 | 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 | |
| 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 | |
Variables | |
| const char *const | FEATURE_COMPOSITE |
Footer identity_composite for the feature view. | |
| const char *const | PSM_COMPOSITE |
Footer identity_composite for the psm view. | |
| const char *const | PG_COMPOSITE |
Footer identity_composite for the pg view. | |
Opaque QPX row identities (feature_id, psm_id, pg_id)
Every QPX view carries a mandatory int64 identity column that is its primary key. The value is opaque – it is not meant to be parsed or reversed, only compared – and is derived deterministically from a footer-declared identity_composite of ordinary columns.
These functions reproduce qpx.core.data.identity byte for byte. That is a hard requirement, not a nicety. qpxc re-derives feature_id for identified rows from the declared composite, but never rewrites the psm.feature_id that points at it. An OpenMS collection whose ids were invented rather than derived would therefore turn into one with dangling cross-references the moment it was converted – which qpx's own dataset validation reports as dangling_feature_id.
The derivation is BLAKE2b truncated to 8 bytes over the canonical JSON encoding of the composite, read as a big-endian signed 64-bit integer. Negative values are normal and carry no meaning.
feature_id alone, and a test reference must not pin id values across files: the feature composite contains rt and observed_mz, so one ULP of platform drift changes the whole id rather than one digit of it.| struct OpenMS::QPXIdentity::Float32 |
A float32 composite component.
Distinct from double so a caller cannot pass an unrounded value by accident: QPX hashes the value as persisted, so a column stored as float32 must be narrowed to float before it is encoded, whatever precision it was computed at.
| Class Members | ||
|---|---|---|
| float | value | |
| struct OpenMS::QPXIdentity::Null |
A composite component that is JSON null (a null column value)
| using FeatureLinks = std::unordered_map<Int64, Int64> |
The feature↔PSM edge of one QPX collection, as psm_id → feature_id.
Collected by ConsensusMapArrowExport::exportToArrow() / exportToParquet() / exportToParquetStreaming() through their out_links parameter, then handed to the psm exporter, which fills psm.feature_id from it. Keying on the id rather than on a pointer or a row index is what keeps the two directions consistent: both views derive the key from the same four persisted columns, so they agree by construction rather than by both happening to walk the identifications in the same order.
| using Value = std::variant<Null, std::string, Int64, Float32, std::vector<Int32>, std::vector<std::string> > |
JSON array of strings (grouped_runs)
| std::string canonical | ( | const std::vector< Value > & | values, |
| const std::vector< size_t > & | unordered_list_indices = {} |
||
| ) |
Canonical JSON encoding of an identity composite.
Compact separators, ASCII-escaped strings – the exact bytes qpx hashes.
| [in] | values | The composite components, in the order the composite declares |
| [in] | unordered_list_indices | Positions whose list value is a set and is sorted before encoding. QPX uses this for grouped_runs; ordered lists such as scan keep their order. |
["BSA1_F1",[2311],"PEPTIDER",2] | 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.
| [in] | values | The composite components, in the order the composite declares |
| [in] | unordered_list_indices | Set-valued positions, see canonical() |
| 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
Composite: (run_file_name, peptidoform, charge, rt, scan, observed_mz). The floats are what make an unidentified feature row identifiable at all – such a row has an empty peptidoform and an empty scan, and its run and charge are shared with dozens of others.
| [in] | run_file_name | Bare run name (no directory, no extension) |
| [in] | peptidoform | ProForma notation; empty for an unidentified feature |
| [in] | charge | Charge state as persisted (int16) |
| [in] | rt | Retention time in seconds, or nullopt when the column is null |
| [in] | scan | Scan components; empty for an unidentified feature |
| [in] | observed_mz | Experimental m/z |
| std::string formatFloat | ( | float | value | ) |
Render one float32 the way Python's repr writes it inside JSON.
QPX encodes composites with json.dumps, which formats floats with float.__repr__: the shortest decimal that round-trips, switching to exponential notation when the decimal point would fall at position <= -4 or > 16, and appending ".0" to a value that would otherwise look like an integer. C++'s own general format picks between fixed and scientific by a different rule, so it cannot be used directly.
| [in] | value | The value as persisted; it is widened to double first, exactly as Arrow's cast + to_pylist does on the reading side |
"0.1", "1000000000000000.0", "1e+16", "9.999e-05", "-0.0" | 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
Composite: (pg_accessions, grouped_runs, label). Both lists are treated as sets – deduplicated and sorted by their JSON encoding – because neither the order in which a group lists its members nor the order of the runs aggregated into one quantity is part of the group's identity.
The FULL membership keys the id, not the leading protein alone. Two distinct groups that happen to share a leader (P1;P2 and P1;P3) would otherwise derive the same pg_id, and since the id is this view's primary key, that collision is a refused export rather than a merely inaccurate value.
| [in] | pg_accessions | Every accession in the group, in any order |
| [in] | grouped_runs | Raw files of this quantification unit, in any order |
| [in] | label | Channel label, or nullopt for an identification-only group |
| 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
Composite: (run_file_name, scan, peptidoform, charge) – no floats, so a psm identity is stable across platforms.
|
extern |
Footer identity_composite for the feature view.
|
extern |
Footer identity_composite for the pg view.
|
extern |
Footer identity_composite for the psm view.