OpenMS
Loading...
Searching...
No Matches
ThermoRawFileMetadata Class Reference

Resolve the precursor hierarchy from bridge metadata without fetching peaks. Keeps isolation targets distinct from selected ions, and retains SPS selections and supplemental reactions. The filter fallback follows ThermoRawFileParser. More...

#include <OpenMS/FORMAT/HANDLERS/ThermoRawFileMetadata.h>

Classes

Public Member Functions

 ThermoRawFileMetadata ()
 
std::vector< ThermoPrecursor > precursors (const ThermoScan &scan)
 Precursor descriptors of one scan; scans must be passed in acquisition order.
 

Static Public Member Functions

static std::string trailer (const ThermoScan &scan, const std::string &label)
 Value of the trailer-extra entry with exactly this label, or "" if absent.
 
static std::optional< double > number (std::string_view value)
 Parse a trailer value as a number (locale-independent).
 
static std::string filterKey (const std::string &filter)
 Filter key of an MSn filter string: the text between "ms<N> " and the following " [".
 
static bool isSRM (const std::string &filter)
 Whether a filter string describes a selected reaction monitoring (SRM) scan.
 
static double selectedIon (double target, std::optional< double > mono, double width)
 Selected ion m/z of a precursor (ThermoRawFileParser rule).
 
static constexpr int retentionWindow ()
 Number of preceding scans whose state is always retained to resolve master scan references.
 

Private Member Functions

void prune_ (int current)
 Forget scans that no later scan can reference (see precursors()).
 
int parentFromFilter_ (const std::string &key) const
 Most recent scan whose filter key is the parent of key (0 if none).
 
std::vector< double > spsMasses_ (const ThermoScan &scan)
 SPS target masses from the legacy ("SPS Mass N:") or modern ("SPS Masses:") trailer labels.
 

Static Private Member Functions

static bool supplemental_ (const ThermoReaction &first, const ThermoReaction &second)
 True if second is the supplemental (HCD / CID) step of an ETD / ECD reaction first on the same target.
 
static std::size_t lastReaction_ (const std::vector< ThermoReaction > &reactions)
 Index of the reaction that isolated this scan's precursor when no parent is known.
 
static bool isLegacySpsLabel_ (const std::string &label)
 True if label is a legacy "SPS Mass <N>:" label.
 
static bool isModernSpsLabel_ (const std::string &label)
 True if label is "SPS Masses:" or "SPS Masses Continued:".
 

Private Attributes

std::map< int, State > scans_
 retained scans by scan number
 
std::map< std::string, int > filters_
 most recent scan per filter key ("" for MS1), pruned with scans_
 
int first_seen_ = 0
 first scan passed to precursors()
 
int forgotten_below_ = 0
 scans before this one may have been forgotten
 
bool warned_forgotten_ = false
 a forgotten master scan was reported
 
ThermoTrailerIndex trailer_
 per-file positions of the trailer labels read below
 
ThermoTrailerIndex::Key master_key_
 
ThermoTrailerIndex::Key charge_key_
 
ThermoTrailerIndex::Key mono_key_
 
ThermoTrailerIndex::Key sps_masses_key_
 
std::vector< ThermoTrailerIndex::Key > width_keys_
 "MS<level> Isolation Width:" by level
 

Detailed Description

Resolve the precursor hierarchy from bridge metadata without fetching peaks. Keeps isolation targets distinct from selected ions, and retains SPS selections and supplemental reactions. The filter fallback follows ThermoRawFileParser.


Class Documentation

◆ OpenMS::Internal::ThermoRawFileMetadata::State

struct OpenMS::Internal::ThermoRawFileMetadata::State

What is retained per seen scan to resolve later scans' parents.

Class Members
int level = 1 MS order.
string native_id spectrum reference for descendants
vector< ThermoPrecursor > own this scan's own precursor descriptors
int parent = 0 scan this one descends from (0 if unknown)
size_t reactions = 0 reactions consumed up to and including this scan

Constructor & Destructor Documentation

◆ ThermoRawFileMetadata()

Member Function Documentation

◆ filterKey()

static std::string filterKey ( const std::string &  filter)
static

Filter key of an MSn filter string: the text between "ms<N> " and the following " [".

Used to find a scan's parent by filter when no master scan is known, e.g. "FTMS + c NSI Full ms2 500.00@hcd30.00 [100-1000]" yields "500.00@hcd30.00".

Returns
the key, or "" if the filter has no such part.

◆ isLegacySpsLabel_()

static bool isLegacySpsLabel_ ( const std::string &  label)
staticprivate

True if label is a legacy "SPS Mass <N>:" label.

◆ isModernSpsLabel_()

static bool isModernSpsLabel_ ( const std::string &  label)
staticprivate

True if label is "SPS Masses:" or "SPS Masses Continued:".

◆ isSRM()

static bool isSRM ( const std::string &  filter)
static

Whether a filter string describes a selected reaction monitoring (SRM) scan.

The scan mode is one of the words before the mass ranges ("Full", "SIM", "SRM", "CRM", "Z", "Q1MS", "Q3MS"), e.g. "+ c NSI SRM ms2 549.272 [246.107-246.109, 529.776-529.778]" is an SRM scan.

◆ lastReaction_()

static std::size_t lastReaction_ ( const std::vector< ThermoReaction > &  reactions)
staticprivate

Index of the reaction that isolated this scan's precursor when no parent is known.

◆ number()

static std::optional< double > number ( std::string_view  value)
static

Parse a trailer value as a number (locale-independent).

Returns
the number, or an empty optional when the value is empty, not fully numeric (e.g. "2,5" or "12.3abc") or not finite. Surrounding whitespace and a leading '+' are accepted. A literal zero is a valid number, not "missing".

◆ parentFromFilter_()

int parentFromFilter_ ( const std::string &  key) const
private

Most recent scan whose filter key is the parent of key (0 if none).

◆ precursors()

std::vector< ThermoPrecursor > precursors ( const ThermoScan &  scan)

Precursor descriptors of one scan; scans must be passed in acquisition order.

MS1 scans return an empty vector and are only recorded as potential parents. For MSn scans the vector holds the scan's own precursor (isolation target, selected ion, charge, window, parent scan / spectrum reference, activation and supplemental activation), followed by further SPS selections and then the precursors of every ancestor scan, so an MS3 scan lists its MS2 parent's precursor as well. Only each scan's own precursors are retained internally; ancestors are resolved through parent links on request.

Memory stays bounded: the state of scans more than retentionWindow() scans before the current one is forgotten, unless it is an ancestor of a retained scan, and so are filter keys last seen before that. A master scan reference to a forgotten scan is reported with a warning and resolved like an unknown parent. Real acquisitions reference parents within a duty cycle, far below the window.

◆ prune_()

void prune_ ( int  current)
private

Forget scans that no later scan can reference (see precursors()).

◆ retentionWindow()

static constexpr int retentionWindow ( )
inlinestaticconstexpr

Number of preceding scans whose state is always retained to resolve master scan references.

◆ selectedIon()

static double selectedIon ( double  target,
std::optional< double >  mono,
double  width 
)
static

Selected ion m/z of a precursor (ThermoRawFileParser rule).

Parameters
targetisolation window target m/z of the reaction
mono"Monoisotopic M/Z:" trailer value as returned by number()
widthisolation width (0 if unknown)
Returns
the monoisotopic m/z when it is set and plausibly inside the isolation window (narrow windows accept -3.0 / +2.5 Th around the target), otherwise the target

◆ spsMasses_()

std::vector< double > spsMasses_ ( const ThermoScan &  scan)
private

SPS target masses from the legacy ("SPS Mass N:") or modern ("SPS Masses:") trailer labels.

◆ supplemental_()

static bool supplemental_ ( const ThermoReaction &  first,
const ThermoReaction &  second 
)
staticprivate

True if second is the supplemental (HCD / CID) step of an ETD / ECD reaction first on the same target.

◆ trailer()

static std::string trailer ( const ThermoScan &  scan,
const std::string &  label 
)
static

Value of the trailer-extra entry with exactly this label, or "" if absent.

Member Data Documentation

◆ charge_key_

ThermoTrailerIndex::Key charge_key_
private

◆ filters_

std::map<std::string, int> filters_
private

most recent scan per filter key ("" for MS1), pruned with scans_

◆ first_seen_

int first_seen_ = 0
private

first scan passed to precursors()

◆ forgotten_below_

int forgotten_below_ = 0
private

scans before this one may have been forgotten

◆ master_key_

ThermoTrailerIndex::Key master_key_
private

◆ mono_key_

ThermoTrailerIndex::Key mono_key_
private

◆ scans_

std::map<int, State> scans_
private

retained scans by scan number

◆ sps_masses_key_

ThermoTrailerIndex::Key sps_masses_key_
private

◆ trailer_

ThermoTrailerIndex trailer_
private

per-file positions of the trailer labels read below

◆ warned_forgotten_

bool warned_forgotten_ = false
private

a forgotten master scan was reported

◆ width_keys_

std::vector<ThermoTrailerIndex::Key> width_keys_
private

"MS<level> Isolation Width:" by level