Skip to content

[INTERNAL,BUILD] Move remaining TOPP-only helpers out of OpenMS libraries - #10239

Merged
timosachsenberg merged 2 commits into
OpenMS:developfrom
timosachsenberg:refactor/topp-local-sources
Sep 22, 2026
Merged

timosachsenberg merged 2 commits into
OpenMS:developfrom
timosachsenberg:refactor/topp-local-sources

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Moves the remaining single-TOPP-consumer helpers without pyOpenMS bindings into their tool folders, following #10228. The branch is based on develop after #10228 was squash-merged (5e29efe), so this PR contains only the two follow-up commits.

The audit covers the public header trees of OpenMS, OpenMS_CLI, OpenMS_GUI and OpenSwathAlgo, with transitive consumers and binding references checked. Shared code and bound APIs stay in the libraries. The final scan of the 944 remaining library headers finds no eligible single-tool candidates.

Tool Moved classes/helpers
CometAdapter CometModification, CometNativeIDRemapper
DecoyDatabase NeighborSeq
INIUpdater INIUpdater
NucleicAcidSearchEngine ModifiedNASequenceGenerator
OpenSwathExport OpenSwathMatrixExporter, OpenSwathParquetExporter, OpenSwathResultsExporter
OpenSwathInfer OpenSwathGeneInference, OpenSwathPeptideInference, OpenSwathPeptidoformInference, OpenSwathProteinInference
OpenSwathPeakMapExtractor XIPMParquetConsumer
OpenSwathPercolatorScoring OpenSwathOSWParquetReader, OpenSwathPercolatorScoring
OpenSwathWorkflow OpenSwathOSWParquetWriter
ParquetDiff ParquetTableComparator
QualityControl Contaminants, FWHM, FragmentMassError, MQEvidenceExporter, MQExporterHelper, MQMsmsExporter, Ms2SpectrumStats, MzCalibration, PeptideMass, RTAlignment
UniPEFF UniProtXMLHandler, UniProtXMLFile

29 headers and 28 implementations move into src/topp/<Tool>/{include,source}: 28 headers / 27 implementations from libOpenMS, plus INIUpdater from libOpenMS_CLI. Entry points move into the same folders. Library source lists, installed header lists and export annotations are updated. Each tool declares its direct dependencies and supports building against an installed OpenMS CLI SDK.

Tests follow the tool-local convention from #10228. Normal builds retain every original test name. Mixed coverage is separated: the reusable LevelContextInference_test stays in the library project, with wrapper checks in OpenSwathInference_test; XIPMParquetFile_test uses independent reader fixtures, while XIPMParquetRoundTrip_test preserves the original producer-generated fixtures and assertions. The two library tests remain available with TOPP disabled. INIUpdater's existing class test moves unchanged apart from its include and explicitly links OpenMS_CLI.

The review fixes restore executable DISABLE_OPENSWATH guards in the OpenSwathExport and OpenSwathPercolatorScoring test folders; these guards were initially inside a quoted error message.

Additional changes needed for standalone SDK builds:

  • OpenSwathOSWParquetWriter uses the same unsigned sign-bit mask directly instead of importing the private SQLite implementation header.
  • OpenSwathPercolatorScoring owns its native SQLite connection and statement helpers locally. It no longer calls non-exported libOpenMS helpers or exchanges SQLite handles across the SDK boundary. Scoring logic is unchanged.
  • UniProtXMLHandler uses the existing XMLAttributes narrow-name overload and char16_t interface, keeping Xerces private to OpenMS.
  • Register the already-exported ZipRandomAccessFile factory's header in the installed header list, preserving direct archive access with an installed SDK. Libzip remains private to its implementation.

Breaking C++ API change: relocated headers are no longer installed, and these classes no longer belong to libOpenMS / libOpenMS_CLI. No pyOpenMS binding is removed.

Validation on Linux, GCC 13, Release, with GUI and optional vendor backends disabled:

  • Original relocation: built the core and CLI libraries, all 11 affected tools, their class tests and supporting workflow tools. Of 182 selected tests, 180 passed and two returned the expected Comet error-path codes configured as skips. All 29 selected class tests passed. Sixteen workflow tests passed on rerun after relinking two incomplete local helper executables.
  • Review fixes: rebuilt INIUpdater, its class test, ToolHandler_test and the six affected OpenSWATH class tests; all eight class tests passed. Built the three INIUpdater workflow dependencies and manually ran all five existing INIUpdater workflow checks, including output comparisons and the expected failure case; all passed. Those workflow tests retain their existing GUI/X-server CTest gate.
  • Independently built and started all 12 relocated tools against installed SDKs. INIUpdater was checked against a fresh SDK after its move. Relocated headers are absent from the installed SDKs and the libraries export none of the relocated classes' symbols.
  • Normal registration remains at 2880 tests, with INIUpdater_test registered once. BUILD_TOPP_TOOLS=OFF omits the 26 relocated original tests and retains the reusable inference and XIPM reader tests. ENABLE_CLASS_TESTING=OFF registers no tool-local class tests.
  • An isolated configure using the real tool test folders and class-test helper registers six export/scoring tests with DISABLE_OPENSWATH=OFF and zero with it ON. Full DISABLE_OPENSWATH=ON configuration reaches an existing unconditional link to the absent DIAHelper_test target; the reference branch fails identically, and the relevant CMake code is unchanged.
  • INIUpdater's header, implementation and test retain their original logic. The final audit of all four library trees reports no remaining eligible candidates.
  • Rebasing onto the squash-merged prerequisite preserved the validated source tree exactly. Windows and macOS were not run locally.

Summary by CodeRabbit

  • Breaking Changes

    • Several tool-specific headers and implementations are no longer included in the shared OpenMS libraries or installed header set.
    • Tool-specific functionality is now packaged with its corresponding command-line tool rather than exposed as general library APIs.
  • Build Improvements

    • Command-line tools can be configured and built more independently.
    • Tool-level dependencies and compilation settings are handled within each tool.
  • Tests & Documentation

    • Tool tests have been relocated with their tools.
    • Added independent XIPM reader fixtures and expanded round-trip coverage.

Relocate all remaining single-TOPP-consumer helpers without pyOpenMS bindings,
including their tests and direct dependencies. Preserve library-only reader
and inference coverage and validate every tool against an installed SDK.
Restore the executable DISABLE_OPENSWATH guards for export and scoring tests. Move the remaining CLI-only INIUpdater helper and its test next to the tool, and remove its installed header and library registration.
@timosachsenberg
timosachsenberg force-pushed the refactor/topp-local-sources branch from 6328ffb to 0b7f0f2 Compare September 22, 2026 15:23
@timosachsenberg timosachsenberg changed the title [INTERNAL,BUILD] Move remaining TOPP-only helpers out of libOpenMS [INTERNAL,BUILD] Move remaining TOPP-only helpers out of OpenMS libraries Sep 22, 2026
@timosachsenberg
timosachsenberg marked this pull request as ready for review September 22, 2026 16:01
@timosachsenberg

Copy link
Copy Markdown
Contributor Author

@singjc if this move of files is an issue I can move back. Currently cleaning up the core a bit and moving specialized/not wrapped stuff to the topp tools folder

@timosachsenberg
timosachsenberg merged commit 07ca27a into OpenMS:develop Sep 22, 2026
11 of 12 checks passed
timosachsenberg pushed a commit that referenced this pull request Sep 22, 2026
The rebase onto develop turned configure red on every platform, which is why the
wheels failed alongside build-and-test:

  CMake Error at cmake/install_macros.cmake:109 (message):
    Installed header include/OpenMS/FORMAT/ZipRandomAccessFile.h includes a
    private dependency (#include <arrow/io/api.h>).

That is this PR's own guard catching a real leak rather than a false positive.
develop's #10239 added ZipRandomAccessFile.h to the installed header list, and
its Open() returns an arrow::Result<std::shared_ptr<arrow::io::RandomAccessFile>>,
so the header cannot compile without Arrow's development files. It joins
ParquetFile.h on OpenMS_private_headers for exactly the same reason.

Nothing loses access: no installed header includes it, and its consumers all
build against the build tree and already resolve Arrow themselves --
ZipRandomAccessFile_test links the Arrow and Parquet targets, and the
OpenSwathPercolatorScoring and OpenSwathWorkflow tool directories find Arrow in
their own CMakeLists.

Scanned all 910 installed headers for the private dependencies the guard covers;
this was the only one, so configure should get through in one go.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg
timosachsenberg added a commit that referenced this pull request Sep 23, 2026
…10242)

INIUpdater moved out of libOpenMS_CLI into its own tool-local sources
under src/topp/INIUpdater/ (#10239), but three descriptions of the
OpenMS_CLI/openms_cli framework still listed it as part of that
library: the developer tutorial's src/ directory table, the
link-external-code-to-openms.md guide for linking OpenMS::OpenMS_CLI,
and the source comment in src/openms_cli/CMakeLists.txt. Also update
the CHANGELOG's original OpenMS_CLI bullet (#10162), which listed the
same stale contents for the still-unreleased 3.6.0 section.

Add missing PR references (#10228, #10216, #10239) to three other
3.6.0 CHANGELOG bullets describing the OpenNuXL move, the TOPPBase
"official" flag removal and the tool-only-helpers relocation, which
were merged without a citation unlike their neighboring entries.


Claude-Session: https://claude.ai/code/session_01GJr1SK7WrAje7WozyJHSfP

Co-authored-by: Claude <[email protected]>
timosachsenberg added a commit that referenced this pull request Sep 23, 2026
#10239 moved single-consumer helpers from the libraries into their tool
folders. For eight of them that also moved a private dependency of libOpenMS
into the tool: they are built on Arrow/Parquet (and, for the Percolator
scoring, SQLite), so OpenSwathExport, OpenSwathPercolatorScoring,
OpenSwathWorkflow, OpenSwathPeakMapExtractor and ParquetDiff had to find and
link Arrow, Parquet and SQLite themselves, and three of them included
libOpenMS' Arrow-typed internal headers (ParquetFile.h, ZipRandomAccessFile.h),
which a standalone build against an installed OpenMS can only reach if those
headers are installed too.

The tool programs themselves use none of it -- not one arrow:: call in
OpenSwathExport.cpp, OpenSwathWorkflow.cpp and the others. All of it sits in
helper classes whose interfaces are OpenMS types only. So the helpers go back
into the library, behind those interfaces, and the tools link nothing but
OpenMS. Rule applied: a helper built on a private dependency of libOpenMS stays
in the library even if only one tool uses it.

Moved back, to where they were before #10239 (the move is that PR's own patch
for these files, applied in reverse, so the content is exactly the pre-move
content: OPENMS_DLLAPI and <OpenMS/...> include paths restored, and
OpenSwathPercolatorScoring back on the library's SQLite helpers instead of its
tool-local copies):

  ANALYSIS/OPENSWATH  OpenSwathMatrixExporter, OpenSwathParquetExporter,
                      OpenSwathResultsExporter, OpenSwathOSWParquetReader,
                      OpenSwathOSWParquetWriter, OpenSwathPercolatorScoring
  FORMAT/DATAACCESS   XIPMParquetConsumer
  FORMAT              ParquetTableComparator

Their ten class tests return to class_tests/openms with their original
registrations and Arrow/SQLite links; XIPMParquetRoundTrip_test, which #10239
created for the tool folder, joins them, since it tests the library producer
against the library reader. XIPMParquetFile_test keeps #10239's independent
reader fixtures. The five tool test folders are gone, and each tool
CMakeLists is down to find_package(OpenMS) and one executable, with a comment
saying why the helpers are not next to it.

OpenSwathWorkflow.cpp also included ParquetFile.h without using it (no
ParquetFile:: anywhere); dropped. The CHANGELOG entry of #10239, not released
yet, now counts 21 headers / 20 implementations and states the rule.

Not touched: ParquetFile.h and ZipRandomAccessFile.h stay installed here as on
develop; whether they should be is #10223's business, and with this change no
tool includes them any more.

Checked locally with syntax-only compiles, stubbed generated headers and the
Arrow/Parquet 25 C++ headers from the pyarrow wheel:
- all five tool programs against a copy of the include tree without
  ParquetFile.h and ZipRandomAccessFile.h and with no Arrow on the include path
  (OpenSwathWorkflow failed that on the unused include before it was dropped,
  which also shows the setup does catch an Arrow dependency);
- the eight library sources and all eleven class tests, with Arrow and SQLite;
- executables.cmake evaluated with cmake -P: each of the eleven tests is
  registered exactly once.
Nothing was built or run end to end.


Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

Co-authored-by: Claude <[email protected]>
timosachsenberg added a commit that referenced this pull request Sep 23, 2026
…XL/helper-move changes (#10243)

* docs(CHANGELOG): cite PR numbers for tool-registry/NuXL-move/helper-move entries

Three General entries for recently merged PRs (#10228, #10239) were missing
their PR citation, and the Robustness entry for the Deisotoper precursor-mass
fix was missing #10231, which applied the same fix to NuXLDeisotoper. Also
add a dedicated entry for #10216 (TOPP tool registry generated from the
build instead of hard-coded in ToolHandler), whose own PR description
deferred its CHANGELOG entry to this changelog-sync workflow.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013A9BjZDvvP332kBDkwLaen

* docs(CHANGELOG): mention env-var tool registry paths per CodeRabbit review

The tool-registry entry omitted OPENMS_TOOL_REGISTRY_PATH/OPENMS_TTD_INTERNAL_PATH,
a supported way to register external tools without a rebuild, and implied the
build-tree fallback only applies to uninstalled builds when it actually applies
whenever earlier candidates hold no registry.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013A9BjZDvvP332kBDkwLaen

---------

Co-authored-by: Claude <[email protected]>
timosachsenberg pushed a commit that referenced this pull request Sep 28, 2026
The rebase onto develop turned configure red on every platform, which is why the
wheels failed alongside build-and-test:

  CMake Error at cmake/install_macros.cmake:109 (message):
    Installed header include/OpenMS/FORMAT/ZipRandomAccessFile.h includes a
    private dependency (#include <arrow/io/api.h>).

That is this PR's own guard catching a real leak rather than a false positive.
develop's #10239 added ZipRandomAccessFile.h to the installed header list, and
its Open() returns an arrow::Result<std::shared_ptr<arrow::io::RandomAccessFile>>,
so the header cannot compile without Arrow's development files. It joins
ParquetFile.h on OpenMS_private_headers for exactly the same reason.

Nothing loses access: no installed header includes it, and its consumers all
build against the build tree and already resolve Arrow themselves --
ZipRandomAccessFile_test links the Arrow and Parquet targets, and the
OpenSwathPercolatorScoring and OpenSwathWorkflow tool directories find Arrow in
their own CMakeLists.

Scanned all 910 installed headers for the private dependencies the guard covers;
this was the only one, so configure should get through in one go.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg
timosachsenberg pushed a commit that referenced this pull request Sep 29, 2026
The rebase onto develop turned configure red on every platform, which is why the
wheels failed alongside build-and-test:

  CMake Error at cmake/install_macros.cmake:109 (message):
    Installed header include/OpenMS/FORMAT/ZipRandomAccessFile.h includes a
    private dependency (#include <arrow/io/api.h>).

That is this PR's own guard catching a real leak rather than a false positive.
develop's #10239 added ZipRandomAccessFile.h to the installed header list, and
its Open() returns an arrow::Result<std::shared_ptr<arrow::io::RandomAccessFile>>,
so the header cannot compile without Arrow's development files. It joins
ParquetFile.h on OpenMS_private_headers for exactly the same reason.

Nothing loses access: no installed header includes it, and its consumers all
build against the build tree and already resolve Arrow themselves --
ZipRandomAccessFile_test links the Arrow and Parquet targets, and the
OpenSwathPercolatorScoring and OpenSwathWorkflow tool directories find Arrow in
their own CMakeLists.

Scanned all 910 installed headers for the private dependencies the guard covers;
this was the only one, so configure should get through in one go.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg
timosachsenberg added a commit that referenced this pull request Oct 1, 2026
* [API,BUILD] Remove Boost from installed public headers

* Fix CI portability after hiding Boost headers

Constrain IDDataContainer equality to equality-comparable records so MSVC
can instantiate containers whose records have no operator==. Cover both
unsupported equality and supported value comparison in the class test.

Include <exception> directly in PeakPickerIM and remove ProSE's unnecessary
Arrow header include; its OpenMS helpers accept opaque shared pointers.

Rebuilt the core and CLI libraries, affected tools and regression tests on
Linux. All 20 selected class and TOPP checks passed, including QPX export.

* Keep Arrow and OpenTIMS out of the installed header set

Making Boost::boost PRIVATE removed the one public include directory that also
carried the rest of the dependency prefix, so installed headers that include a
private dependency stopped resolving. OpenSwathWorkflow.cpp failed on every
platform with "arrow/api.h: No such file or directory" via ParquetFile.h; the
Linux all_verify_interface_header_sets target and the new Boost-free consumer
would have hit the same wall for ParquetFile.h and RationalScan2ImConverter.h.

Both headers name a private dependency in their declarations -- every
ParquetFile helper takes or returns an arrow::Status / Table / Array, and
RationalScan2ImConverter derives from OpenTIMS' Scan2InvIonMobilityConverter --
so they join the Xerces and SQLite adapters on OpenMS_private_headers instead of
being installed. The readers and writers built on them (XICParquetFile, QPXFile,
BrukerTimsFile, ...) stay installed and keep exposing OpenMS types only.

OpenSwathWorkflow.cpp never used ParquetFile, so its include is dropped rather
than given Arrow; the Boost-free consumer no longer needs the Arrow include
directories and now compiles every installed header with nothing but OpenMS'
own usage requirements. openms_validate_public_headers rejects an installed
header that includes Boost, Arrow/Parquet, Xerces, SQLiteCpp, Eigen, SIMDe or
OpenTIMS at configure time, so the next such leak fails where it is introduced
instead of on a downstream machine.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

* Address review findings on the Boost-private change

Include <concepts> directly in IDDataContainer_test rather than relying on a
transitive include for std::equality_comparable.

Document QTClusterFinder's HeapHandles and RandomShuffler's special members; the
copy keeps the engine state, a moved-from shuffler reseeds on next use.

Reject a NaN probability in binomial_cdf_complement. Every comparison against
NaN is false, so the negated range test waved it through to Boost's domain_error
policy. Behavior for valid probabilities is unchanged.

State getRandomSequence_'s pseudoRNG contract: the draw is reduced modulo the
residue count, so the generator sets the distribution, not the index range. The
index is in range for any int the generator returns, since the unsigned
conversion precedes the modulo.

Give ExternalCode.doxygen the file preamble its sibling pages carry, and drop
its OPENMS_ADDCXX_FLAGS entry -- that variable was removed, so the page was
handing consumers an unsupported instruction.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

* Keep QT clustering's grid order platform-independent

TOPP_FeatureLinkerUnlabeledQT_5_out1 failed on Windows only: the first consensus
element's centroid came out at rt=310.033 against the reference's rt=510. The
Linux and macOS jobs, and the other 2988 tests, were green.

QTClusterFinder::computeClustering_ walks the hash grid with grid.begin()..end()
and numbers its clusters in that order, so the container's bucket order decides
which of two equally good clusters is picked first. HashGrid used
boost::unordered_map with boost::hash, whose bucket policy and hash values are
the same on every platform -- which is what let one shared reference file match
everywhere. Moving it to std::unordered_map with a std::hash-based PositionHash
made both implementation-defined, and MSVC's differ from libstdc++'s and
libc++'s. HashUtils.h says as much: reproducible "on the same platform".

Restore Boost.Unordered here instead of renumbering the references, so
clustering is bit-for-bit what develop produces: the header is now identical to
develop apart from a comment and the already-unused <boost/array.hpp>. To keep
Boost out of the installed interface, HashGrid.h joins OpenMS_private_headers
and QTClusterFinder::Grid becomes an opaque type defined in the .cpp, the same
treatment Heap and HeapHandles already get. Installed QTClusterFinder.h no
longer includes HashGrid.h, so the pyOpenMS binding and other consumers of the
installed headers are unaffected; HashGrid_test links Boost directly.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

* Include HashGrid where it is used in PipEcho

The previous commit made QTClusterFinder::Grid opaque and dropped HashGrid.h
from QTClusterFinder.h, which broke the Linux build: PipEcho's GridWithStorage.h
names HashGrid<value_type> but only included QTClusterFinder.h, so it had been
picking the template up transitively. g++ then resolved grid_index_t and
grid_center_t to nothing, and nearby()'s first parameter to const int&.

Include HashGrid.h there directly, with the standard headers the file uses, and
drop the QTClusterFinder.h include: nothing else in PipEcho comes from it
(Impl.cpp includes ProgressLogger.h itself). HashGrid.h is internal now and
PipEcho lives under source/, so Boost is fine here.

Checked the rest of the surface for the same transitive assumption: no other
translation unit names HashGrid<...> or QTClusterFinder::Grid, and hash_value()
for DPosition is used only by HashGrid_test, which includes the header itself.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

* Keep PipEcho's include of QTClusterFinder.h

Dropping that include from GridWithStorage.h was wrong twice over: PipEcho also
reaches FeatureMap, ConsensusMap and ConsensusFeature through it, via
BaseGroupFinder.h, so Impl.h and Impl.cpp stopped compiling on every platform.
Restore it next to the HashGrid.h include rather than replacing it, which makes
this file's diff against the last green commit purely additive.

Also include DPosition.h in QTClusterFinder_test, which names DPosition<2> and
had been resolving it through the HashGrid.h that QTClusterFinder.h used to pull
in. Feature.h still provides it, but the test should not depend on that.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

* Fix unusable empty-regex fallback and skip the smatch for boolean searches

RegularExpressionAccess::get() returned a default-constructed boost::regex as the
fallback for a RegularExpression with no compiled pattern. A default-constructed
boost::regex holds no implementation and asserts (release builds: UB) as soon as it
is matched against, so `RegularExpression re; re.search(s);` aborts -- reachable from
public API and from pyOpenMS, though not from any current in-tree caller
(SpectrumLookup::readSpectra guards with `if (!scan_regexp.empty())`). Compile the
empty pattern instead, which makes RegularExpression() behave exactly like
RegularExpression("").

RegularExpression::search() always built a boost::smatch, even when the caller only
wanted the boolean. Take Boost's overload without a match_results when first_match is
null -- it is what these call sites used before this PR, and it lets Boost add
match_any -- and assign into the caller's string in place rather than through a
temporary, so a reused output string keeps its capacity.

Measured, so nobody mistakes this for a hot-path fix: on the anchored decoy-affix
pattern DBSuitability searches with, match_any is worth 1.01x, i.e. nothing; on an
unanchored alternation that misses it is 0.92x, i.e. slower. The ~10% seen on very
short inputs comes from not constructing the smatch at all, not from match_any. The
point is to skip work, not to speed up matching.

Verified equivalent to the pre-PR behaviour over 144 pattern/text/path combinations,
including a reused dirty output string and the empty-pattern case.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JuSyPgk7Qeooh6o7D74DGj

* Resolve Boost in the tool directories that use it

develop moved OpenNuXL and OpenSwathPeakMapExtractor into their own directories,
which are meant to build standalone against an installed OpenMS SDK. Both use
Boost directly, and they were getting it from the list in src/topp/CMakeLists.txt,
which does not run in a standalone build. Resolve it where DecoyDatabase and
NucleicAcidSearchEngine already do, in each tool's own CMakeLists, and drop the
two from the parent list so exactly one place handles each tool.

Only the header-only target is needed: OpenNuXL.cpp uses Boost.Range,
NuXLReport.cpp Boost.Math and OpenSwathPeakMapExtractor.cpp boost::numeric_cast.
OpenNuXL.cpp also includes <boost/regex.hpp>, but names no regex symbol, so no
compiled component is involved; the include is left alone rather than removed
here.

Also link Boost into NuXLReport_test. That one is not just a standalone gap:
openms_add_tool_class_test() links ${OpenMS_LIBRARIES}, which stopped carrying
Boost when this PR made it private, and the test compiles NuXLReport.cpp. It
would have failed in-tree as soon as develop's NuXL move met this branch.

Checked every translation unit outside the libraries that includes a Boost
header -- 43 of them -- and each now belongs to a target that links Boost.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

* Keep ZipRandomAccessFile.h out of the installed header set

The rebase onto develop turned configure red on every platform, which is why the
wheels failed alongside build-and-test:

  CMake Error at cmake/install_macros.cmake:109 (message):
    Installed header include/OpenMS/FORMAT/ZipRandomAccessFile.h includes a
    private dependency (#include <arrow/io/api.h>).

That is this PR's own guard catching a real leak rather than a false positive.
develop's #10239 added ZipRandomAccessFile.h to the installed header list, and
its Open() returns an arrow::Result<std::shared_ptr<arrow::io::RandomAccessFile>>,
so the header cannot compile without Arrow's development files. It joins
ParquetFile.h on OpenMS_private_headers for exactly the same reason.

Nothing loses access: no installed header includes it, and its consumers all
build against the build tree and already resolve Arrow themselves --
ZipRandomAccessFile_test links the Arrow and Parquet targets, and the
OpenSwathPercolatorScoring and OpenSwathWorkflow tool directories find Arrow in
their own CMakeLists.

Scanned all 910 installed headers for the private dependencies the guard covers;
this was the only one, so configure should get through in one go.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

* Install the private headers standalone tools include; fix IDMapper's scan regex

Three tool directories that can be built against an installed OpenMS include
headers this PR had made private, so their standalone builds failed on a missing
file even after 18935de gave them their own Boost lookup:

  OpenNuXL                    NuXLReport.cpp         -> ANALYSIS/ID/IDBoostGraph.h
  OpenSwathExport             ParquetExporter.cpp    -> FORMAT/ParquetFile.h
  OpenSwathPercolatorScoring  OSWParquetReader.cpp   -> FORMAT/ParquetFile.h,
                                                        FORMAT/ZipRandomAccessFile.h
  OpenSwathWorkflow           OSWParquetWriter.cpp   -> FORMAT/ParquetFile.h

An audit of every standalone tool directory against the real private header
lists found exactly these three headers and nothing else.

None of them can rejoin the exported HEADERS set: each names Boost.Graph or Arrow
types in its declarations, and that set is what the header-set verification and
the Boost-free consumer test compile with nothing but OpenMS' own usage
requirements. So they stay on OpenMS_private_headers and are additionally
installed with install(FILES) next to the public headers, in the OpenMS_headers
component, via a new OpenMS_installed_private_headers list. Configure fails if a
header on that list is not also private, so the list cannot quietly install a
public header twice. Each tool directory already finds and links Boost or Arrow
itself. No public header includes any of the three.

IDMapper: the TMT/iTRAQ path built its scan regex as RegularExpression{""} and
then tested empty() before deriving one with getRegExFromNativeID(). A compiled
empty pattern is not empty(), so the fallback never ran, extractScanNumber()
found no capture group, and mapping aborted with a ParseError whenever the IDs
carry bare integer scan numbers (e.g. Sage). develop had the same bug with
boost::regex{""}; this PR only rewrote the line. Declare it default-constructed,
and outside the per-feature loop so it is derived once, as the "all scan_ids are
of the same structure" comment intends. Checked against the real
RegularExpression class and the extractScanNumber logic: the old code throws on
"controllerType=0 controllerNumber=1 scan=42", the new one yields 42 and 43 for
two features and derives the regex once. No test relies on the throw.

CHANGELOG and ExternalCode.doxygen said ParquetFile.h was no longer installed;
they now describe the three installed-but-internal headers, and the doc's
configure-failure sentence says "public header", which is what the guard scans.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

* Give NuXLReport a Boost-free grouping API instead of installing IDBoostGraph.h

594b1e2 made OpenNuXL's standalone build work by installing IDBoostGraph.h next
to the public headers, outside the exported header set. That ships a
Boost.Graph header again and makes every consumer of it bring Boost. NuXLReport
only needs one thing from it: the indistinguishable protein groups of a run.

Add that as public API with OpenMS types only:

  static void BasicProteinInferenceAlgorithm::annotateIndistinguishableGroups(
      ProteinIdentification& proteins, const PeptideIdentificationList& peptides,
      Size use_top_psms = 1, bool add_singletons = true);

It is exactly what NuXLReport did by hand (build the graph over the run's top
hits, calculateAndAnnotateIndistProteins) and what run() already does under its
"annotate_indistinguishable_groups" parameter, so the class was the natural
home and IDBoostGraph stays an implementation detail of the .cpp. The peptides
are taken by const reference and copied inside, because the graph holds
non-const pointers into them; NuXLReport already made that same copy (with a
"TODO: why copy needed?").

NuXLReport calls it with (1, false), the same top-hit, no-singletons setting as
before, and no longer names Internal::IDBoostGraph. IDBoostGraph.h is private
and not installed again; OpenMS_installed_private_headers keeps only the two
Arrow headers the OpenSwath tool directories need.

Checked locally with syntax-only compiles against stubbed generated headers and
Boost 1.83 (each with a negative control that fails as expected):
- BasicProteinInferenceAlgorithm.cpp, and the class test with -Wall -Wshadow
  (no warning from the test file);
- all 12 OpenNuXL sources against a copy of the include tree with all 17 private
  headers deleted, i.e. what a standalone build sees. The previous NuXLReport.cpp
  fails that on the missing IDBoostGraph.h; the new one passes.

The class test covers the default (top hit, singletons), no singletons, all
hits, and the empty case that throws. Its data is built so that a
second-ranked hit and a hit from another run would each split the {P1, P2}
group if the use_top_psms limit or the run filter were not applied.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

* Clean up the review findings on the Boost-private change

Six cleanups from reviewing this PR, each checked locally with syntax-only or
object compiles against stubbed generated headers and Boost 1.83.

PipEcho includes what it uses. GridWithStorage.h no longer includes
QTClusterFinder.h just so that Impl.h/Impl.cpp get FeatureMap, ConsensusMap and
ConsensusFeature second-hand through BaseGroupFinder.h; Impl.h includes
ConsensusMap.h and FeatureMap.h itself. Found by removing the include and
compiling all seven PipEcho translation units until they passed again (the
two misses were exactly the ones that broke CI on b038fb8), then compiling each
of the ten PipEcho headers on its own.

EnzymaticDigestion holds a plain RegularExpression. The unique_ptr wrapper and
its "use PImpl, since #include cost is huge" comment date from boost::regex;
RegularExpression is a pimpl itself, so the second indirection bought nothing.
The copy operations become defaulted -- the hand-written ones copied exactly
the four data members the class has, and copying a RegularExpression shares
its compiled pattern as copying the wrapper did.

checkedCast instead of boost::numeric_cast in the 14 files where this PR had
added <boost/numeric/conversion/cast.hpp> only to keep numeric_cast working:
9 library sources and the MRMTransitionGroupPicker, OpenSwathAnalyzer,
OpenSwathChromatogramExtractor, OpenSwathFeatureXMLToTSV and
OpenSwathPeakMapExtractor tools. All 32 calls convert an integer (size() or an
index) to int or SignedSize, which checkedCast covers; nothing catches
boost::numeric::bad_numeric_cast. The five tools use no other Boost, so they
leave the Boost consumer list, and OpenSwathPeakMapExtractor's CMakeLists no
longer looks Boost up -- it is identical to develop again, which also keeps it
clear of #10247. Checked by compiling the five tools with every Boost header
replaced by an #error stub (the previous MRMTransitionGroupPicker.cpp fails
that on cast.hpp).

IDDataContainer::modify no longer takes a std::function. It is a template that
hands the caller's callable to an out-of-line modify_() as a function pointer
plus a pointer to the callable, so nothing is copied or allocated per call --
the allocation the performance review measured in addScore and friends. The
explicit instantiations export modify_ like the other members (WEAK DEFAULT in
the object file, as erase). The in-tree callers' functors do not mutate
themselves, so calling the original instead of a copy changes nothing for
them. Ran the real IDDataContainer.cpp, instantiated for a minimal record type,
against lambdas, a const callable, rvalue and lvalue functors, a std::function,
a stateful lambda, OrderedView::modify and a key collision; all pass, also
under ASan and UBSan.

Not changed, after checking:
- Moved-from pimpls. IDDataContainer's null impl_ is its empty state (the
  default constructor has it too), and erase/modify require an iterator into
  the container. Every SpectralDeconvolution access to the bitsets is reached
  through performSpectrumDeconvolution(), which recreates them first; that is
  now stated where it happens. RandomShuffler checks in both public entry
  points. Keeping a live Impl in moved-from objects would make the moves
  allocate and lose noexcept.
- The Boost-free consumer test's poison headers. Its own loop writes the 15,634
  files of a Boost 1.83 tree in 1.1 s, in a test that then compiles ~900
  headers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

* Stop installing ParquetFile.h and ZipRandomAccessFile.h

594b1e2 installed the two Arrow-typed internal headers next to the public ones,
outside the exported header set, because the OpenSwathExport,
OpenSwathPercolatorScoring and OpenSwathWorkflow tool directories included them
and can be built against an installed OpenMS. #10247, now merged, moved the
Arrow-based helpers those tools used back into libOpenMS, so no tool includes
either header any more -- the audit over all 14 standalone tool directories
against the private header lists comes back empty. The only remaining users
are libOpenMS itself and its class tests, which build against the source tree.

So the workaround goes: the OpenMS_installed_private_headers list, its
initialisation in includes.cmake, the install loop in src/openms/CMakeLists.txt
and the FORMAT/sources.cmake entries. includes.cmake is identical to develop
again. CHANGELOG and ExternalCode.doxygen now list ParquetFile.h and
ZipRandomAccessFile.h with RationalScan2ImConverter.h as no longer installed,
and drop the paragraph about installed-but-internal headers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

* Check installed headers against an include allowlist

openms_validate_public_headers() rejected includes of eight known private
dependencies (boost, arrow, parquet, xercesc, Eigen, SQLiteCpp, simde, opentims++)
plus nlohmann/json. A dependency added later slipped past it unless someone
remembered to extend the list, and even today it missed <sqlite3.h>.

It now accepts only what an installed header may rely on downstream:
OpenMS/..., the C++ standard library, operating-system headers (sys/...,
windows.h, winternl.h) and the public dependencies OpenMP (omp.h) and Crawdad
(CrawdadWrapper.h, WITH_CRAWDAD only). A library adds the headers of its own
PUBLIC dependencies with the new openms_add_library(... ALLOWED_PUBLIC_INCLUDES)
argument; the GUI layer allows Qt that way, so Qt stays out of the core headers.

All 929 installed headers of the core, CLI, OpenSwathAlgo, GUI and test-framework
layers pass, with WITH_ONNX, WITH_OPENTIMS, WITH_HDF5 and WITH_THERMO_RAW
headers included; the GUI headers fail without the Qt allowance. Every private
header that includes a third-party header is rejected, including
SqliteConnector_impl.h (<sqlite3.h>). The header-set test gets a second negative
case, a header that includes an unknown "newdep/api.h" next to allowed includes:
it fails with the old denylist and passes now, and only newdep/api.h is reported.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

* Address CodeRabbit's review of the include-allowlist push

IDDataContainer allocated its Impl on first insertion, and iterators remember
their owner. An end() saved from an empty container therefore stopped comparing
equal to end() after the first insert, and decrementing it dereferenced a null
owner (a harness around the real IDDataContainer.cpp crashed on exactly that).
Boost.MultiIndex keeps such iterators valid. The default and copy constructors
now allocate the Impl; only a moved-from container has none until insert().

IDMapper's TMT/iTRAQ fallback for bare scan numbers (e.g. Sage) runs since this
PR fixed its never-empty regex. For a WIFF native ID ("sample=1 period=1
cycle=96 experiment=1") the generic single-number regex takes the last number,
the experiment, so reference "1" could be attached to the wrong feature. WIFF
IDs now go through the accession-based extractScanNumber(), which returns
cycle * 1000 + experiment (96001), the convention OpenMS uses elsewhere. A new
IDMapper_test section covers Thermo and WIFF IDs against bare scan numbers.

annotateIndistinguishableGroups() appended to the run's existing groups, so a
repeated call duplicated them. The groups now replace the run's groups, which
are restored if grouping throws; the test checks both.

CHANGELOG: only the CMake package of a shared build is Boost-free; a static
build keeps Boost among its link dependencies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

* Document the RegularExpression constructors and accessors

CodeRabbit's first review asked for Doxygen on the public members of the new
class; only search() had any. The comments state what callers rely on and
what is easy to get wrong: a default-constructed expression is empty() and
matches like "", while a compiled "" is not empty(); an invalid pattern throws
a std::runtime_error (Boost's regex_error derives from it); and assign() does
not affect copies made earlier, which share the old compiled state.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

* Test that binomial_cdf_complement rejects a NaN probability

The positive range check that rejects NaN had no test: the section covered
only probabilities below 0 and above 1, which the old negated check caught as
well. CodeRabbit pointed out that the PR comment claiming a test was wrong.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

* Build IDDataContainer on std::set and give RandomShuffler a std engine

IDDataContainer wrapped a Boost.MultiIndex container with a single
ordered_unique index behind a pimpl, with its own out-of-line iterator
carrying an owner pointer. That doubled every *Ref handle to 16 bytes and
made each iterator step a call across the library boundary, the two costs
the performance review of #10223 singled out.

A std::set with a transparent comparator does the same job header-only:
the record's key members are template arguments, a composite key is a
std::tuple and a key prefix (the input file of an observation) compares
against the leading key members. Iterators are the set's: 8 bytes, inline.
modify() changes a record in place and checks that it still orders between
its neighbours; only a key change moves the record (its node, so references
stay valid), and a key that duplicates another record's erases the record
and returns false, as before. modify() therefore takes the position by
reference and leaves it on the record or, after a rejected duplicate, on the
next one. The two cleanup() loops that shrink group keys honour that return
value instead of dereferencing a possibly erased group.

The applied processing steps, the one collection that also keeps insertion
order, are an IDSequencedContainer: a std::vector with a linear uniqueness
check, a handful of records per result. getStepsAndScoresByStep() returns
its lookup view (find, end, modify); no caller iterated the step order.

RandomShuffler held boost::mt19937_64 behind a pimpl. std::mt19937_64 is the
same generator with the same seeding, and Boost's uniform_int, which keeps
the shuffle sequence platform-independent, accepts a standard engine, so the
engine is a plain member again and only the index draw stays in the .cpp.
The seed-42 golden sequence in MathFunctions_test checks that nothing moved.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

* Find Boost for a TOPP or GUI layer built against an installed OpenMS

OPENMS_USE_INSTALLED_LIBRARY (#10339) finds only what the applications
need themselves and leaves the libraries' public dependencies to
OpenMSConfig.cmake. Boost used to arrive that way; now that it is private
to libOpenMS, the installation no longer provides Boost::boost, and the
layer's configure failed on the TOPP tools that link it directly
(ApplicationLayer_configure: "Target Digestor links to Boost::boost but
the target was not found", likewise FeatureFinderMultiplex, FileInfo,
FileMerger, ...). The GUI library links it too. The layer finds the Boost
headers as the library build does.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NR333nLd3McuJgH9doFntg

---------

Co-authored-by: Claude <[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.

1 participant