OpenMS
Loading...
Searching...
No Matches
BrukerTimsFile.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <OpenMS/config.h>
7
8#ifdef WITH_OPENTIMS
9
14#include <cstdint>
15#include <functional>
16#include <limits>
17#include <memory>
18#include <string>
19
20class TimsDataHandle;
21
22namespace OpenMS
23{
24 class FullSwathFileConsumer;
25
68 class OPENMS_DLLAPI BrukerTimsFile : public ProgressLogger
69 {
70 public:
72 struct Config
73 {
74 double calibration_tolerance = 0.0;
75 bool calibrate = false;
78
79 bool load_ms1 = true;
82
83 bool load_ms2 = true;
87
118 uint32_t frame_id_min = 0;
119 uint32_t frame_id_max = std::numeric_limits<uint32_t>::max();
120
129 double rt_min_sec = 0.0;
130 double rt_max_sec = std::numeric_limits<double>::infinity();
131
143 bool rt_selects_spectra = false;
144
155 double im_min = 0.0;
156 double im_max = std::numeric_limits<double>::infinity();
157
169 enum class CentroidAlgo { OFF, GREEDY2D, HILL_BASED };
170
174 CentroidAlgo ms1_centroid_algo = CentroidAlgo::OFF;
175
192 CentroidAlgo ms2_centroid_algo = CentroidAlgo::OFF;
193
194 float ms1_centroid_mz_ppm = 10.0f;
195 float ms1_centroid_im_pct = 0.0f;
196 int ms1_centroid_max_peaks = 100000;
197
198 float ms2_centroid_mz_ppm = 20.0f;
199 double centroid_valley_factor = 1.3;
200 Size ms1_centroid_min_hill_length = 1;
201 Size ms2_centroid_min_hill_length = 2;
202 Size centroid_max_scan_gap = 0;
203 bool expose_hill_bounds = false;
204
214 bool isotopic_prefilter = false;
215 double isotopic_prefilter_tol_ppm = 50.0;
216
217 int dia_ms2_n_neighbors = 0;
218 int dia_ms2_min_support = 1;
219 bool dia_ms2_centroid = false;
220
221 int ms1_n_neighbors = 0;
224 int ms1_min_support = 0;
228 double ms1_max_rt_distance_sec = 0.0;
233
234 enum ExportMode { AUTO, SPECTRUM, FRAME };
235 ExportMode export_mode = AUTO;
236
256 enum class TimsCalibrationStrategy { AUTO, BRUKER_SDK, RATIONAL, LINEAR };
257 TimsCalibrationStrategy tims_calibration_strategy = TimsCalibrationStrategy::AUTO;
258
262 enum class PressureCompensation { NONE, GLOBAL, PER_FRAME };
263 PressureCompensation pressure_compensation = PressureCompensation::NONE;
264
267 std::string bruker_sdk_path;
268 };
269
271 enum class DataFormat
272 {
273 NONE,
274 TDF,
275 TSF,
276 BAF,
277 UNREADABLE_ARCHIVE
278 };
279
288 static DataFormat detectFormat(const std::string& path);
289
297 static void checkDataFormat(const std::string& path);
298
300 struct DIAStreamingMetadata
301 {
302 std::vector<OpenSwath::SwathMap> boundaries;
303 int nr_ms1_spectra = 0;
304 std::vector<int> nr_ms2_spectra;
305 };
306
309 DIAStreamingMetadata readDIAMetadata(const std::string& path, ExperimentalSettings& exp_settings);
311 DIAStreamingMetadata readDIAMetadata(const std::string& path, ExperimentalSettings& exp_settings,
312 const Config& config);
313
317 void loadDIAStreaming(const std::string& path, FullSwathFileConsumer& consumer);
319 void loadDIAStreaming(const std::string& path, FullSwathFileConsumer& consumer,
320 const Config& config);
321
331 void load(const std::string& path, MSExperiment& exp);
333 void load(const std::string& path, MSExperiment& exp, const Config& config);
334
349 void transform(const std::string& path, Interfaces::IMSDataConsumer* consumer);
351 void transform(const std::string& path, Interfaces::IMSDataConsumer* consumer, const Config& config);
352
353 private:
355 using SpectrumSink = std::function<void(MSSpectrum&)>;
356
357 // The public read functions of the same names run these and report SQLite and decoding errors as Exception::ParseError
358 DIAStreamingMetadata readDIAMetadata_(const std::string& path, ExperimentalSettings& exp_settings, const Config& config);
359 void loadDIAStreaming_(const std::string& path, FullSwathFileConsumer& consumer, const Config& config);
360 void load_(const std::string& path, MSExperiment& exp, const Config& config);
361 void transform_(const std::string& path, Interfaces::IMSDataConsumer* consumer, const Config& config);
362
363 // The loaders emit their spectra in order of retention time, spectra of equal retention time MS1
364 // first, unless the configuration is one of the two that transform() names.
365
367 void loadDDA_(TimsDataHandle& handle, const SpectrumSink& sink, const Config& config);
368
370 void loadDIA_(TimsDataHandle& handle, const SpectrumSink& sink, const Config& config);
371
373 void loadFrames_(TimsDataHandle& handle, const SpectrumSink& sink, const Config& config);
374
377 void loadExperimentalSettings_(const std::string& path, const std::string& d_path, ExperimentalSettings& settings);
378
380 struct UnpackedArchive;
381
383 static std::shared_ptr<UnpackedArchive> unpack_(const std::string& path);
384
387 std::shared_ptr<UnpackedArchive> takeUnpacked_(const std::string& path);
388
390 std::shared_ptr<UnpackedArchive> unpacked_;
391 };
392
393} // namespace OpenMS
394
395#endif // WITH_OPENTIMS
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19