Thermo RAW

Thermo RAW file reading implementation using the pure .NET RawFileReader library released in 2017.

This module provides ThermoRawLoader, a RandomAccessScanSource implementation.

Depends upon the pythonnet project which provides the clr module, enabling nearly seamless interoperation with the Common Language Runtime.

The public interface of this module should be identical to ms_deisotope.data_source.thermo_raw.

Note

This interface was largely based upon the APIs that ProteoWizard used, both in order to understand how the Thermo libraries really worked, and to maintain parity with it.

class ms_deisotope.data_source.thermo_raw_net.ThermoRawLoader(source_file, _load_metadata=True, **kwargs)[source]

Reads scans from Thermo Fisher RAW files directly. Provides both iterative and random access.

close()[source]

Close the underlying file reader.

data_processing()

Describe any preprocessing steps applied to the data described by this instance.

Returns

Return type

list of DataProcessingInformation

file_description()

Describe the file and its components, as well as any content types it has.

Returns

Return type

FileInformation

find_next_ms1(start_index: int) Optional[ms_deisotope.data_source.scan.loader.ScanType]

Locate the MS1 scan following start_index, iterating forwards through scans until either the last scan is reached or an MS1 scan is found.

Returns

Return type

ScanBase or None if not found

find_previous_ms1(start_index: int) Optional[ms_deisotope.data_source.scan.loader.ScanType]

Locate the MS1 scan preceding start_index, iterating backwards through scans until either the first scan is reached or an MS1 scan is found.

Returns

Return type

ScanBase or None if not found

get_scan_by_id(scan_id)[source]

Retrieve the scan object for the specified scan id.

If the scan object is still bound and in memory somewhere, a reference to that same object will be returned. Otherwise, a new object will be created.

Parameters

scan_id (str) – The unique scan id value to be retrieved

Returns

Return type

Scan

get_scan_by_index(index)[source]

Retrieve the scan object for the specified scan index.

This internally calls get_scan_by_id() which will use its cache.

Parameters

index (int) – The index to get the scan for

Returns

Return type

Scan

get_scan_by_time(time)[source]

Retrieve the scan object for the specified scan time.

This internally calls get_scan_by_id() which will use its cache.

Parameters

time (float) – The time to get the nearest scan from

Returns

Return type

Scan

property has_fast_random_access: ms_deisotope.utils.Constant

Check whether the underlying data stream supports fast random access or not.

Even if the file format supports random access, it may be impractical due to overhead in parsing the underlying data stream, e.g. calling gzip.GzipFile.seek() can force the file to be decompressed from the beginning of the file on each call. This property can be used to signal to the caller whether or not it should use a different strategy.

Returns

One of DefinitelyNotFastRandomAccess, MaybeFastRandomAccess, or DefinitelyFastRandomAccess. The first is a False-y value, the latter two will evaluate to True

Return type

Constant

has_ms1_scans()[source]

Checks if this ScanDataSource contains MS1 spectra.

Returns

Returns a boolean value if the presence of MS1 scans is known for certain, or None if it cannot be determined in the case of missing metadata.

Return type

bool or None

has_msn_scans()[source]

Checks if this ScanDataSource contains MSn spectra.

Returns

Returns a boolean value if the presence of MSn scans is known for certain, or None if it cannot be determined in the case of missing metadata.

Return type

bool or None

property index

Accesses the scan index

Returns

Maps scan ID to index

Return type

collections.OrderedDict

initialize_scan_cache()

Initialize a cache which keeps track of which Scan objects are still in memory using a weakref.WeakValueDictionary.

When a scan is requested, if the scan object is found in the cache, the existing object is returned rather than re-read from disk.

instrument_configuration()

Describe the different instrument components and configurations used to acquire scans in this run.

Returns

Return type

list of InstrumentInformation

make_iterator(iterator=None, grouped=None, **kwargs) ms_deisotope.data_source.scan.loader.ScanIterator

Configure the ScanIterator’s behavior, selecting it’s iteration strategy over either its default iterator or the provided iterator argument.

Parameters
  • iterator (Iterator, optional) – The iterator to manipulate. If missing, the default iterator will be used.

  • grouped (bool, optional) – Whether the iterator should be grouped and produce ScanBunch objects or single Scan. If None is passed, has_ms1_scans() will be be used instead. Defaults to None.

next()[source]

Advance the iterator, fetching the next ScanBunch or ScanBase depending upon iteration strategy.

Returns

Return type

ScanBunch or ScanBase

reset()[source]

Reset the iterator, if possible, and clear any caches.

samples()[source]

Describe the sample(s) used to generate the mass spectrometry data contained in this file.

Returns

Return type

list of Sample

property scan_cache

A weakref.WeakValueDictionary mapping used to retrieve scans from memory if available before re-reading them from disk.

software_list() List[ms_deisotope.data_source.metadata.software.Software][source]

Describe any software used on the data described by this instance.

Returns

Return type

list of Software

property source_file_name: Optional[str]

Return the name of the file that backs this data source, if available.

Returns

Return type

str or None

start_from_scan(scan_id=None, rt=None, index=None, require_ms1=True, grouped=True, **kwargs)[source]

Reconstruct an iterator which will start from the scan matching one of scan_id, rt, or index. Only one may be provided.

After invoking this method, the iterator this object wraps will be changed to begin yielding scan bunchs (or single scans if grouped is False).

Parameters
  • scan_id (str, optional) – Start from the scan with the specified id.

  • rt (float, optional) – Start from the scan nearest to specified time (in minutes) in the run. If no exact match is found, the nearest scan time will be found, rounded up.

  • index (int, optional) – Start from the scan with the specified index.

  • require_ms1 (bool, optional) – Whether the iterator must start from an MS1 scan. True by default.

  • grouped (bool, optional) – whether the iterator should yield scan bunches or single scans. True by default.

property time

A indexer facade that lets you index and slice by scan time.

Returns

Return type

TimeIndex