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

Scan-by-scan conversion of a Thermo RAW file into OpenMS spectra (private). More...

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

Classes

struct  ScanInfo
 Scan header values needed to select scans before converting them. More...
 

Public Types

using Options = ThermoRawFile::Options
 
using ParentLookup = std::function< const MSSpectrum *(int scan)>
 Returns the converted (peak-sorted) spectrum of a scan or nullptr if it is not available.
 

Public Member Functions

 ThermoRawScanReader (const std::string &path, const Options &options)
 Open path.
 
 ~ThermoRawScanReader ()
 
 ThermoRawScanReader (const ThermoRawScanReader &)=delete
 
ThermoRawScanReader & operator= (const ThermoRawScanReader &)=delete
 
bool hasMSData () const
 True if the file contains a mass spectrometer controller.
 
int firstScan () const
 First MS scan number (only valid if hasMSData()).
 
int lastScan () const
 Last MS scan number (only valid if hasMSData()).
 
void fillSettings (ExperimentalSettings &settings) const
 Write run-level settings into settings (instrument configurations are added by convert() and addInstrumentConfigurations()).
 
const ScanInfo & header (int scan, bool with_peaks=false)
 Read the header of scan; must be called for every scan in increasing order.
 
void readAhead (int last_scan, int peaks_from)
 Read the following scans up to last_scan on worker threads ahead of header().
 
void convert (MSSpectrum &spectrum, ExperimentalSettings &settings, const ParentLookup &parent, bool peaks)
 Convert the scan of the last header() call.
 
void addInstrumentConfigurations (ExperimentalSettings &settings)
 Add the instrument configurations of all scans read by header() so far to settings.
 
std::shared_ptr< DataProcessing > dataProcessing () const
 Data processing attached to every converted spectrum and chromatogram.
 
MSChromatogram ticChromatogram () const
 TIC chromatogram as reported by the vendor library (reads every scan header).
 
void readDetectors (std::vector< MSChromatogram > &chromatograms, std::vector< MSSpectrum > &spectra)
 Detector (UV/PDA/analog) chromatograms and PDA spectra (Options::all_detectors).
 

Private Attributes

std::unique_ptr< Impl > impl_
 

Detailed Description

Scan-by-scan conversion of a Thermo RAW file into OpenMS spectra (private).

Shared by ThermoRawFile::load() and by later streaming and random access readers. A reader opens the RAW file once; all calls must come from one thread.

Usage:

  1. fillSettings() writes the run-level settings (source file, sample, instrument, data processing).
  2. header() must be called for every MS scan in acquisition order, from firstScan() on, because the precursor of an MSn scan is reconstructed from the scans before it. It reads only the scan header, unless the caller asks for the peaks as well because it will convert the scan anyway (one vendor read instead of two).
  3. convert() turns the scan whose header was read last into an MSSpectrum. Scans that are not needed can simply be skipped (no peaks are read for them).

The precursor intensity estimate of an MSn scan sums peaks of its parent scan. convert() asks the ParentLookup for the parent spectrum first (e.g. the already loaded experiment); if it returns nullptr, the reader decodes the parent peaks itself, so filtered loads give the same precursors as a full load.


Class Documentation

◆ OpenMS::Internal::ThermoRawScanReader::ScanInfo

struct OpenMS::Internal::ThermoRawScanReader::ScanInfo

Scan header values needed to select scans before converting them.

Class Members
int ms_level = 0 MS level (0 for unknown or non-MS controllers)
double precursor_mz = 0.0 m/z of the first precursor (NaN if there is none)
double rt = 0.0 retention time in seconds
int scan = 0 scan number
double tic = 0.0 total ion current (NaN if the vendor reports none)

Member Typedef Documentation

◆ Options

using Options = ThermoRawFile::Options

◆ ParentLookup

using ParentLookup = std::function<const MSSpectrum*(int scan)>

Returns the converted (peak-sorted) spectrum of a scan or nullptr if it is not available.

Constructor & Destructor Documentation

◆ ThermoRawScanReader() [1/2]

ThermoRawScanReader ( const std::string &  path,
const Options &  options 
)

Open path.

Parameters
[in]pathThermo RAW file (symbolic links are resolved for the vendor library)
[in]optionsConversion options; ms_levels / rt / scan ranges are not applied here
Exceptions
Exception::FileNotFoundif path does not exist
std::exceptionif the bridge cannot open the file

◆ ~ThermoRawScanReader()

◆ ThermoRawScanReader() [2/2]

Member Function Documentation

◆ addInstrumentConfigurations()

void addInstrumentConfigurations ( ExperimentalSettings &  settings)

Add the instrument configurations of all scans read by header() so far to settings.

Configuration ids are assigned in the order of all scans read, independent of which scans are converted. Call this after the last header() so that configurations of scans that were not converted are also listed, as in a load without scan selection.

◆ convert()

void convert ( MSSpectrum &  spectrum,
ExperimentalSettings &  settings,
const ParentLookup &  parent,
bool  peaks 
)

Convert the scan of the last header() call.

Parameters
[out]spectrumThe converted spectrum (peaks sorted by m/z)
[in,out]settingsReceives instrument configurations as they appear
[in]parentLookup of already converted parent spectra (may be empty)
[in]peaksIf false, no peaks or auxiliary arrays are read (metadata only)

◆ dataProcessing()

std::shared_ptr< DataProcessing > dataProcessing ( ) const

Data processing attached to every converted spectrum and chromatogram.

◆ fillSettings()

void fillSettings ( ExperimentalSettings &  settings) const

Write run-level settings into settings (instrument configurations are added by convert() and addInstrumentConfigurations()).

◆ firstScan()

int firstScan ( ) const

First MS scan number (only valid if hasMSData()).

◆ hasMSData()

bool hasMSData ( ) const

True if the file contains a mass spectrometer controller.

◆ header()

const ScanInfo & header ( int  scan,
bool  with_peaks = false 
)

Read the header of scan; must be called for every scan in increasing order.

Parameters
[in]scanScan number, the successor of the previous call's scan
[in]with_peaksAlso read the peaks for a following convert() call. Saves a second vendor read of the scan when the caller already knows it will convert it.

◆ lastScan()

int lastScan ( ) const

Last MS scan number (only valid if hasMSData()).

◆ operator=()

ThermoRawScanReader & operator= ( const ThermoRawScanReader &  )
delete

◆ readAhead()

void readAhead ( int  last_scan,
int  peaks_from 
)

Read the following scans up to last_scan on worker threads ahead of header().

Uses up to three threads besides the calling one, limited by the OpenMP thread count (none if it is 1). Output is unchanged; header() takes the scans from the read-ahead buffer, which holds a bounded number of scans.

Parameters
[in]last_scanLast scan to read ahead
[in]peaks_fromScans from this number on are read with peaks (as header(scan, true))

◆ readDetectors()

void readDetectors ( std::vector< MSChromatogram > &  chromatograms,
std::vector< MSSpectrum > &  spectra 
)

Detector (UV/PDA/analog) chromatograms and PDA spectra (Options::all_detectors).

◆ ticChromatogram()

MSChromatogram ticChromatogram ( ) const

TIC chromatogram as reported by the vendor library (reads every scan header).

Member Data Documentation

◆ impl_

std::unique_ptr<Impl> impl_
private