Skip to content

Commit

Permalink
switch to tims_open_v2 to load calibrated data (see michalsta#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgbaltussen committed Feb 22, 2023
1 parent eb782e9 commit f9a29c6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
11 changes: 11 additions & 0 deletions opentims++/bruker_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@

typedef uint64_t tims_open_fun_t(const char *path, uint32_t recalibration);

// Added by Rick Helmus
enum pressure_compensation_strategy {
NoPressureCompensation = 0,
AnalyisGlobalPressureCompensation = 1,
PerFramePressureCompensation = 2,
PerFramePressureCompensationWithMissingReference = 3
};
typedef uint64_t tims_open_v2_fun_t(const char *path, uint32_t recalibration,
pressure_compensation_strategy pres_comp_strat);
// End add

typedef uint32_t tims_convert_fun_t(uint64_t file_hndl, int64_t frame_id, const double *tofs, double *mzs, uint32_t arr_size);

typedef uint32_t tims_scan2inv_ion_mobility_fun_t(uint64_t file_hndl, int64_t frame_id, const double *tofs, double *mzs, uint32_t arr_size);
Expand Down
10 changes: 8 additions & 2 deletions opentims++/scan2inv_ion_mobility_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,19 @@ std::string BrukerScan2InvIonMobilityConverter::get_tims_error()

BrukerScan2InvIonMobilityConverter::BrukerScan2InvIonMobilityConverter(TimsDataHandle& TDH, const std::string& lib_path) : lib_handle(lib_path), bruker_file_handle(0)
{
tims_open = lib_handle.symbol_lookup<tims_open_fun_t>("tims_open");
// Changed by Rick Helmus
// tims_open = lib_handle.symbol_lookup<tims_open_fun_t>("tims_open");
tims_open = lib_handle.symbol_lookup<tims_open_v2_fun_t>("tims_open_v2");
// end change
tims_get_last_error_string = lib_handle.symbol_lookup<tims_get_last_error_string_fun_t>("tims_get_last_error_string");
tims_close = lib_handle.symbol_lookup<tims_close_fun_t>("tims_close");
tims_scannum_to_inv_ion_mobility = lib_handle.symbol_lookup<tims_convert_fun_t>("tims_scannum_to_oneoverk0");
tims_inv_ion_mobility_to_scannum = lib_handle.symbol_lookup<tims_convert_fun_t>("tims_oneoverk0_to_scannum");

bruker_file_handle = (*tims_open)(TDH.tims_dir_path.c_str(), 0); // Recalibrated states not supported
// Changed by Rick Helmus
// bruker_file_handle = (*tims_open)(TDH.tims_dir_path.c_str(), 0); // Recalibrated states not supported
bruker_file_handle = (*tims_open)(TDH.tims_dir_path.c_str(), 1, AnalyisGlobalPressureCompensation);
// End change

if(bruker_file_handle == 0)
throw std::runtime_error("tims_open(" + TDH.tims_dir_path + ") failed. Reason: " + get_tims_error());
Expand Down
5 changes: 4 additions & 1 deletion opentims++/scan2inv_ion_mobility_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ class BrukerScan2InvIonMobilityConverter final : public Scan2InvIonMobilityConve
const LoadedLibraryHandle lib_handle;
uint64_t bruker_file_handle;

tims_open_fun_t* tims_open;
// Changed by Rick Helmus
// tims_open_fun_t* tims_open;
tims_open_v2_fun_t* tims_open;
// end change
tims_get_last_error_string_fun_t* tims_get_last_error_string;
tims_close_fun_t* tims_close;
tims_convert_fun_t* tims_scannum_to_inv_ion_mobility;
Expand Down
10 changes: 8 additions & 2 deletions opentims++/tof2mz_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,19 @@ std::string BrukerTof2MzConverter::get_tims_error()

BrukerTof2MzConverter::BrukerTof2MzConverter(TimsDataHandle& TDH, const std::string& lib_path) : lib_handle(lib_path), bruker_file_handle(0)
{
tims_open = lib_handle.symbol_lookup<tims_open_fun_t>("tims_open");
// Changed by Rick Helmus
// tims_open = lib_handle.symbol_lookup<tims_open_fun_t>("tims_open");
tims_open = lib_handle.symbol_lookup<tims_open_v2_fun_t>("tims_open_v2");
// end change
tims_get_last_error_string = lib_handle.symbol_lookup<tims_get_last_error_string_fun_t>("tims_get_last_error_string");
tims_close = lib_handle.symbol_lookup<tims_close_fun_t>("tims_close");
tims_index_to_mz = lib_handle.symbol_lookup<tims_convert_fun_t>("tims_index_to_mz");
tims_mz_to_index = lib_handle.symbol_lookup<tims_convert_fun_t>("tims_mz_to_index");

bruker_file_handle = (*tims_open)(TDH.tims_dir_path.c_str(), 0); // Recalibrated states not supported
// Changed by Rick Helmus
// bruker_file_handle = (*tims_open)(TDH.tims_dir_path.c_str(), 0); // Recalibrated states not supported
bruker_file_handle = (*tims_open)(TDH.tims_dir_path.c_str(), 1, AnalyisGlobalPressureCompensation);
// End change

if(bruker_file_handle == 0)
throw std::runtime_error("tims_open(" + TDH.tims_dir_path + ") failed. Reason: " + get_tims_error());
Expand Down
5 changes: 4 additions & 1 deletion opentims++/tof2mz_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ class BrukerTof2MzConverter final : public Tof2MzConverter
const LoadedLibraryHandle lib_handle;
uint64_t bruker_file_handle;

tims_open_fun_t* tims_open;
// Changed by Rick Helmus
// tims_open_fun_t* tims_open;
tims_open_v2_fun_t* tims_open;
// end change
tims_get_last_error_string_fun_t* tims_get_last_error_string;
tims_close_fun_t* tims_close;
tims_convert_fun_t* tims_index_to_mz;
Expand Down

0 comments on commit f9a29c6

Please sign in to comment.