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
79 class OPENMS_DLLAPI BrukerTimsFile : public ProgressLogger
80 {
81 public:
83 struct Config
84 {
85 double calibration_tolerance = 0.0;
86 bool calibrate = false;
89
90 bool load_ms1 = true;
93
94 bool load_ms2 = true;
98
129 uint32_t frame_id_min = 0;
130 uint32_t frame_id_max = std::numeric_limits<uint32_t>::max();
131
140 double rt_min_sec = 0.0;
141 double rt_max_sec = std::numeric_limits<double>::infinity();
142
154 bool rt_selects_spectra = false;
155
166 double im_min = 0.0;
167 double im_max = std::numeric_limits<double>::infinity();
168
180 enum class CentroidAlgo { OFF, GREEDY2D, HILL_BASED };
181
185 CentroidAlgo ms1_centroid_algo = CentroidAlgo::OFF;
186
203 CentroidAlgo ms2_centroid_algo = CentroidAlgo::OFF;
204
205 float ms1_centroid_mz_ppm = 10.0f;
206 float ms1_centroid_im_pct = 0.0f;
207 int ms1_centroid_max_peaks = 100000;
208
209 float ms2_centroid_mz_ppm = 20.0f;
210 double centroid_valley_factor = 1.3;
211 Size ms1_centroid_min_hill_length = 1;
212 Size ms2_centroid_min_hill_length = 2;
213 Size centroid_max_scan_gap = 0;
214 bool expose_hill_bounds = false;
215
225 bool isotopic_prefilter = false;
226 double isotopic_prefilter_tol_ppm = 50.0;
227
228 int dia_ms2_n_neighbors = 0;
229 int dia_ms2_min_support = 1;
230 bool dia_ms2_centroid = false;
231
232 int ms1_n_neighbors = 0;
235 int ms1_min_support = 0;
239 double ms1_max_rt_distance_sec = 0.0;
244
245 enum ExportMode { AUTO, SPECTRUM, FRAME };
246 ExportMode export_mode = AUTO;
247
267 enum class TimsCalibrationStrategy { AUTO, BRUKER_SDK, RATIONAL, LINEAR };
268 TimsCalibrationStrategy tims_calibration_strategy = TimsCalibrationStrategy::AUTO;
269
273 enum class PressureCompensation { NONE, GLOBAL, PER_FRAME };
274 PressureCompensation pressure_compensation = PressureCompensation::NONE;
275
278 std::string bruker_sdk_path;
279 };
280
282 enum class DataFormat
283 {
284 NONE,
285 TDF,
286 TSF,
287 BAF,
288 UNREADABLE_ARCHIVE
289 };
290
299 static DataFormat detectFormat(const std::string& path);
300
308 static void checkDataFormat(const std::string& path);
309
311 struct DIAStreamingMetadata
312 {
313 std::vector<OpenSwath::SwathMap> boundaries;
314 int nr_ms1_spectra = 0;
315 std::vector<int> nr_ms2_spectra;
316 };
317
320 DIAStreamingMetadata readDIAMetadata(const std::string& path, ExperimentalSettings& exp_settings);
322 DIAStreamingMetadata readDIAMetadata(const std::string& path, ExperimentalSettings& exp_settings,
323 const Config& config);
324
328 void loadDIAStreaming(const std::string& path, FullSwathFileConsumer& consumer);
330 void loadDIAStreaming(const std::string& path, FullSwathFileConsumer& consumer,
331 const Config& config);
332
342 void load(const std::string& path, MSExperiment& exp);
344 void load(const std::string& path, MSExperiment& exp, const Config& config);
345
360 void transform(const std::string& path, Interfaces::IMSDataConsumer* consumer);
362 void transform(const std::string& path, Interfaces::IMSDataConsumer* consumer, const Config& config);
363
364 private:
366 using SpectrumSink = std::function<void(MSSpectrum&)>;
367
368 // The public read functions of the same names run these and report SQLite and decoding errors as Exception::ParseError
369 DIAStreamingMetadata readDIAMetadata_(const std::string& path, ExperimentalSettings& exp_settings, const Config& config);
370 void loadDIAStreaming_(const std::string& path, FullSwathFileConsumer& consumer, const Config& config);
371 void load_(const std::string& path, MSExperiment& exp, const Config& config);
372 void transform_(const std::string& path, Interfaces::IMSDataConsumer* consumer, const Config& config);
373
374 // The loaders emit their spectra in order of retention time, spectra of equal retention time MS1
375 // first, unless the configuration is one of the two that transform() names.
376
378 void loadDDA_(TimsDataHandle& handle, const SpectrumSink& sink, const Config& config);
379
381 void loadDIA_(TimsDataHandle& handle, const SpectrumSink& sink, const Config& config);
382
384 void loadFrames_(TimsDataHandle& handle, const SpectrumSink& sink, const Config& config);
385
388 void loadExperimentalSettings_(const std::string& path, const std::string& d_path, ExperimentalSettings& settings);
389
391 struct UnpackedArchive;
392
394 static std::shared_ptr<UnpackedArchive> unpack_(const std::string& path);
395
398 std::shared_ptr<UnpackedArchive> takeUnpacked_(const std::string& path);
399
401 std::shared_ptr<UnpackedArchive> unpacked_;
402 };
403
404} // namespace OpenMS
405
406#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