Establish and validate canonical precursor/transition identifiers for OpenSWATH libraries.
More...
Establish and validate canonical precursor/transition identifiers for OpenSWATH libraries.
OpenSWATH algorithms use string identifiers in OpenSwath::LightTargetedExperiment, while persistent PQP/OSWPQ schemas use integer foreign keys. This helper defines the application-level invariant that the LightTargetedExperiment carries those canonical integer identifiers encoded as decimal strings:
LightCompound.id is the canonical precursor ID.
LightTransition.peptide_ref references that canonical precursor ID.
LightTransition.transition_name is the canonical transition ID.
Arbitrary source identifiers (for example from TSV or TraML) are normalized once at the OpenSWATH library-loading boundary. Database-backed inputs (PQP/OSWPQ) already carry persistent numeric IDs and are validated instead of renumbered.
| static std::optional< std::string > canonicalTargetForDecoyPrecursor |
( |
const std::string & |
decoy_ref, |
|
|
const SourceIDMapping & |
source_ids, |
|
|
const std::string & |
decoy_prefix |
|
) |
| |
|
static |
Resolve the canonical target precursor paired with a source-prefix decoy.
decoy_ref is normally a canonical precursor ID. The source precursor ID is recovered from source_ids, decoy_prefix is removed there, and the matching target source ID is mapped back to its canonical operational ID. If no provenance mapping is available, source-ID input is supported as a compatibility path.
- Returns
- The matching target precursor ID in the same operational domain as the loaded experiment, or std::nullopt if the decoy cannot be paired.
Replace arbitrary source precursor/transition identifiers with deterministic canonical IDs.
Precursor IDs are assigned by lexicographically sorting all unique source compound IDs and numbering them from zero, matching the persistent PQP convention. Compounds that are not referenced by any transition are then omitted from the operational LightTargetedExperiment without compressing the remaining IDs, so sparse precursor IDs are expected. This keeps direct source loading consistent with source-to-PQP round-trips. Transition IDs are assigned from their order in exp.transitions, also starting at zero. Existing transition peptide_ref values are rewritten to the new precursor IDs.
Normalization rebuilds the LightTargetedExperiment rather than changing compound IDs in place, ensuring that its internal compound-reference lookup cache cannot retain source-ID keys after canonicalization. The rebuild moves the contents of exp instead of copying them, so the library is never held twice. All validation happens before that: if an exception listed below is thrown, exp is unchanged. If an allocation fails later, exp is left valid but unspecified and must be discarded.
This function is intended for source-oriented formats such as TSV and TraML. It must not be used to renumber libraries that already contain persistent canonical IDs.
- Parameters
-
| [in,out] | exp | Source-oriented experiment to canonicalize in place. |
- Returns
- Source-ID provenance for the canonicalized experiment. The precursor maps cover every source compound, including compounds omitted from the operational
exp.
- Exceptions
-
| Exception::InvalidValue | If a compound ID is empty/duplicated or a transition references an unknown/empty compound ID. |