BrukerTimsFile#
- class pyopenms.BrukerTimsFile#
Bases:
objectReader for Bruker TimsTOF .d directories via opentims.
Supports DDA-PASEF, DIA-PASEF, and raw frame-level 4D access. Ion mobility data is stored in VSSC (1/K0) units using IM_PEAK format for MS1 and DIA MS2, and scalar drift times for DDA MS2.
load()andtransform()also read TSF data (timsTOF without ion mobility: MALDI imaging and spot runs, LC-MS with TIMS off), one centroided spectrum per frame, MS2 spectra with their precursor.This class is only available when OpenMS is built with
WITH_OPENTIMS=ON(the default). The Bruker SDK (timsdata.dll/libtimsdata.so) is not bundled with pyOpenMS; supply it via theOPENMS_BRUKER_SDK_PATHenvironment variable orConfig.bruker_sdk_path.Use
hasattr(pyopenms, "BrukerTimsFile")to feature-detect at runtime.- __init__() None#
Methods
__init__()checkDataFormat(path)Raises if the path holds Bruker data in a format that cannot be read (BAF); load() does this check itself
detectFormat(path)Which Bruker data format a .d directory or '.d.zip' archive holds, told by its file names (nothing is read or extracted)
endProgress([bytes_processed])Ends the progress display
Returns the type of progress log being used
load(path)Overloaded function.
Increment progress by 1 (according to range begin-end)
readDIAMetadata(path)Overloaded function.
setLogType(type)Sets the progress log that should be used.
setProgress(value)Sets the current progress
startProgress(begin, end, label)transform(path, consumer)Overloaded function.
- class Config#
Bases:
objectProcessing and export configuration for BrukerTimsFile.load() and readDIAMetadata()
- class TimsCalibrationStrategy(*values)#
Bases:
Enum- AUTO = 0#
- BRUKER_SDK = 1#
- LINEAR = 3#
- RATIONAL = 2#
- property bruker_sdk_path: str#
Path to Bruker SDK library (empty = discover from OPENMS_BRUKER_SDK_PATH env var)
- property calibrate: bool#
Enable m/z recalibration (off by default; may fail on some datasets)
- property calibration_tolerance: float#
m/z recalibration tolerance in Da (0 = default 0.1 Da)
- property centroid_max_scan_gap: int#
HILL_BASED (MS1 and MS2): maximum number of consecutive empty IM scans a hill may bridge (default 0 = consecutive scans only)
- property centroid_valley_factor: float#
HILL_BASED (MS1 and MS2): a hill is split at a valley if both neighbouring maxima exceed the valley by this factor (default 1.3; smaller = more splitting)
- property dia_ms2_centroid: bool#
DIA MS2 2D peak picking: Gaussian smoothing + local maxima detection
- property dia_ms2_min_support: int#
DIA MS2 denoising: minimum occupied neighbors in 3x3 (m/z x IM) grid
- property dia_ms2_n_neighbors: int#
DIA MS2 frame aggregation: number of adjacent frames on each side (0 = disabled)
- property export_mode: pyopenms.BrukerTimsFile.Config.ExportMode#
AUTO detects DDA vs DIA; SPECTRUM forces per-precursor; FRAME returns raw 4D frames
- property expose_hill_bounds: bool#
HILL_BASED (MS1 and DIA MS2): attach four float data arrays with the IM and m/z bounds of each centroid’s hill (default False)
- property frame_id_max: int#
Highest frame ID to read (inclusive; default 4294967295 = to the last frame). Frames outside the range are not read.
- property frame_id_min: int#
Lowest frame ID to read (inclusive; frame IDs are 1-based; default 0 = from the first frame)
- property im_max: float#
Upper ion mobility limit, 1/K0 in Vs/cm2 (inclusive; default +inf = no limit). See im_min.
- property im_min: float#
Lower ion mobility limit, 1/K0 in Vs/cm2 (inclusive; default 0.0). load() and transform() remove the peaks outside the range from spectra with an ion mobility per peak and leave out DDA MS2 spectra whose ion mobility lies outside.
- property isotopic_prefilter: bool#
MS1 and DIA MS2: before centroiding, drop peaks without an isotopic partner (charge 1-5) in the same or an adjacent IM scan (default False)
- property isotopic_prefilter_tol_ppm: float#
m/z tolerance in ppm for the isotopic partner match of isotopic_prefilter (default 50.0)
- property load_ms1: bool#
Load MS1 spectra. Disable for MS2-only workflows.
- property load_ms2: bool#
Load MS2 spectra. Disable for MS1-only workflows: the MS2 frames are then not read.
- property ms1_centroid_algo: pyopenms.BrukerTimsFile.Config.CentroidAlgo#
MS1 centroiding algorithm (default OFF). OFF with ms1_centroid_mz_ppm and ms1_centroid_im_pct both > 0 selects GREEDY2D.
- property ms1_centroid_im_pct: float#
GREEDY2D only: MS1 centroiding ion mobility tolerance in percent (0 = GREEDY2D disabled, suggested: 3.0). Ignored by HILL_BASED.
- property ms1_centroid_max_peaks: int#
GREEDY2D only: upper bound on centroided peaks per MS1 spectrum (the most intense ones are kept)
- property ms1_centroid_min_hill_length: int#
HILL_BASED MS1: minimum number of IM scans a hill must span (default 1)
- property ms1_centroid_mz_ppm: float#
MS1 centroiding m/z tolerance in ppm, used by GREEDY2D and HILL_BASED (default 10.0; 0 = MS1 centroiding disabled)
- property ms1_max_rt_distance_sec: float#
Cap RT distance (s) between neighbor MS1 frame and center frame during aggregation (0 = no cap)
- property ms1_min_support: int#
MS1 denoising after aggregation: min occupied 3x3 neighbors (0 = disabled)
- property ms1_n_neighbors: int#
MS1 frame aggregation: adjacent MS1 frames on each side (0 = disabled)
- property ms2_centroid_algo: pyopenms.BrukerTimsFile.Config.CentroidAlgo#
MS2 centroiding algorithm for DIA-PASEF and DDA-PASEF
- property ms2_centroid_min_hill_length: int#
HILL_BASED MS2: minimum number of IM scans a hill must span (default 2, tuned for DIA-PASEF; use 1 for DDA-PASEF)
- property ms2_centroid_mz_ppm: float#
HILL_BASED MS2 centroiding m/z tolerance in ppm (default 20.0; 0 = HILL_BASED MS2 centroiding falls back to OFF with a warning)
- property pressure_compensation: pyopenms.BrukerTimsFile.Config.PressureCompensation#
Pressure compensation strategy (only effective with BRUKER_SDK calibration)
- property rt_max_sec: float#
Upper retention time limit in seconds (inclusive; default +inf = no limit). Resolved to a frame ID range and intersected with frame_id_min/frame_id_max.
- property rt_min_sec: float#
Lower retention time limit in seconds (inclusive; default 0.0). Resolved to a frame ID range and intersected with frame_id_min/frame_id_max.
- property rt_selects_spectra: bool#
What the retention time range selects (default False: frames). True: the spectra of a load without the range whose retention time lies in it, in the same form (DDA MS2 spectra from all of their frames, aggregation with its neighbors outside the range). Honored by load() and transform().
- property tims_calibration_strategy: pyopenms.BrukerTimsFile.Config.TimsCalibrationStrategy#
Strategy for converting TIMS scan indices to 1/K0 values; every strategy except LINEAR also takes m/z from the MzCalibration table
- class DIAStreamingMetadata#
Bases:
objectMetadata describing DIA SWATH layout for streaming consumers
- property boundaries: list[pyopenms.SwathMap]#
One SwathMap per DIA window (MS2 only)
- property nr_ms1_spectra: int#
Number of MS1 frames
- property nr_ms2_spectra: list[int]#
Per-window spectrum counts (parallel to boundaries)
- class DataFormat(*values)#
Bases:
Enum- BAF = 3#
- NONE = 0#
- TDF = 1#
- TSF = 2#
- UNREADABLE_ARCHIVE = 4#
- getMapping()#
Returns a dict mapping int values to enum member name strings.
- static checkDataFormat(path: str) None#
Raises if the path holds Bruker data in a format that cannot be read (BAF); load() does this check itself
- static detectFormat(path: str) pyopenms.BrukerTimsFile.DataFormat#
Which Bruker data format a .d directory or ‘.d.zip’ archive holds, told by its file names (nothing is read or extracted)
- endProgress(bytes_processed: int = 0) None#
Ends the progress display
- getLogType() pyopenms.ProgressLogger.LogType#
Returns the type of progress log being used
- load(path: str) pyopenms.MSExperiment#
- load(path: str, config: pyopenms.BrukerTimsFile.Config) pyopenms.MSExperiment
Overloaded function.
load(path: str) -> pyopenms.MSExperiment
Load a .d directory into a new MSExperiment using default configuration
load(path: str, config: pyopenms.BrukerTimsFile.Config) -> pyopenms.MSExperiment
Load a .d directory into a new MSExperiment with explicit configuration
- nextProgress() None#
Increment progress by 1 (according to range begin-end)
- readDIAMetadata(path: str) tuple#
- readDIAMetadata(path: str, config: pyopenms.BrukerTimsFile.Config) tuple
Overloaded function.
readDIAMetadata(path: str) -> tuple
Read DIA SWATH boundaries and spectrum counts (no peak data). Returns (DIAStreamingMetadata, ExperimentalSettings).
readDIAMetadata(path: str, config: pyopenms.BrukerTimsFile.Config) -> tuple
Read DIA SWATH boundaries and spectrum counts with explicit configuration. Returns (DIAStreamingMetadata, ExperimentalSettings).
- setLogType(type: pyopenms.ProgressLogger.LogType) None#
Sets the progress log that should be used. The default type is NONE!
- setProgress(value: int) None#
Sets the current progress
- startProgress(begin: int, end: int, label: str) None#
- transform(path: str, consumer: object) None#
- transform(path: str, consumer: object, config: pyopenms.BrukerTimsFile.Config) None
Overloaded function.
transform(path: str, consumer: object) -> None
Feed the spectra of a .d directory to a consumer object as they are read, without keeping them: the spectra load() returns, in the same order (default configuration)
transform(path: str, consumer: object, config: pyopenms.BrukerTimsFile.Config) -> None
Feed the spectra of a .d directory to a consumer object as they are read, without keeping them: the spectra load() returns with this configuration, in the same order. DIA data with MS2 aggregation over retention time, and DDA data with calibrate=True on the linear m/z model, are loaded completely first.