Skip to content

Add native Thermo RAW file reading via openms-thermo-bridge - #9234

Closed
jpfeuffer with Copilot wants to merge 2 commits into
developfrom
copilot/add-support-reading-thermo-raw-files
Closed

jpfeuffer with Copilot wants to merge 2 commits into
developfrom
copilot/add-support-reading-thermo-raw-files

Conversation

Copilot AI commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Integrates jpfeuffer/openms-thermo-bridge to enable direct reading of Thermo RAW files into MSExperiment, eliminating the need for external conversion tools like ThermoRawFileParser.

CMake integration

  • New WITH_THERMO_RAW option (OFF by default), mirrors WITH_OPENTIMS pattern
  • FetchContent from GitHub with find_package(OpenMSThermoBridge) fallback
  • ENABLE_THERMO_RAW_TESTS downloads ginkgotoxin-ms-positive.raw test data
  • Managed .NET runtime files deployed via openms_thermo_bridge_copy_runtime_files()
  • WITH_THERMO_RAW exported in OpenMSConfig.cmake.in

ThermoRawFile class (FORMAT/ThermoRawFile.{h,cpp})

  • Follows BrukerTimsFile pattern: ProgressLogger subclass, #ifdef WITH_THERMO_RAW guard
  • Reads all scans with RT (min→sec), MS level, polarity, native ID, scan filter
  • MSn precursor metadata: monoisotopic m/z, charge, isolation width, activation type (CID/HCD/ETD/ECD), collision energy
  • Source file + instrument metadata populated on the experiment

FileHandler routing

  • FileTypes::RAW marked {PROVIDES_EXPERIMENT, READABLE}
  • FileHandler::loadExperiment routes .raw → ThermoRawFile::load with MS-level filtering
  • Returns UNKNOWN when WITH_THERMO_RAW is not compiled in

Usage

cmake -DWITH_THERMO_RAW=ON -DENABLE_THERMO_RAW_TESTS=ON ..
MSExperiment exp;
FileHandler().loadExperiment("sample.raw", exp);
// or directly:
ThermoRawFile().load("sample.raw", exp);

Runtime requirements

.NET 8 runtime + managed bridge DLLs (auto-deployed by CMake). The bridge embeds the .NET host to call ThermoFisher.RawFileReader natively — no Mono or external process needed.

Copilot AI and others added 2 commits April 28, 2026 16:40
Integrates github.com/jpfeuffer/openms-thermo-bridge using CMake FetchContent
to enable native reading of Thermo RAW files into MSExperiment.

- Add WITH_THERMO_RAW CMake option (OFF by default)
- FetchContent openms-thermo-bridge from GitHub
- Create ThermoRawFile class (header + implementation)
- Register in FileHandler, FileTypes, and FORMAT sources
- Handle runtime file deployment for managed .NET bridge DLLs
- Add test data download option (ENABLE_THERMO_RAW_TESTS)

Agent-Logs-Url: https://github.com/OpenMS/OpenMS/sessions/0baa4939-e841-4551-84a6-7d773b80aa2c

Co-authored-by: jpfeuffer <[email protected]>
- Remove unnecessary DataProcessing clear for centroid scans
- Add comment explaining HCD -> BEAM mapping
- Add warning log for unknown activation types
- Fix FetchContent SOURCE_DIR variable name typo

Agent-Logs-Url: https://github.com/OpenMS/OpenMS/sessions/0baa4939-e841-4551-84a6-7d773b80aa2c

Co-authored-by: jpfeuffer <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds optional native Thermo RAW reading support to OpenMS via the external openms-thermo-bridge, wiring it into build configuration and FileHandler so .raw files can be loaded directly into MSExperiment.

Changes:

  • Introduces WITH_THERMO_RAW / ENABLE_THERMO_RAW_TESTS CMake options and fetches openms-thermo-bridge when enabled.
  • Adds new FORMAT/ThermoRawFile reader and routes FileHandler::loadExperiment() for FileTypes::RAW.
  • Updates FileTypes::RAW annotations/properties and mzML label mapping.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
CMakeLists.txt Adds build/test-data options for Thermo RAW support.
cmake/cmake_findExternalLibs.cmake Fetches/locates OpenMSThermoBridge when WITH_THERMO_RAW is enabled.
cmake/OpenMSConfig.cmake.in Exports the WITH_THERMO_RAW feature flag.
src/openms/CMakeLists.txt Links OpenMS against the thermo bridge and deploys runtime files when enabled.
src/openms/include/OpenMS/FORMAT/ThermoRawFile.h Declares the new RAW reader API behind WITH_THERMO_RAW.
src/openms/include/OpenMS/FORMAT/sources.cmake Installs/compiles the new header conditionally.
src/openms/source/FORMAT/ThermoRawFile.cpp Implements scan-by-scan RAW loading via the bridge.
src/openms/source/FORMAT/FileHandler.cpp Routes .raw loading to ThermoRawFile and applies MS-level filtering.
src/openms/source/FORMAT/FileTypes.cpp Marks RAW as readable/experiment-providing and adds mzML label.
src/openms/source/FORMAT/sources.cmake Builds the new reader conditionally.

endProgress();

// Sort by RT
exp.sortSpectra(true);

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After loading and sorting spectra, MSExperiment ranges are not updated. Most loaders call exp.updateRanges() so min/max RT/mz/intensity reflect the loaded data; add an updateRanges call after sortSpectra(true) (and after any filtering) to keep experiment metadata consistent.

Suggested change
exp.sortSpectra(true);
exp.sortSpectra(true);
exp.updateRanges();

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be true

Comment on lines +9 to +16
#include <OpenMS/config.h>

#ifdef WITH_THERMO_RAW

#include <OpenMS/FORMAT/ThermoRawFile.h>
#include <OpenMS/CONCEPT/Exception.h>
#include <OpenMS/CONCEPT/LogStream.h>
#include <OpenMS/KERNEL/MSSpectrum.h>

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ThermoRawFile.cpp uses std::filesystem::path but does not include . Relying on transitive includes is non-portable and can break builds on some platforms/compilers; include the standard header explicitly in this translation unit.

Copilot uses AI. Check for mistakes.
FetchContent_Declare(
OpenMSThermoBridge
GIT_REPOSITORY https://github.com/jpfeuffer/openms-thermo-bridge.git
GIT_TAG main

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This FetchContent dependency is not pinned (GIT_TAG main). Using a moving branch makes builds non-reproducible and can unintentionally pull breaking or compromised commits; pin to a specific release tag or commit SHA.

Suggested change
GIT_TAG main
# Pin to a specific reviewed upstream revision to keep builds reproducible.
GIT_TAG 0123456789abcdef0123456789abcdef01234567

Copilot uses AI. Check for mistakes.

FetchContent_MakeAvailable(OpenMSThermoBridge)

message(STATUS "openms-thermo-bridge: built from source (${openmsthermobridge_SOURCE_DIR})")

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The status message references ${openmsthermobridge_SOURCE_DIR}, but the FetchContent name is OpenMSThermoBridge, so the correct variable is ${OpenMSThermoBridge_SOURCE_DIR}. As written, the printed source dir will be empty/misleading.

Suggested change
message(STATUS "openms-thermo-bridge: built from source (${openmsthermobridge_SOURCE_DIR})")
message(STATUS "openms-thermo-bridge: built from source (${OpenMSThermoBridge_SOURCE_DIR})")

Copilot uses AI. Check for mistakes.
Comment on lines 100 to 104
TypeNameBinding(FileTypes::XQUESTXML, "xquest.xml", "xquest.xml file", {PROP::PROVIDES_IDENTIFICATIONS, PROP::READABLE, PROP::WRITEABLE}),
TypeNameBinding(FileTypes::SPECXML, "spec.xml", "spec.xml file", {}),
TypeNameBinding(FileTypes::JSON, "json", "JavaScript Object Notation file", {PROP::READABLE, PROP::WRITEABLE}),
TypeNameBinding(FileTypes::RAW, "raw", "(Thermo) Raw data file", {}),
TypeNameBinding(FileTypes::RAW, "raw", "(Thermo) Raw data file", {PROP::PROVIDES_EXPERIMENT, PROP::READABLE}),
TypeNameBinding(FileTypes::OMS, "oms", "OpenMS SQLite file", {PROP::PROVIDES_IDENTIFICATIONS, PROP::PROVIDES_FEATURES, PROP::PROVIDES_CONSENSUSFEATURES}),

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking FileTypes::RAW as READABLE/PROVIDES_EXPERIMENT changes the result of FileTypeList::typesWithProperties({READABLE}) and will make the existing unit test expectation in src/tests/class_tests/openms/source/FileTypes_test.cpp (currently g.getTypes().size() == 44) fail. Update the test to match the new readable type count.

Copilot uses AI. Check for mistakes.
std::remove_if(exp.getSpectra().begin(), exp.getSpectra().end(),
[this](const MSSpectrum& s) { return !options_.containsMSLevel(s.getMSLevel()); }),
exp.getSpectra().end());
}

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After MS-level filtering via erase/remove_if, exp's cached ranges can become stale (and ThermoRawFile currently doesn't update ranges at all). Call exp.updateRanges() after filtering so downstream code sees consistent min/max ranges.

Suggested change
}
}
exp.updateRanges();

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably true

Comment on lines +44 to +45
src.setFileType("RAW");
src.setNativeIDType("scan number");

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SourceFile metadata is currently set to fileType="RAW" and nativeIDType="scan number" while the accession indicates Thermo nativeID format. When writing mzML, OpenMS looks up CV terms by name (not by the stored accession) and will fall back to default CV terms if the names don't match; set fileType/nativeIDType to the correct CV term names (e.g., "Thermo RAW format" and "Thermo nativeID format") so mzML export preserves correct metadata.

Suggested change
src.setFileType("RAW");
src.setNativeIDType("scan number");
src.setFileType("Thermo RAW format");
src.setNativeIDType("Thermo nativeID format");

Copilot uses AI. Check for mistakes.
{
throw Exception::FileNotFound(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, path);
}

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ThermoRawFile::load currently appends spectra to whatever is already in exp. Other OpenMS loaders typically clear/reset the experiment at the start of load(); consider clearing exp (and optionally keeping meta data) so repeated calls don't accidentally accumulate spectra.

Suggested change
// Loaders are expected to populate the output experiment from scratch.
// Reset here to avoid accumulating spectra/metadata across repeated calls.
exp = MSExperiment();

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah maybe

spectrum.setNativeID("scan=" + std::to_string(scan));

// Centroid / profile
const bool centroid = raw.is_centroid_scan(scan);

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spectrum centroid/profile status is detected (raw.is_centroid_scan(scan)) but never propagated to the MSSpectrum metadata. Set spectrum.setType(...) appropriately (CENTROID vs PROFILE) so downstream algorithms can rely on spectrum type being correct.

Suggested change
const bool centroid = raw.is_centroid_scan(scan);
const bool centroid = raw.is_centroid_scan(scan);
spectrum.setType(centroid ? SpectrumSettings::CENTROID : SpectrumSettings::PROFILE);

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is important

@timosachsenberg

Copy link
Copy Markdown
Contributor

nice.

@jpfeuffer

Copy link
Copy Markdown
Contributor

See #9235. Bot was too stupid.

@jpfeuffer jpfeuffer closed this Apr 28, 2026
poshul pushed a commit that referenced this pull request May 23, 2026
#9389)

* [FEATURE] Add Thermo RAW file reading support via openms-thermo-bridge

Integrates github.com/jpfeuffer/openms-thermo-bridge using CMake FetchContent
to enable native reading of Thermo RAW files into MSExperiment.

- Add WITH_THERMO_RAW CMake option (OFF by default)
- FetchContent openms-thermo-bridge from GitHub
- Create ThermoRawFile class (header + implementation)
- Register in FileHandler, FileTypes, and FORMAT sources
- Handle runtime file deployment for managed .NET bridge DLLs
- Add test data download option (ENABLE_THERMO_RAW_TESTS)

Agent-Logs-Url: https://github.com/OpenMS/OpenMS/sessions/0baa4939-e841-4551-84a6-7d773b80aa2c

Co-authored-by: jpfeuffer <[email protected]>

* [FIX] Address code review feedback for ThermoRawFile

- Remove unnecessary DataProcessing clear for centroid scans
- Add comment explaining HCD -> BEAM mapping
- Add warning log for unknown activation types
- Fix FetchContent SOURCE_DIR variable name typo

Agent-Logs-Url: https://github.com/OpenMS/OpenMS/sessions/0baa4939-e841-4551-84a6-7d773b80aa2c

Co-authored-by: jpfeuffer <[email protected]>

* [FIX] Address all review comments and CI test failure for ThermoRawFile PR #9234

Agent-Logs-Url: https://github.com/OpenMS/OpenMS/sessions/e6dab72b-f13f-424e-92be-0d717181976e

Co-authored-by: jpfeuffer <[email protected]>

* Apply suggestion from @jpfeuffer

* How about actually testing it you dumb bot

Co-authored-by: Julianus Pfeuffer <[email protected]>

* [FIX] Register openms_thermo_bridge in CMake export set to fix configure error

Agent-Logs-Url: https://github.com/OpenMS/OpenMS/sessions/471cbc5e-7543-45ba-9854-38e6ff19f0d2

Co-authored-by: jpfeuffer <[email protected]>

* [FIX] Fix ThermoRawFile.cpp compile errors: namespace and scoped enum usage

Agent-Logs-Url: https://github.com/OpenMS/OpenMS/sessions/35b731ed-b44d-42db-9395-038533cc196f

Co-authored-by: jpfeuffer <[email protected]>

* [FIX] Force openms_thermo_bridge to build as static library to fix TOPP linker errors

Agent-Logs-Url: https://github.com/OpenMS/OpenMS/sessions/567f4a37-f528-4846-a93e-0eed64bc36b1

Co-authored-by: jpfeuffer <[email protected]>

* [FIX] Make openms_thermo_bridge fully internal — remove install/export targets

Agent-Logs-Url: https://github.com/OpenMS/OpenMS/sessions/903d2303-d6d8-42aa-a8af-8cd43154dfea

Co-authored-by: jpfeuffer <[email protected]>

* [FIX] Compile openms_thermo_bridge with -fPIC for shared library linking

Agent-Logs-Url: https://github.com/OpenMS/OpenMS/sessions/2d4cb206-3214-4ed2-b80f-74b4e277ccec

Co-authored-by: jpfeuffer <[email protected]>

* disable bridge tests, add class test, disable on macos

* fix(ThermoRawFile_test): MS2-conditional precursor check + Windows runtime copy + macOS arm64 stub

- Test: gate the precursor round-trip assertion on the test data actually
  containing MSn spectra. The bundled ginkgotoxin RAW is MS1-only, so the
  unconditional TEST_EQUAL(found_msn_precursor, true) was failing on
  Linux/Windows. Emit STATUS log when no MSn present so the gap is visible.
- CMake: copy the managed bridge runtime files (ThermoWrapperManaged.dll +
  .runtimeconfig.json) next to ThermoRawFile_test.exe via a POST_BUILD
  step. The bridge searches exe_dir/managed first; on Windows the test
  binary lives in src/tests/class_tests/bin which is a different directory
  from libOpenMS.dll, so the OpenMS-target copy was not visible at runtime.
- Test: provide a placeholder main() when WITH_THERMO_RAW is OFF so the
  test target still links on platforms where the bridge is disabled (macOS
  arm64 default). The empty TU previously caused "Undefined symbols: _main".

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* ci(wheels): disable WITH_THERMO_RAW in pyOpenMS wheel builds

The cibuildwheel manylinux containers and Windows/macOS wheel builders do
not have the .NET SDK pre-installed, so the FetchContent step for
openms-thermo-bridge fails with:

  Could not find DOTNET_EXECUTABLE using the following names: dotnet

Pass -DWITH_THERMO_RAW=OFF in all four wheel cmake invocations (Linux x64,
Linux arm64, macOS arm64, Windows). The wheels stay portable; users who
need Thermo RAW support can build OpenMS from source with the bridge
enabled.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(cmake): default WITH_THERMO_RAW=OFF on Linux arm64/aarch64 too

Thermo's RawFileReader does not ship native dependencies for arm64 on
either macOS or Linux. The bridge configures and builds (it is just
managed .NET), but at runtime the C# code throws a managed exception
when it tries to open a RAW file because the underlying native helpers
aren't present. CI confirmed: ubuntu-24.04-arm fails ThermoRawFile_test
with "Failed to open RAW file (code -2)" (managed exception).

Extend the existing macOS arm64 default-off to also cover Linux arm64
and update the warning/status message accordingly.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* [DOC] Add WITH_THERMO_RAW + ENABLE_THERMO_RAW_TESTS to cmake params docs, note dotnet runtime requirement

Agent-Logs-Url: https://github.com/OpenMS/OpenMS/sessions/9832bbed-ddc6-48f5-a7f3-ecc197b880a8

Co-authored-by: timosachsenberg <[email protected]>

* [FIX] Download and install Thermo RawFileReader license from upstream repo at cmake install phase

Agent-Logs-Url: https://github.com/OpenMS/OpenMS/sessions/58dfa2f7-ca3a-497c-98fd-c5b6ad8c473d

Co-authored-by: jpfeuffer <[email protected]>

* [BUILD,CI] bump openms-thermo-bridge to v0.2.0; enable macOS arm64

v0.2.0 ships native osx-arm64 managed runtime assets, so the
arm64/Apple workarounds added earlier in this branch are no longer
needed.

Changes:
- cmake/cmake_findExternalLibs.cmake: pin GIT_TAG to v0.2.0
- CMakeLists.txt: narrow the arm64 default-OFF guard to Linux aarch64
  only (macOS arm64 is now fully supported); update messages
- .github/workflows/pyopenms-wheels-cibuildwheel.yml: remove
  -DWITH_THERMO_RAW=OFF from the macOS arm64 wheel build job
- ThermoRawFile_test.cpp: update comment to reflect that only Linux
  aarch64 still defaults to OFF

* test(ThermoRawFile): switch test data to PNNL Angiotensin_AllScans.raw, gate behind ENABLE_THERMO_RAW_TESTS (opt-in)

The previous ginkgotoxin sample was MS1-only, leaving the MS2 precursor
round-trip assertion silently skipped. Angiotensin_AllScans.raw (BSD-2-Clause,
Battelle 2018) has 87 MS1 (FTMS Full ms) plus hundreds of MS2 scans with HCD
and supplemental-activation (ETD+HCD, ETD+CID) filters at precursor m/z 432.9,
exercising the activation-method switch in ThermoRawFile.cpp.

- CMakeLists.txt: flip ENABLE_THERMO_RAW_TESTS default to OFF to match the
  ENABLE_OPENTIMS_TESTS pattern (opt-in for integration data downloads). Pin
  FetchContent URL to a specific PNNL commit and verify with URL_HASH SHA256.
- ThermoRawFile_test.cpp: replace the MS1-only-gated round-trip with concrete
  assertions on MS1+MSn presence, positive polarity, precursor m/z preservation
  through mzML, and at least one activation method seen on the MS2 spectra.
- doc/doxygen/install/common-cmake-parameters.doxygen: update ENABLE_THERMO_RAW_TESTS
  default note.

https://claude.ai/code/session_016q1fcq679fQJ2EMRSCxNQY

* ci(macOS): install .NET 8 SDK for OpenMSThermoBridge build

The bridge calls `dotnet publish` for ThermoWrapperManaged.csproj and
FindDotNetHost.cmake needs `nethost.h`/`libnethost` from the
Microsoft.NETCore.App.Host.osx-arm64 SDK pack. macOS runners do not
ship a .NET SDK by default, so configure fails with
`DotNetHost_INCLUDE_DIR/DotNetHost_LIBRARY` missing.

Add an `actions/setup-dotnet@v4` step pinned to 8.0.x (matching the
managed wrapper's net8.0 target) in:
- .github/actions/dependencies/action.yml (covers macOS xcode CI)
- .github/workflows/pyopenms-wheels-cibuildwheel.yml (covers wheel
  build-wheels-macos job)

setup-dotnet exports `DOTNET_ROOT`, which FindDotNetHost.cmake picks
up to locate the host pack.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* ci(macOS): default visibility on openms_thermo_bridge target (try #9392)

Issue #9392: BrukerTimsFile_test fails on macOS xcode when the bridge is
linked into libOpenMS.dylib — catch(const std::exception&) inside
openTimsDataHandle() fails to match std::exception subclasses thrown
from opentims's static lib, leaking out as "No such file or directory".
Validation in PR #9393 confirmed the bridge linkage is the trigger.

Working theory: hidden-by-default C++ visibility (inherited from
OpenMS's global CMAKE_CXX_VISIBILITY_PRESET=hidden) causes the bridge's
template-instantiated typeinfo (std::exception and its derived chain)
to land in libOpenMS.dylib as symbols that don't deduplicate with
opentims's copies inside the same DSO.

Override the bridge's CXX_VISIBILITY_PRESET to `default` and disable
VISIBILITY_INLINES_HIDDEN, mirroring the pattern already in place for
HiGHS in this file. If this resolves test #143 on macOS xcode, the
hypothesis is confirmed and #9392 can be closed.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* Revert "ci(macOS): default visibility on openms_thermo_bridge target (try #9392)"

This reverts commit 46f2478.

* [DIAGNOSTIC #9392] surface throw site in openTimsDataHandle

Visibility tweak in 46f2478 (reverted in 9faac9d) didn't move
the BrukerTimsFile_test failure, so the working theory of cross-DSO
typeinfo divergence is wrong, or at least the simple visibility
override doesn't reach the affected translation units.

Before iterating more CMake guesses, gather evidence: print to stderr
on every path through openTimsDataHandle so the next macOS xcode log
tells us whether the throw is

  (a) inside the TimsDataHandle constructor's try-block but a
      typeinfo mismatch makes catch(const std::exception&) miss it
      — the catch(...) here will fire and print the mangled type;
  (b) past the constructor entirely (lazy validation) — the
      "ctor returned OK" marker will print and the test failure
      is coming from a downstream call (isDIA_/loadDDA_/...).

Different fixes apply in each case, so an empirical one-shot is
worth one ~25-min CI cycle. Revert this commit (or both diagnostic
commits) once the answer lands in #9392.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* [DIAGNOSTIC #9392] print typeinfo addresses + rethrow-as-exception probe

Prior diag showed openTimsDataHandle catch(const std::exception&)
fails to match a real std::__1::system_error throw, but
catch(...) does. The mangled name string is the canonical libc++
one, so this isn't a stdlib-mismatch by name. Two real possibilities
remain:

  (a) Multiple non-coalesced copies of typeinfo for std::exception
      (and chain) inside libOpenMS.dylib — once the bridge is linked,
      hidden-visibility weak symbols don't merge across object files
      with Apple's ld64.
  (b) Something else entirely (linker quirk, libnethost dylib
      shadowing, etc.).

This commit prints, from BrukerTimsFile.cpp's translation unit:
  - the thrown exception's typeinfo pointer
  - &typeid(std::exception/runtime_error/system_error) addresses
  - pointer-equality and name-equality checks against the thrown type
  - the result of std::rethrow_exception caught by std::exception&

If thrown_ti pointer != &typeid(std::system_error) but their .name()
strings match -> (a) confirmed: two typeinfo copies in the same DSO.
If they're pointer-equal but the outer catch still failed -> something
weirder is going on and we need a new theory.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(diag): guard #9392 cxxabi diagnostic behind !defined(_MSC_VER)

Previous diagnostic commit unconditionally included <cxxabi.h>, which
MSVC doesn't ship -> Windows build broke with C1083. The bug only
reproduces on macOS anyway, so gate the include + diagnostic block
behind a non-MSVC check.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* [DIAGNOSTIC #9392] walk thrown_ti's __si/__vmi base chain

Previous diag showed std::system_error typeinfo address matches
between throw and catch sites, but catch(const std::exception&)
still fails. The next address we need is what  (the
typeinfo pointer for runtime_error stored inside system_error's
typeinfo) actually points at -- which copy of std::runtime_error
the throw was bound to.

If __base_type address != local typeid(std::runtime_error) address,
the typeinfo objects live in different dylibs (libc++abi vs.
libc++ or libnethost-shadowed) and that's the explicit divergence
that breaks the catch chain walk.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(diag): replace abi::__si_class_type_info walk with progressive catch probes

Apple libcxxabi <cxxabi.h> does not publicly expose __si_class_type_info /
__vmi_class_type_info, so 4f91e3c broke the macOS build. Replace the
chain walk with three rethrow-and-catch probes (system_error, runtime_error,
exception) that pin the break point in the typeinfo chain without needing
ABI internals.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(BrukerTimsFile): widen openTimsDataHandle catch to runtime_error (#9392)

On macOS xcode with WITH_THERMO_RAW=ON, BrukerTimsFile_test line 115
(TEST_EXCEPTION(Exception::FileNotReadable, f.load("/nonexistent/path.d",
exp))) reported "wrong exception thrown! No such file or directory":

  openTimsDataHandle's catch(const std::exception&) was failing to match
  the std::__1::system_error opentims actually throws.

Diagnosis (see #9392 for the full measurement log):
- typeid(std::system_error) / std::runtime_error addresses in
  BrukerTimsFile.cpp match the thrown exception's chain exactly.
- typeid(std::exception) address does NOT match the address that
  runtime_error's base_type field stores inside the thrown chain.
- catch(std::system_error)  matches the throw    -> chain OK there
  catch(std::runtime_error) matches the throw    -> chain OK there
  catch(std::exception)     does NOT match       -> chain breaks here.

Cause: linking openms-thermo-bridge into libOpenMS.dylib introduces a
second copy of typeinfo for std::exception inside libOpenMS.dylib that
doesn't coalesce with the one libc++abi.dylib exports. Without the
bridge (e.g., on develop, or with WITH_THERMO_RAW=OFF), only libc++abi's
copy is reachable and the catch works. A deeper linker-side fix
(un-exporting the embedded _ZTISt9exception so the references collapse)
is left for #9392.

Fix: catch the runtime_error layer of the chain explicitly, ahead of
the broader std::exception arm. That layer still has typeinfo identity
across the bridge boundary (proven by the catch probe). The
std::exception arm is kept for non-runtime_error subclasses on other
platforms; the catch(...) arm is the last-resort fallback.

This is type-safe defensive code, not a catch-all -- e.what() is
preserved in the messages on the typed arms.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(cmake): update OpenMSThermoBridge to v0.2.1 and adjust build settings for shared library compatibility

fix(BrukerTimsFile): remove redundant runtime_error catch to resolve typeinfo duplication issue on macOS

fix(ThermoRawFile): update polarity and activation type handling for improved compatibility with Thermo data

* fix(cmake): update OpenMSThermoBridge to v0.2.3 and enhance installation comments

* [DOC] Update WITH_THERMO_RAW platform support text

Agent-Logs-Url: https://github.com/OpenMS/OpenMS/sessions/729c1d73-be17-4acd-b06a-2ea769ad3e27

Co-authored-by: timosachsenberg <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: jpfeuffer <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants