OpenMS
Loading...
Searching...
No Matches
OpenMS::CometNativeIDRemapper Namespace Reference

Rewrite spectrum native IDs to a monotonic "index=N" form and translate PSM references back. More...

Functions

Size rewriteToIndex (MSExperiment &exp)
 Rewrite every spectrum's native ID to "index=N" (monotonic, 0-based).
 
void translateReferencesBack (const MSExperiment &exp, PeptideIdentificationList &pids)
 Translate PSM spectrum references from the rewritten "index=N" form back to the original IDs.
 

Variables

const std::string ORIGINAL_NATIVE_ID = "original_native_id"
 MetaValue key under which the original native ID is stashed by rewriteToIndex().
 

Detailed Description

Rewrite spectrum native IDs to a monotonic "index=N" form and translate PSM references back.

Motivation (CometAdapter): Comet's bundled mzParser greps for "scan=" anywhere in a spectrum native ID and uses atoi of the following digits as a sort key. Bruker DDA native IDs of the form "frame=F scan=S precursor=P" carry a non-monotonic "scan=S" (the TIMS isolation-window start), so mzParser detects "unsorted" scans and falls into a std::sort with a strict-weak-ordering-violating comparator -> undefined behavior / segfault. The workaround is to rewrite native IDs to "index=N" (which mzParser indexes by counter, not by atoi("scan=")) before handing the mzML to Comet, then translate the PSM spectrum references on Comet's output back to the original native IDs.

This namespace exposes that rewrite/restore pair as a small, SDK-free, testable unit so the round-trip can be verified without a Comet binary or vendor data.

Function Documentation

◆ rewriteToIndex()

Size rewriteToIndex ( MSExperiment exp)
inline

Rewrite every spectrum's native ID to "index=N" (monotonic, 0-based).

The original native ID of each spectrum is preserved under the ORIGINAL_NATIVE_ID MetaValue so it can be restored later by translateReferencesBack().

Parameters
expExperiment whose spectra are rewritten in place.
Returns
the number of spectra rewritten.

References MSExperiment::getSpectra(), ORIGINAL_NATIVE_ID, and OpenMS::StringUtils::toStr().

◆ translateReferencesBack()

void translateReferencesBack ( const MSExperiment exp,
PeptideIdentificationList pids 
)
inline

Translate PSM spectrum references from the rewritten "index=N" form back to the original IDs.

Restores the spectrum reference of each PeptideIdentification that points at a rewritten "index=N" native ID to the original native ID recorded by rewriteToIndex(). References that do not match any rewritten spectrum are left untouched. No-op when exp is empty or contains no spectrum with an ORIGINAL_NATIVE_ID MetaValue.

Parameters
expExperiment previously passed to rewriteToIndex() (read-only here).
pidsPeptideIdentifications whose spectrum references are translated in place.

References MSExperiment::empty(), MSExperiment::getSpectra(), ORIGINAL_NATIVE_ID, and MSExperiment::size().

Variable Documentation

◆ ORIGINAL_NATIVE_ID

const std::string ORIGINAL_NATIVE_ID = "original_native_id"
inline

MetaValue key under which the original native ID is stashed by rewriteToIndex().

Referenced by rewriteToIndex(), and translateReferencesBack().