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

class  Accessor
 Converts scans independently of each other (random access). More...
 
struct  ScanInfo
 Scan header values needed to select scans before converting them. More...
 
struct  ScanRecord
 Everything of a scan that depends on the scans before it (see header()). 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 scanHeaders (int first, int last, bool precursors, const std::function< bool(const ScanInfo &)> &visit)
 Visit the headers of scans first to last ahead of header(), without peaks.
 
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.
 
ScanRecord record () const
 Record of the scan whose header was read last (by header()).
 
std::unique_ptr< Accessor > accessor () const
 Random access converter for scans whose records were taken.
 
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); may be called at any time.
 

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)

◆ OpenMS::Internal::ThermoRawScanReader::ScanRecord

struct OpenMS::Internal::ThermoRawScanReader::ScanRecord

Everything of a scan that depends on the scans before it (see header()).

With a record, Accessor::convert() converts the scan in any order and on any thread.

Class Members
string configuration_id instrument configuration id
ScanInfo info
string native_id
vector< ThermoPrecursor > precursors resolved in acquisition order

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), or a ZIP archive that holds one .raw file ('.zip' suffix), which is extracted into a temporary directory that lives as long as the reader and its accessors
[in]optionsConversion options; ms_levels / rt / scan ranges are not applied here
Exceptions
Exception::FileNotFoundif path does not exist
Exception::ParseErrorif path is gzip- or bzip2-compressed ('.gz', '.bz2' suffix), or a ZIP archive that holds no .raw file or more than one
Exception::InvalidValueif the .raw file cannot be extracted (e.g. not enough free space)
std::exceptionif the bridge cannot open the file

◆ ~ThermoRawScanReader()

◆ ThermoRawScanReader() [2/2]

Member Function Documentation

◆ accessor()

std::unique_ptr< Accessor > accessor ( ) const

Random access converter for scans whose records were taken.

Call it after the header() pass: precursor intensity estimates use parents from the first scan visited by header() on, as a sequential conversion does.

◆ 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); may be called at any time.

◆ record()

ScanRecord record ( ) const

Record of the scan whose header was read last (by header()).

◆ scanHeaders()

void scanHeaders ( int  first,
int  last,
bool  precursors,
const std::function< bool(const ScanInfo &)> &  visit 
)

Visit the headers of scans first to last ahead of header(), without peaks.

A cheap pass, e.g. to count the scans a filtered conversion selects before streaming them or to index a file for random access. Instrument configurations are registered in the same order as header() would register them (so ids match a single pass), and the state of header() and convert() is not changed otherwise.

Parameters
[in]firstFirst scan number; use firstScan() if precursors are resolved
[in]lastLast scan number
[in]precursorsAlso set ScanInfo::precursor_mz. Reads the trailers and resolves the precursors from first on (slower); otherwise precursor_mz is NaN.
[in]visitCalled for every scan in order; returning false stops the pass

◆ 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