![]() |
OpenMS
|
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_ |
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:
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.
| struct OpenMS::Internal::ThermoRawScanReader::ScanInfo |
Scan header values needed to select scans before converting them.
| 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 |
| 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.
| ThermoRawScanReader | ( | const std::string & | path, |
| const Options & | options | ||
| ) |
Open path.
| [in] | path | Thermo 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] | options | Conversion options; ms_levels / rt / scan ranges are not applied here |
| Exception::FileNotFound | if path does not exist |
| Exception::ParseError | if path is gzip- or bzip2-compressed ('.gz', '.bz2' suffix), or a ZIP archive that holds no .raw file or more than one |
| Exception::InvalidValue | if the .raw file cannot be extracted (e.g. not enough free space) |
| std::exception | if the bridge cannot open the file |
| ~ThermoRawScanReader | ( | ) |
|
delete |
| std::unique_ptr< Accessor > accessor | ( | ) | const |
| 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.
| void convert | ( | MSSpectrum & | spectrum, |
| ExperimentalSettings & | settings, | ||
| const ParentLookup & | parent, | ||
| bool | peaks | ||
| ) |
Convert the scan of the last header() call.
| [out] | spectrum | The converted spectrum (peaks sorted by m/z) |
| [in,out] | settings | Receives instrument configurations as they appear |
| [in] | parent | Lookup of already converted parent spectra (may be empty) |
| [in] | peaks | If false, no peaks or auxiliary arrays are read (metadata only) |
| std::shared_ptr< DataProcessing > dataProcessing | ( | ) | const |
Data processing attached to every converted spectrum and chromatogram.
| void fillSettings | ( | ExperimentalSettings & | settings | ) | const |
Write run-level settings into settings (instrument configurations are added by convert() and addInstrumentConfigurations()).
| int firstScan | ( | ) | const |
First MS scan number (only valid if hasMSData()).
| bool hasMSData | ( | ) | const |
True if the file contains a mass spectrometer controller.
| const ScanInfo & header | ( | int | scan, |
| bool | with_peaks = false |
||
| ) |
Read the header of scan; must be called for every scan in increasing order.
| [in] | scan | Scan number, the successor of the previous call's scan |
| [in] | with_peaks | Also 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. |
| int lastScan | ( | ) | const |
Last MS scan number (only valid if hasMSData()).
|
delete |
| 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.
| [in] | last_scan | Last scan to read ahead |
| [in] | peaks_from | Scans from this number on are read with peaks (as header(scan, true)) |
| 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.
| ScanRecord record | ( | ) | const |
Record of the scan whose header was read last (by 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.
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.
| [in] | first | First scan number; use firstScan() if precursors are resolved |
| [in] | last | Last scan number |
| [in] | precursors | Also set ScanInfo::precursor_mz. Reads the trailers and resolves the precursors from first on (slower); otherwise precursor_mz is NaN. |
| [in] | visit | Called for every scan in order; returning false stops the pass |
| MSChromatogram ticChromatogram | ( | ) | const |
TIC chromatogram as reported by the vendor library (reads every scan header).
|
private |