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
97 class OPENMS_DLLAPI BrukerTimsFile : public ProgressLogger
98 {
99 public:
102 struct Config
103 {
104 double calibration_tolerance = 0.0;
105 bool calibrate = false;
108
109 bool load_ms1 = true;
112
113 bool load_ms2 = true;
117
148 uint32_t frame_id_min = 0;
149 uint32_t frame_id_max = std::numeric_limits<uint32_t>::max();
150
159 double rt_min_sec = 0.0;
160 double rt_max_sec = std::numeric_limits<double>::infinity();
161
173 bool rt_selects_spectra = false;
174
185 double im_min = 0.0;
186 double im_max = std::numeric_limits<double>::infinity();
187
199 enum class CentroidAlgo { OFF, GREEDY2D, HILL_BASED };
200
204 CentroidAlgo ms1_centroid_algo = CentroidAlgo::OFF;
205
222 CentroidAlgo ms2_centroid_algo = CentroidAlgo::OFF;
223
224 float ms1_centroid_mz_ppm = 10.0f;
225 float ms1_centroid_im_pct = 0.0f;
226 int ms1_centroid_max_peaks = 100000;
227
228 float ms2_centroid_mz_ppm = 20.0f;
229 double centroid_valley_factor = 1.3;
230 Size ms1_centroid_min_hill_length = 1;
231 Size ms2_centroid_min_hill_length = 2;
232 Size centroid_max_scan_gap = 0;
233 bool expose_hill_bounds = false;
234
244 bool isotopic_prefilter = false;
245 double isotopic_prefilter_tol_ppm = 50.0;
246
247 int dia_ms2_n_neighbors = 0;
248 int dia_ms2_min_support = 1;
249 bool dia_ms2_centroid = false;
250
251 int ms1_n_neighbors = 0;
254 int ms1_min_support = 0;
258 double ms1_max_rt_distance_sec = 0.0;
263
264 enum ExportMode { AUTO, SPECTRUM, FRAME };
265 ExportMode export_mode = AUTO;
266
290 enum class TimsCalibrationStrategy { AUTO, BRUKER_SDK, RATIONAL, LINEAR };
291 TimsCalibrationStrategy tims_calibration_strategy = TimsCalibrationStrategy::AUTO;
292
296 enum class PressureCompensation { NONE, GLOBAL, PER_FRAME };
297 PressureCompensation pressure_compensation = PressureCompensation::NONE;
298
301 std::string bruker_sdk_path;
302 };
303
305 enum class DataFormat
306 {
307 NONE,
308 TDF,
309 TSF,
310 BAF,
311 UNREADABLE_ARCHIVE
312 };
313
322 static DataFormat detectFormat(const std::string& path);
323
331 static void checkDataFormat(const std::string& path);
332
334 struct DIAStreamingMetadata
335 {
336 std::vector<OpenSwath::SwathMap> boundaries;
337 int nr_ms1_spectra = 0;
338 std::vector<int> nr_ms2_spectra;
339 };
340
343 DIAStreamingMetadata readDIAMetadata(const std::string& path, ExperimentalSettings& exp_settings);
345 DIAStreamingMetadata readDIAMetadata(const std::string& path, ExperimentalSettings& exp_settings,
346 const Config& config);
347
351 void loadDIAStreaming(const std::string& path, FullSwathFileConsumer& consumer);
353 void loadDIAStreaming(const std::string& path, FullSwathFileConsumer& consumer,
354 const Config& config);
355
370 void load(const std::string& path, MSExperiment& exp);
372 void load(const std::string& path, MSExperiment& exp, const Config& config);
373
388 void transform(const std::string& path, Interfaces::IMSDataConsumer* consumer);
390 void transform(const std::string& path, Interfaces::IMSDataConsumer* consumer, const Config& config);
391
392 private:
394 using SpectrumSink = std::function<void(MSSpectrum&)>;
395
396 // The public read functions of the same names run these and report SQLite and decoding errors as Exception::ParseError
397 DIAStreamingMetadata readDIAMetadata_(const std::string& path, ExperimentalSettings& exp_settings, const Config& config);
398 void loadDIAStreaming_(const std::string& path, FullSwathFileConsumer& consumer, const Config& config);
399 void load_(const std::string& path, MSExperiment& exp, const Config& config);
400 void transform_(const std::string& path, Interfaces::IMSDataConsumer* consumer, const Config& config);
401
402 // The loaders emit their spectra in order of retention time, spectra of equal retention time MS1
403 // first, unless the configuration is one of the two that transform() names.
404
406 void loadDDA_(TimsDataHandle& handle, const SpectrumSink& sink, const Config& config);
407
409 void loadDIA_(TimsDataHandle& handle, const SpectrumSink& sink, const Config& config);
410
412 void loadFrames_(TimsDataHandle& handle, const SpectrumSink& sink, const Config& config);
413
415 struct TSFRun;
416
418 void loadTSF_(TSFRun& run, const SpectrumSink& sink);
419
422 void loadExperimentalSettings_(const std::string& path, const std::string& d_path, ExperimentalSettings& settings);
423
425 struct UnpackedArchive;
426
428 static std::shared_ptr<UnpackedArchive> unpack_(const std::string& path);
429
432 std::shared_ptr<UnpackedArchive> takeUnpacked_(const std::string& path);
433
435 std::shared_ptr<UnpackedArchive> unpacked_;
436 };
437
438} // namespace OpenMS
439
440#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