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
58 class OPENMS_DLLAPI BrukerTimsFile : public ProgressLogger
59 {
60 public:
62 struct Config
63 {
64 double calibration_tolerance = 0.0;
65 bool calibrate = false;
68
69 bool load_ms1 = true;
72
73 bool load_ms2 = true;
77
108 uint32_t frame_id_min = 0;
109 uint32_t frame_id_max = std::numeric_limits<uint32_t>::max();
110
119 double rt_min_sec = 0.0;
120 double rt_max_sec = std::numeric_limits<double>::infinity();
121
133 bool rt_selects_spectra = false;
134
145 double im_min = 0.0;
146 double im_max = std::numeric_limits<double>::infinity();
147
159 enum class CentroidAlgo { OFF, GREEDY2D, HILL_BASED };
160
164 CentroidAlgo ms1_centroid_algo = CentroidAlgo::OFF;
165
182 CentroidAlgo ms2_centroid_algo = CentroidAlgo::OFF;
183
184 float ms1_centroid_mz_ppm = 10.0f;
185 float ms1_centroid_im_pct = 0.0f;
186 int ms1_centroid_max_peaks = 100000;
187
188 float ms2_centroid_mz_ppm = 20.0f;
189 double centroid_valley_factor = 1.3;
190 Size ms1_centroid_min_hill_length = 1;
191 Size ms2_centroid_min_hill_length = 2;
192 Size centroid_max_scan_gap = 0;
193 bool expose_hill_bounds = false;
194
204 bool isotopic_prefilter = false;
205 double isotopic_prefilter_tol_ppm = 50.0;
206
207 int dia_ms2_n_neighbors = 0;
208 int dia_ms2_min_support = 1;
209 bool dia_ms2_centroid = false;
210
211 int ms1_n_neighbors = 0;
214 int ms1_min_support = 0;
218 double ms1_max_rt_distance_sec = 0.0;
223
224 enum ExportMode { AUTO, SPECTRUM, FRAME };
225 ExportMode export_mode = AUTO;
226
246 enum class TimsCalibrationStrategy { AUTO, BRUKER_SDK, RATIONAL, LINEAR };
247 TimsCalibrationStrategy tims_calibration_strategy = TimsCalibrationStrategy::AUTO;
248
252 enum class PressureCompensation { NONE, GLOBAL, PER_FRAME };
253 PressureCompensation pressure_compensation = PressureCompensation::NONE;
254
257 std::string bruker_sdk_path;
258 };
259
261 enum class DataFormat
262 {
263 NONE,
264 TDF,
265 TSF,
266 BAF,
267 UNREADABLE_ARCHIVE
268 };
269
278 static DataFormat detectFormat(const std::string& path);
279
287 static void checkDataFormat(const std::string& path);
288
290 struct DIAStreamingMetadata
291 {
292 std::vector<OpenSwath::SwathMap> boundaries;
293 int nr_ms1_spectra = 0;
294 std::vector<int> nr_ms2_spectra;
295 };
296
299 DIAStreamingMetadata readDIAMetadata(const std::string& path, ExperimentalSettings& exp_settings);
301 DIAStreamingMetadata readDIAMetadata(const std::string& path, ExperimentalSettings& exp_settings,
302 const Config& config);
303
307 void loadDIAStreaming(const std::string& path, FullSwathFileConsumer& consumer);
309 void loadDIAStreaming(const std::string& path, FullSwathFileConsumer& consumer,
310 const Config& config);
311
317 void load(const std::string& path, MSExperiment& exp);
319 void load(const std::string& path, MSExperiment& exp, const Config& config);
320
335 void transform(const std::string& path, Interfaces::IMSDataConsumer* consumer);
337 void transform(const std::string& path, Interfaces::IMSDataConsumer* consumer, const Config& config);
338
339 private:
341 using SpectrumSink = std::function<void(MSSpectrum&)>;
342
343 // The loaders emit their spectra in order of retention time, spectra of equal retention time MS1
344 // first, unless the configuration is one of the two that transform() names.
345
347 void loadDDA_(TimsDataHandle& handle, const SpectrumSink& sink, const Config& config);
348
350 void loadDIA_(TimsDataHandle& handle, const SpectrumSink& sink, const Config& config);
351
353 void loadFrames_(TimsDataHandle& handle, const SpectrumSink& sink, const Config& config);
354
357 void loadExperimentalSettings_(const std::string& path, const std::string& d_path, ExperimentalSettings& settings);
358
360 struct UnpackedArchive;
361
363 static std::shared_ptr<UnpackedArchive> unpack_(const std::string& path);
364
367 std::shared_ptr<UnpackedArchive> takeUnpacked_(const std::string& path);
368
370 std::shared_ptr<UnpackedArchive> unpacked_;
371 };
372
373} // namespace OpenMS
374
375#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