Skip to content

Support wrapping of enum classes. Remove boost smart_ptr and bump up autowrap - #8405

Merged
timosachsenberg merged 12 commits into
developfrom
claude/finish-openms-pr-7860-01LmhYPcZ8NpWGru4zeX8Mbi
Nov 30, 2025
Merged

timosachsenberg merged 12 commits into
developfrom
claude/finish-openms-pr-7860-01LmhYPcZ8NpWGru4zeX8Mbi

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Nov 28, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes

    • More reliable import/export, display and reporting of activation methods (fixes indexing/type issues).
  • Refactor

    • Activation methods now use a type-safe, scoped representation for consistent handling across formats and tools.
    • Modernized internal pointer usage to standard C++ smart pointers for cleaner memory handling.
  • Tests

    • Unit tests updated to reflect scoped activation-method usage and validate correct I/O and display.

✏️ Tip: You can customize this high-level summary in your review settings.

This converts the ActivationMethod enum in the Precursor class from a
plain C++ enum to a scoped enum class for improved type safety:

- Prevents implicit conversion to integers
- Requires explicit member qualification (e.g., Precursor::ActivationMethod::CID)
- Fixes Cython compilation issues with pyOpenMS bindings

Changes made:
- Modified Precursor.h: enum -> enum class, array sizes use static_cast
- Modified Precursor.cpp: Added static_assert for array size validation,
  updated array indexing to use static_cast<size_t>()
- Updated Precursor.pxd for Cython: cdef enum -> cdef enum class
- Updated all usages across codebase (format handlers, analysis modules,
  TOPP tools, GUI components, tests) to use qualified enum syntax
- Added compile-time assertions to ensure array sizes match enum count
@coderabbitai

coderabbitai Bot commented Nov 28, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Convert Precursor::ActivationMethod to a scoped enum class, make activation-name arrays fixed-size with explicit casts and static_asserts, and update all call sites to use scoped qualifiers and size_t casts. Separately, migrate widespread boost::shared_ptr usages to std::shared_ptr (includes, typedefs, APIs, sources, bindings, and tests).

Changes

Cohort / File(s) Summary
Enum & Activation Name Arrays
src/openms/include/OpenMS/METADATA/Precursor.h, src/openms/source/METADATA/Precursor.cpp
Change ActivationMethod → enum class ActivationMethod; declare NamesOfActivationMethod/NamesOfActivationMethodShort with fixed size from ActivationMethod::SIZE_OF_ACTIVATIONMETHOD; add static_asserts; update all indexing to static_cast<size_t>(...).
I/O / Format Handlers
src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp, .../MzXMLHandler.cpp, .../MzMLSqliteHandler.cpp, src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp, src/openms/source/FORMAT/HANDLERS/CachedMzMLHandler.cpp, src/openms/source/FORMAT/IBSpectraFile.cpp, src/openms/include/OpenMS/FORMAT/HANDLERS/MzDataHandler.h, src/openms/include/OpenMS/FORMAT/HANDLERS/MzXMLHandler.h
Qualify activation-method uses to Precursor::ActivationMethod::X; update bounds checks to use scoped size; cast enum values for SQL/CV writing; index name arrays via static_cast<size_t>.
Analysis / Quantitation / TopDown
src/openms/include/OpenMS/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.h, src/openms/source/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.cpp, src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
Use scoped enum qualifiers and static_cast<size_t> when building activation-name strings and indexing arrays; adjust defaults/selection code to scoped enums.
Kernel / Utils / QC
src/openms/include/OpenMS/KERNEL/RangeUtils.h, src/openms/source/QC/Ms2SpectrumStats.cpp, src/openms/source/QC/MzCalibration.cpp, src/openms/include/OpenMS/CONCEPT/Helpers.h, src/openms/source/ANALYSIS/OPENSWATH/ChromatogramExtractorAlgorithm.cpp
Fix activation-name indexing with static_cast<size_t>; update Helpers::constifyPointerVector and related signatures to std::shared_ptr; add small header includes.
GUI, TOPP & Tools
src/openms_gui/source/VISUAL/VISUALIZER/PrecursorVisualizer.cpp, src/openms_gui/*, src/topp/FileFilter.cpp, src/topp/FileInfo.cpp, src/topp/*
Replace loop bounds and array accesses to use ActivationMethod::SIZE_OF_ACTIVATIONMETHOD (with casts); update call sites to scoped enum and/or modernized pointer usage.
Bindings / pyOpenMS
src/pyOpenMS/pxds/Precursor.pxd, src/pyOpenMS/pxds/ISpectrumAccess.pxd, src/pyOpenMS/pxds/*.pxd, src/pyOpenMS/addons/SwathMap.pyx, src/pyOpenMS/pxds/smart_ptr.pxd, src/pyOpenMS/create_cpp_extension.py
Expose ActivationMethod as cdef enum class ...; switch Cython externs/typedefs from Boost → std::shared_ptr; adjust smart_ptr.pxd (remove unique(), use_count() → long); drop include_boost in codegen.
Boost → std Modernization (API & internals)
many headers/sources (examples) src/openms/include/OpenMS/INTERFACES/DataStructures.h, src/openms/include/OpenMS/INTERFACES/ISpectrumAccess.h, src/openms/include/OpenMS/ANALYSIS/OPENSWATH/DATAACCESS/*.h, src/openms/source/ANALYSIS/OPENSWATH/DATAACCESS/*.cpp, src/openswathalgo/include/..., src/openms_gui/include/OpenMS/VISUAL/LayerDataBase.h, src/openms/source/*, src/topp/*, tests under src/tests/*
Replace boost::shared_ptr / boost::make_shared / boost::static_pointer_cast with std::shared_ptr / std::make_shared / std::static_pointer_cast; update includes to <memory>; update public typedefs and method signatures accordingly.
Tests
src/tests/class_tests/openms/source/*.cpp (many)
Update tests to use Precursor::ActivationMethod::X and convert Boost smart-pointer usages to std::shared_ptr; update START_SECTION declarations and expectations referencing unscoped enums.
Examples & Misc small fixes
doc/code_examples/Tutorial_GUI_Plot1D.cpp, assorted files
Replace boost::make_shared with std::make_shared; add missing <algorithm> includes where required.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • Areas needing extra attention:
    • src/openms/include/OpenMS/METADATA/Precursor.h and src/openms/source/METADATA/Precursor.cpp — verify enum values, SIZE_OF_ACTIVATIONMETHOD, array contents and static_asserts.
    • src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp — large, repetitive changes; confirm read/write symmetry and CVParam emission preserved.
    • Public API changes from boost::shared_ptr → std::shared_ptr across headers/bindings — review ABI/binding impacts and downstream consumers.

Possibly related PRs

Suggested labels

enhancement, Review effort [1-5]: 3

Suggested reviewers

  • jpfeuffer
  • poshul

Poem

🐇 I hopped through enums, small and neat,
Scoped every method and cast each seat.
Static asserts guard my carrot stash,
Shared pointers swapped in a tidy dash.
A little hop — the code now runs fast!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.66% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: supporting enum class wrapping, removing Boost smart pointers, and updating autowrap dependency.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/finish-openms-pr-7860-01LmhYPcZ8NpWGru4zeX8Mbi

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a88014 and 13f916d.

📒 Files selected for processing (2)
  • src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFinderScoring.cpp (2 hunks)
  • src/openms/source/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimatorMedianRapid.cpp (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/openms/**/*.{cpp,h,hpp,cc,cxx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms

Files:

  • src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFinderScoring.cpp
  • src/openms/source/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimatorMedianRapid.cpp
🧠 Learnings (7)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)

Applied to files:

  • src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFinderScoring.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms

Applied to files:

  • src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFinderScoring.cpp
  • src/openms/source/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimatorMedianRapid.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets

Applied to files:

  • src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFinderScoring.cpp
  • src/openms/source/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimatorMedianRapid.cpp
📚 Learning: 2025-08-14T10:19:54.371Z
Learnt from: jpfeuffer
Repo: OpenMS/OpenMS PR: 8167
File: src/topp/Digestor.cpp:200-226
Timestamp: 2025-08-14T10:19:54.371Z
Learning: In OpenMS (C++ bioinformatics framework), use boost random libraries instead of std library random distributions for cross-platform reproducible random number generation, as std library distributions are not reproducible across platforms.

Applied to files:

  • src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFinderScoring.cpp
  • src/openms/source/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimatorMedianRapid.cpp
📚 Learning: 2025-10-21T13:02:16.431Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8318
File: src/openms/include/OpenMS/ML/CLUSTERING/HashGrid.h:466-480
Timestamp: 2025-10-21T13:02:16.431Z
Learning: In OpenMS, when making internal methods public (e.g., in HashGrid.h), remove XXX/TODO comments about implementation details rather than documenting them in the public API documentation.

Applied to files:

  • src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFinderScoring.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Consider algorithmic complexity for data processing operations

Applied to files:

  • src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFinderScoring.cpp
  • src/openms/source/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimatorMedianRapid.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes

Applied to files:

  • src/openms/source/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimatorMedianRapid.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: build-lnx
  • GitHub Check: build-win
  • GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
  • GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
  • GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
  • GitHub Check: cppcheck-test
🔇 Additional comments (3)
src/openms/source/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimatorMedianRapid.cpp (1)

11-11: Adding <algorithm> is correct and necessary

This header is the proper home for std::lower_bound, std::advance, and std::nth_element used later in this file, so making the dependency explicit improves build robustness and clarity without changing behavior.

src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFinderScoring.cpp (2)

25-25: LGTM! Correct header for standard library smart pointers.

The <memory> header is properly included to support the std::shared_ptr and std::make_shared usage on lines 160-161, replacing the previous Boost smart pointer dependencies.


160-161: LGTM! Proper migration to standard library smart pointers.

The migration from boost::shared_ptr and boost::make_shared to their standard library equivalents is correctly implemented. The usage of std::make_shared follows modern C++ best practices for efficient memory allocation.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
src/openms_gui/source/VISUAL/VISUALIZER/PrecursorVisualizer.cpp (1)

54-77: Fix enum‑class loop bounds to restore compilation

enum class Precursor::ActivationMethod no longer implicitly converts to an integer, so conditions like

for (Size i = 0; i < Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD; ++i)

are ill‑formed and will fail to compile. The same applies in store().

Convert the enum size to an integral once and cast indices back to ActivationMethod where needed. For example:

-    activation_methods_->clear();
-    for (Size i = 0; i < Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD; ++i)
+    activation_methods_->clear();
+    const auto am_count = static_cast<Size>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD);
+    for (Size i = 0; i < am_count; ++i)
     {
       QListWidgetItem * item = new QListWidgetItem(activation_methods_);
-      item->setText(QString::fromStdString(Precursor::NamesOfActivationMethod[static_cast<size_t>(i)]));
-      if (temp_.getActivationMethods().count(Precursor::ActivationMethod(i)) == 1)
+      const auto am = static_cast<Precursor::ActivationMethod>(i);
+      item->setText(QString::fromStdString(Precursor::NamesOfActivationMethod[static_cast<size_t>(am)]));
+      if (temp_.getActivationMethods().count(am) == 1)
       {
         item->setCheckState(Qt::Checked);
       }

and in store():

-    ptr_->getActivationMethods().clear();
-    for (UInt i = 0; i < Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD; ++i)
+    ptr_->getActivationMethods().clear();
+    const auto am_count = static_cast<UInt>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD);
+    for (UInt i = 0; i < am_count; ++i)
     {
       if (activation_methods_->item(i)->checkState() == Qt::Checked)
       {
-        ptr_->getActivationMethods().insert(Precursor::ActivationMethod(i));
+        ptr_->getActivationMethods().insert(static_cast<Precursor::ActivationMethod>(i));
       }
     }

This keeps behavior identical while making the enum‑class usage valid.

Also applies to: 91-98

src/topp/FileFilter.cpp (1)

439-452: Repair ActivationMethod loops to avoid enum‑class/integer comparison errors

The spectra:*_activation handling now uses enum class Precursor::ActivationMethod, but the loops still compare an integer index to the enum:

for (Size i = 0; i < Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD; ++i)

This is ill‑formed with an enum class and will not compile. The logic only needs the numeric range for indexing NamesOfActivationMethod, so casting the enum size once is sufficient. For example:

-    setValidStrings_("spectra:remove_activation", Precursor::NamesOfActivationMethod, (int)Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD);
+    setValidStrings_("spectra:remove_activation",
+                     Precursor::NamesOfActivationMethod,
+                     static_cast<int>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD));
...
-      for (Size i = 0; i < Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD; ++i)
+      const auto am_count = static_cast<Size>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD);
+      for (Size i = 0; i < am_count; ++i)
       {
         if (Precursor::NamesOfActivationMethod[static_cast<size_t>(i)] == remove_activation)
         {
           exp.getSpectra().erase(remove_if(exp.begin(), exp.end(),
                                            HasActivationMethod<MapType::SpectrumType>(ListUtils::create<String>(remove_activation))),
                                  exp.end());
         }
       }
...
-      for (Size i = 0; i < Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD; ++i)
+      const auto am_count = static_cast<Size>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD);
+      for (Size i = 0; i < am_count; ++i)
       {
         if (Precursor::NamesOfActivationMethod[static_cast<size_t>(i)] == select_activation)
         {
           exp.getSpectra().erase(remove_if(exp.begin(), exp.end(),
                                            HasActivationMethod<MapType::SpectrumType>(ListUtils::create<String>(select_activation), true)),
                                  exp.end());
         }
       }

This preserves existing behavior while making the enum‑class usage compile correctly.

Also applies to: 911-933

src/openms/source/FORMAT/HANDLERS/MzXMLHandler.cpp (2)

225-235: Fix enum‑class usage in activation parsing (pointer arithmetic)

The std::find range and end iterator currently use Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD directly in pointer arithmetic:

auto it = std::find(Precursor::NamesOfActivationMethodShort,
                    Precursor::NamesOfActivationMethodShort + Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD,
                    activation);
if (it != Precursor::NamesOfActivationMethodShort + Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD)
{
  spectrum_data_.back().spectrum.getPrecursors().back().getActivationMethods()
    .insert(Precursor::ActivationMethod(it - Precursor::NamesOfActivationMethodShort));
}

With ActivationMethod now an enum class, adding it to a pointer is ill‑formed. Also, the conversion from pointer difference to ActivationMethod should be explicit. A minimal, type‑safe fix:

-          auto it = std::find(Precursor::NamesOfActivationMethodShort, 
-                              Precursor::NamesOfActivationMethodShort + Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD, 
-                              activation);
-
-          if (it != Precursor::NamesOfActivationMethodShort + Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD)
-          {
-            spectrum_data_.back().spectrum.getPrecursors().back().getActivationMethods().insert(Precursor::ActivationMethod(it - Precursor::NamesOfActivationMethodShort));
-          }
+          const auto am_count = static_cast<std::size_t>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD);
+          auto it = std::find(Precursor::NamesOfActivationMethodShort,
+                              Precursor::NamesOfActivationMethodShort + am_count,
+                              activation);
+          if (it != Precursor::NamesOfActivationMethodShort + am_count)
+          {
+            const auto idx = static_cast<std::size_t>(it - Precursor::NamesOfActivationMethodShort);
+            spectrum_data_.back().spectrum.getPrecursors().back().getActivationMethods()
+              .insert(static_cast<Precursor::ActivationMethod>(idx));
+          }

This keeps the mapping logic but makes the enum‑class conversions explicit and valid.


1008-1020: Repair activationMethod attribute indexing (parentheses and enum casts)

The activationMethod attribute writeout currently has two problems:

  • Syntactically, the static_cast<size_t> calls are missing closing parentheses.
  • Semantically, we should cast the ActivationMethod enum directly, without an intermediate int, and also cast the CID fallback.

Current code (simplified):

if (!precursor.getActivationMethods().empty())
{
  os << " activationMethod=\""
-     << Precursor::NamesOfActivationMethodShort[static_cast<size_t>(int(*(precursor.getActivationMethods().begin()))]
      << "\" ";
}
...
-  os << " activationMethod=\"" << Precursor::NamesOfActivationMethodShort[static_cast<size_t>(Precursor::ActivationMethod::CID] << "\" ";

Corrected version:

          if (!precursor.getActivationMethods().empty())
          { // must not be empty, but technically only ETD, ECD, CID are allowed in mzXML 3.1
-            os << " activationMethod=\"" << Precursor::NamesOfActivationMethodShort[static_cast<size_t>(int(*(precursor.getActivationMethods().begin()))] << "\" ";
+            const auto am = *precursor.getActivationMethods().begin();
+            os << " activationMethod=\""
+               << Precursor::NamesOfActivationMethodShort[static_cast<std::size_t>(am)]
+               << "\" ";
          } 
          else if (options_.getForceMQCompatability())
          { // a missing activation would make old MQ versions crash...
            OPENMS_LOG_WARN << "Warning: An MS2 scan does not have data on it's activation method. Using 'CID' as fallback!\n";
-            os << " activationMethod=\"" << Precursor::NamesOfActivationMethodShort[static_cast<size_t>(Precursor::ActivationMethod::CID] << "\" ";
+            os << " activationMethod=\""
+               << Precursor::NamesOfActivationMethodShort[static_cast<std::size_t>(Precursor::ActivationMethod::CID)]
+               << "\" ";
          }

This compiles cleanly under the enum‑class change and preserves the intended behavior (first activation method name, CID fallback for MQ compatibility).

🧹 Nitpick comments (2)
src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp (1)

1747-1871: Scoped ActivationMethod usage in activation CV parsing looks consistent

All activation CV accessions under <activation> are now mapped to the corresponding Precursor::ActivationMethod::<NAME> entries for both spectra and chromatograms, without changing the surrounding logic. The mapping table (CID/PD/PSD/SID/BIRD/ECD/IMD/SORI/HCID/LCID/PHD/ETD/ETciD/EThcD/PQD/TRAP/HCD/INSOURCE/LIFT) matches the enum names and is symmetric with the writer below, so behavior should be unchanged while gaining type safety.

You could later consider factoring the duplicated accession→enum mapping for spectra and chromatograms into a small helper to avoid divergence in future edits, but this is optional and outside this PR’s main scope.

Also applies to: 1913-1993

src/openms/source/METADATA/Precursor.cpp (1)

115-157: Indexing and iteration over activation methods correctly adapted to scoped enum

The accessors now index via static_cast<size_t>(m) where m is ActivationMethod, and the “all names” helpers reserve/iterate up to static_cast<size_t>(ActivationMethod::SIZE_OF_ACTIVATIONMETHOD). This is the right way to use the scoped enum as an array index and pairs cleanly with the size-based static_asserts above.

If you ever want to decouple the loops from the sentinel, you could use std::size(NamesOfActivationMethod)/std::size(NamesOfActivationMethodShort) in the for‑conditions, but that’s optional given the existing static_asserts.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d9b08e5 and 34e3a01.

📒 Files selected for processing (19)
  • src/openms/include/OpenMS/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.h (1 hunks)
  • src/openms/include/OpenMS/KERNEL/RangeUtils.h (1 hunks)
  • src/openms/include/OpenMS/METADATA/Precursor.h (3 hunks)
  • src/openms/source/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.cpp (2 hunks)
  • src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp (1 hunks)
  • src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp (1 hunks)
  • src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp (3 hunks)
  • src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp (2 hunks)
  • src/openms/source/FORMAT/HANDLERS/MzXMLHandler.cpp (1 hunks)
  • src/openms/source/METADATA/Precursor.cpp (6 hunks)
  • src/openms/source/QC/Ms2SpectrumStats.cpp (1 hunks)
  • src/openms_gui/source/VISUAL/VISUALIZER/PrecursorVisualizer.cpp (2 hunks)
  • src/pyOpenMS/pxds/Precursor.pxd (1 hunks)
  • src/tests/class_tests/openms/source/MzDataFile_test.cpp (1 hunks)
  • src/tests/class_tests/openms/source/MzMLFile_test.cpp (2 hunks)
  • src/tests/class_tests/openms/source/Precursor_test.cpp (9 hunks)
  • src/tests/class_tests/openms/source/RangeUtils_test.cpp (4 hunks)
  • src/topp/FileFilter.cpp (4 hunks)
  • src/topp/FileInfo.cpp (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/openms/**/*.{cpp,h,hpp,cc,cxx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms

Files:

  • src/openms/include/OpenMS/KERNEL/RangeUtils.h
  • src/openms/include/OpenMS/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.h
  • src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp
  • src/openms/source/QC/Ms2SpectrumStats.cpp
  • src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp
  • src/openms/include/OpenMS/METADATA/Precursor.h
  • src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp
  • src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp
  • src/openms/source/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.cpp
  • src/openms/source/FORMAT/HANDLERS/MzXMLHandler.cpp
  • src/openms/source/METADATA/Precursor.cpp
src/openms/include/OpenMS/**/*.h

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Add Doxygen comments for new public methods and classes

Files:

  • src/openms/include/OpenMS/KERNEL/RangeUtils.h
  • src/openms/include/OpenMS/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.h
  • src/openms/include/OpenMS/METADATA/Precursor.h
src/tests/class_tests/openms/**/*.cpp

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Write unit tests for new functionality

Files:

  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
  • src/tests/class_tests/openms/source/MzDataFile_test.cpp
  • src/tests/class_tests/openms/source/Precursor_test.cpp
  • src/tests/class_tests/openms/source/RangeUtils_test.cpp
🧠 Learnings (8)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms

Applied to files:

  • src/openms/include/OpenMS/KERNEL/RangeUtils.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)

Applied to files:

  • src/openms/source/QC/Ms2SpectrumStats.cpp
  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
  • src/tests/class_tests/openms/source/MzDataFile_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/pyOpenMS/**/*.h : Add Doxygen comments for new public methods and classes in pyOpenMS bindings

Applied to files:

  • src/pyOpenMS/pxds/Precursor.pxd
📚 Learning: 2025-06-16T15:48:09.667Z
Learnt from: FreezB11
Repo: OpenMS/OpenMS PR: 7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:4-4
Timestamp: 2025-06-16T15:48:09.667Z
Learning: In OpenMS .pxd files, the established pattern for extern from statements is to include angle brackets inside the string literal, like `cdef extern from "<OpenMS/PATH/TO/FILE.h>" namespace "OpenMS":`. This is consistent across all existing quantitation method .pxd files and other .pxd files in the OpenMS codebase.

Applied to files:

  • src/pyOpenMS/pxds/Precursor.pxd
📚 Learning: 2025-06-16T15:49:26.504Z
Learnt from: FreezB11
Repo: OpenMS/OpenMS PR: 7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:1-3
Timestamp: 2025-06-16T15:49:26.504Z
Learning: In OpenMS Python bindings (.pxd files), derived quantitation method classes like TMTThirtyTwoPlexQuantitationMethod only need to declare their constructors. All other public methods (getName, getChannelInformation, getNumberOfChannels, getIsotopeCorrectionMatrix, getReferenceChannel) are inherited from the base IsobaricQuantitationMethod class and don't need to be redeclared explicitly.

Applied to files:

  • src/pyOpenMS/pxds/Precursor.pxd
  • src/openms/source/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality

Applied to files:

  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
  • src/tests/class_tests/openms/source/MzDataFile_test.cpp
  • src/tests/class_tests/openms/source/Precursor_test.cpp
  • src/tests/class_tests/openms/source/RangeUtils_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/*Test.cpp : Follow naming convention: `ClassNameTest.cpp` for `ClassName`

Applied to files:

  • src/tests/class_tests/openms/source/MzMLFile_test.cpp
  • src/tests/class_tests/openms/source/MzDataFile_test.cpp
  • src/tests/class_tests/openms/source/Precursor_test.cpp
  • src/tests/class_tests/openms/source/RangeUtils_test.cpp
📚 Learning: 2025-09-03T12:58:20.032Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8177
File: src/tests/topp/CMakeLists.txt:1857-1865
Timestamp: 2025-09-03T12:58:20.032Z
Learning: OpenMS tests: When adding new TOPP tests in src/tests/topp/CMakeLists.txt that compare outputs via FuzzyDiff, always add set_tests_properties("<tool>_<n>_out<m>" PROPERTIES DEPENDS "<tool>_<n>") to avoid flakiness under parallel CTest runs.

Applied to files:

  • src/tests/class_tests/openms/source/MzDataFile_test.cpp
🧬 Code graph analysis (3)
src/openms/include/OpenMS/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.h (1)
src/openms/source/METADATA/Precursor.cpp (1)
  • Precursor (68-82)
src/tests/class_tests/openms/source/Precursor_test.cpp (2)
src/openms/source/METADATA/Precursor.cpp (3)
  • Precursor (68-82)
  • getAllShortNamesOfActivationMethods (148-157)
  • getAllShortNamesOfActivationMethods (148-148)
src/openms/include/OpenMS/METADATA/Precursor.h (1)
  • set (96-209)
src/openms/source/FORMAT/HANDLERS/MzXMLHandler.cpp (1)
src/topp/FileInfo.cpp (4)
  • os (128-138)
  • os (128-128)
  • os (637-2187)
  • os (637-637)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: build-and-test (ubuntu-22.04-arm, g++, 11)
  • GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
  • GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
  • GitHub Check: build-win
  • GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
  • GitHub Check: build-lnx
  • GitHub Check: build-lnx-arm
🔇 Additional comments (31)
src/openms/source/ANALYSIS/TOPDOWN/FLASHDeconvAlgorithm.cpp (1)

1561-1564: LGTM!

The scoped enum syntax Precursor::ActivationMethod::HCID and Precursor::ActivationMethod::HCD is correctly applied, aligning with the project-wide migration to enum class.

src/openms/include/OpenMS/KERNEL/RangeUtils.h (1)

328-335: LGTM!

The static_cast<size_t>(am) is correctly applied for array indexing, which is required since scoped enum classes don't implicitly convert to integers.

src/openms/include/OpenMS/METADATA/Precursor.h (1)

58-83: LGTM!

The conversion from unscoped enum to enum class ActivationMethod is correctly implemented:

  • Scoped enum prevents implicit integer conversion, improving type safety.
  • Array size declarations correctly use static_cast<size_t>(ActivationMethod::SIZE_OF_ACTIVATIONMETHOD).
  • Existing Doxygen comments for individual values are preserved.
src/tests/class_tests/openms/source/RangeUtils_test.cpp (4)

263-265: LGTM!

The scoped enum syntax Precursor::ActivationMethod::PSD and Precursor::ActivationMethod::BIRD is correctly applied for inserting activation methods into the set.


274-276: LGTM!

Correctly updated to use scoped enum Precursor::ActivationMethod::BIRD.


285-287: LGTM!

Correctly updated to use scoped enum Precursor::ActivationMethod::LCID.


295-297: LGTM!

Correctly updated to use scoped enum Precursor::ActivationMethod::PD.

src/topp/FileInfo.cpp (1)

1436-1441: ActivationMethod indexing changes are correct and type-safe

Using static_cast<size_t> to index NamesOfActivationMethodShort / NamesOfActivationMethod from Precursor::ActivationMethod values is exactly what’s needed after converting to enum class. No behavior change, and array bounds are still tied to the enum size elsewhere.

Also applies to: 1592-1595

src/openms/source/QC/Ms2SpectrumStats.cpp (1)

64-67: Safe cast for ActivationMethod meta value

The added static_cast<size_t> when indexing NamesOfActivationMethodShort from the first activation method fixes the enum-class typing without changing behavior; emptiness is checked beforehand, so no additional edge cases are introduced.

src/tests/class_tests/openms/source/MzDataFile_test.cpp (1)

144-157: Test enum qualification aligned with scoped ActivationMethod

Switching to Precursor::ActivationMethod::CID / SID matches the new enum class and keeps the test semantics identical.

src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp (1)

328-333: Guarded ActivationMethod-to-index conversion looks good

The < SIZE_OF_ACTIVATIONMETHOD check plus static_cast<size_t>(dspec.getActivationMethod()) produces a safe index into NamesOfActivationMethodShort under the new scoped enum.

src/openms/source/ANALYSIS/QUANTITATION/IsobaricChannelExtractor.cpp (2)

118-118: LGTM!

The activation list size calculation correctly uses the scoped enum Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD for the array bounds.


430-430: LGTM!

The indexing into NamesOfActivationMethod correctly uses static_cast<size_t>() with the scoped enum values Precursor::ActivationMethod::HCID and Precursor::ActivationMethod::HCD, consistent with the enum class refactor pattern used elsewhere in the PR.

src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp (2)

663-667: LGTM!

The bounds check correctly uses Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD with static_cast<int>() for comparison against the SQLite integer column value. The subsequent cast to OpenMS::Precursor::ActivationMethod on line 666 properly converts back to the scoped enum type for insertion.


806-810: LGTM!

Consistent with the chromatogram handling above, the spectrum precursor bounds check correctly uses the scoped enum Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD with appropriate casting.

src/pyOpenMS/pxds/Precursor.pxd (1)

64-108: LGTM!

The Cython declaration correctly transitions from cdef enum to cdef enum class with the explicit C++ namespace string "OpenMS::Precursor::ActivationMethod". This properly exposes the scoped enum class to the Python bindings and aligns with the C++ header changes.

src/tests/class_tests/openms/source/Precursor_test.cpp (11)

75-77: LGTM!

Test correctly uses the scoped enum Precursor::ActivationMethod::CID.


81-85: LGTM!

The set declaration uses set<Precursor::ActivationMethod> and insertion uses the scoped enum value correctly.


89-95: LGTM!

Consistent scoped enum usage in getActivationMethodsAsString test.


99-105: LGTM!

Consistent scoped enum usage in getActivationMethodsAsShortString test.


107-115: LGTM!

Both static method tests correctly compare the result size against static_cast<size_t>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD), which is the proper way to convert the scoped enum sentinel to a size type.


190-218: LGTM!

Copy constructor test correctly uses scoped enum Precursor::ActivationMethod::CID.


220-255: LGTM!

Move constructor test correctly uses both Precursor::ActivationMethod::CID and Precursor::ActivationMethod::BIRD scoped enum values.


257-301: LGTM!

Copy assignment operator test correctly uses scoped enum.


303-339: LGTM!

Move assignment operator test correctly uses scoped enum values.


356-360: LGTM!

Equality operator test correctly uses scoped enum.


405-409: LGTM!

Inequality operator test correctly uses scoped enum.

src/tests/class_tests/openms/source/MzMLFile_test.cpp (2)

449-452: LGTM!

Test assertions correctly use scoped enum syntax Precursor::ActivationMethod::CID and Precursor::ActivationMethod::PD for verifying activation methods loaded from the mzML file.


464-466: LGTM!

Test assertion correctly uses Precursor::ActivationMethod::ETD scoped enum value.

src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp (1)

3866-3955: Activation method serialization correctly updated to scoped enum

The checks in writePrecursor_ now use precursor.getActivationMethods().count(Precursor::ActivationMethod::<NAME>) for all supported methods, and the emitted PSI-MS accessions/names still match the read-side mappings (including ETciD/EThcD, HCID/LCID, INSOURCE, LIFT, etc.). Indexing and logic are unchanged apart from the scoped enum qualification, so this preserves mzML I/O behavior while aligning with the new enum class.

src/openms/source/METADATA/Precursor.cpp (1)

16-66: Array sizing and compile-time checks for ActivationMethod look sound

Declaring NamesOfActivationMethod and NamesOfActivationMethodShort with size static_cast<size_t>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD) and adding the two static_asserts gives a robust guarantee that the arrays stay in sync with the enum’s sentinel size. The use of static_cast<size_t> on the scoped enum in these constant expressions is correct and keeps the mapping safe under the new enum class.

timosachsenberg and others added 2 commits November 28, 2025 22:18
…lExtractor.h

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Add explicit static_cast for ActivationMethod enum class:
- MzDataHandler.cpp: Cast to UInt for writeCVS_ call
- MzMLSqliteHandler.cpp: Cast to int when storing activation_method

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp (1)

663-667: Tighten lower-bound validation for activation_method integers

The new static_cast<int>(OpenMS::Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD) usage is correct for an enum class, but the check still allows any value < SIZE_OF_ACTIVATIONMETHOD and != -1. Corrupted data with values < -1 would still pass and be cast to an invalid ActivationMethod value.

Consider tightening both conditions to explicitly enforce a non‑negative range:

-        if (sqlite3_column_type(stmt, 12) != SQLITE_NULL && sqlite3_column_int(stmt, 12) != -1
-            && sqlite3_column_int(stmt, 12) < static_cast<int>(OpenMS::Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD))
+        if (sqlite3_column_type(stmt, 12) != SQLITE_NULL)
+        {
+          const int activation = sqlite3_column_int(stmt, 12);
+          if (activation >= 0 &&
+              activation < static_cast<int>(OpenMS::Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD))
+          {
+            precursor.getActivationMethods().insert(
+              static_cast<OpenMS::Precursor::ActivationMethod>(activation));
+          }
+        }

and analogously for the spectrum case at column 15.

This keeps semantics for -1 (treated as “no activation”), while rejecting other negative garbage values instead of casting them into the enum.

Also applies to: 806-810

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6981327 and 09f97f4.

📒 Files selected for processing (2)
  • src/openms/source/FORMAT/HANDLERS/MzDataHandler.cpp (1 hunks)
  • src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/openms/**/*.{cpp,h,hpp,cc,cxx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms

Files:

  • src/openms/source/FORMAT/HANDLERS/MzDataHandler.cpp
  • src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: build-lnx-arm
  • GitHub Check: build-lnx
  • GitHub Check: build-win
  • GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
  • GitHub Check: build-and-test (ubuntu-22.04-arm, g++, 11)
  • GitHub Check: build-and-test (macos-26, xcode, 26.0)
  • GitHub Check: cppcheck-test
🔇 Additional comments (3)
src/openms/source/FORMAT/HANDLERS/MzDataHandler.cpp (1)

978-978: LGTM! Explicit cast correctly handles enum class conversion.

The static_cast<UInt> is necessary because enum class values don't implicitly convert to integers. The cast target matches the writeCVS_ function signature, and bounds checking is handled within writeCVS_ at lines 1459-1463.

src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp (2)

1117-1123: Enum-class → int cast for precursor activation method is correct

The change to

activation_method = static_cast<int>(*prec.getActivationMethods().begin());

is the right way to persist the enum class ActivationMethod as an integer, and it preserves the previous behavior of storing the first (only) activation method when present.


1330-1334: Enum-class → int cast for chromatogram activation method is correct

Same as in the spectra path, the explicit

activation_method = static_cast<int>(*prec.getActivationMethods().begin());

is appropriate for enum class ActivationMethod and keeps the existing semantics of writing a single activation method code into the database.

claude and others added 5 commits November 28, 2025 21:44
- Add static_cast<size_t>() for pointer arithmetic with SIZE_OF_ACTIVATIONMETHOD
- Fix missing closing parentheses in static_cast expressions for array indexing
- PrecursorVisualizer.cpp: Add static_cast for loop comparisons with SIZE_OF_ACTIVATIONMETHOD
- FileFilter.cpp: Add static_cast for loop comparisons with SIZE_OF_ACTIVATIONMETHOD
- FLASHDeconvSpectrumFile.cpp: Add static_cast for enum comparison

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/openms_gui/source/VISUAL/VISUALIZER/PrecursorVisualizer.cpp (2)

56-77: Scoped enum loop bound is correct; consider explicit enum casts and simplifying QListWidgetItem usage

The new loop bound using static_cast<Size>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD) is consistent with the enum class change and looks correct.

Two small, non-blocking cleanups you may want to do while touching this code:

  • Make the conversion from the loop index to the scoped enum explicit and idiomatic, e.g.:
for (Size i = 0; i < static_cast<Size>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD); ++i)
{
  const auto method = static_cast<Precursor::ActivationMethod>(i);
  QListWidgetItem* item = new QListWidgetItem(activation_methods_);
  item->setText(QString::fromStdString(Precursor::NamesOfActivationMethod[i]));
  if (temp_.getActivationMethods().count(method) == 1)
  {
    // ...
  }
  // ...
}
  • With QListWidgetItem(activation_methods_), the item is already inserted into the list; activation_methods_->addItem(item); is redundant and can be dropped to avoid double-insertion confusion:
-      QListWidgetItem * item = new QListWidgetItem(activation_methods_);
+      QListWidgetItem * item = new QListWidgetItem(activation_methods_);
       // ...
-      activation_methods_->addItem(item);

These are style/clarity improvements only; existing behavior remains the same with your loop-bound change.


92-98: Loop bound cast in store() is fine; optionally align index type and enum cast with update_()

The new bound static_cast<UInt>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD) is correct and matches the enum-class-based size.

For consistency and readability, you might:

  • Use the same index type as in update_() (e.g. Size) unless there is a specific reason to prefer UInt here.
  • Mirror the explicit scoped-enum cast as suggested above:
for (Size i = 0; i < static_cast<Size>(Precursor::ActivationMethod::SIZE_OF_ACTIVATIONMETHOD); ++i)
{
  if (activation_methods_->item(static_cast<int>(i))->checkState() == Qt::Checked)
  {
    ptr_->getActivationMethods().insert(static_cast<Precursor::ActivationMethod>(i));
  }
}

This keeps the enum usage explicit and consistent across update_() and store(), and makes the intent around scoped-enum conversions clearer.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 745054a and 37a8737.

📒 Files selected for processing (3)
  • src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp (1 hunks)
  • src/openms_gui/source/VISUAL/VISUALIZER/PrecursorVisualizer.cpp (2 hunks)
  • src/topp/FileFilter.cpp (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/topp/FileFilter.cpp
🧰 Additional context used
📓 Path-based instructions (1)
src/openms/**/*.{cpp,h,hpp,cc,cxx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms

Files:

  • src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp
🧠 Learnings (3)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets

Applied to files:

  • src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Consider algorithmic complexity for data processing operations

Applied to files:

  • src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality

Applied to files:

  • src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: build-and-test (macos-26, xcode, 26.0)
  • GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
  • GitHub Check: build-and-test (ubuntu-22.04-arm, g++, 11)
  • GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
  • GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
  • GitHub Check: build-and-test (macos-15-intel, xcode, 16.0.0)
  • GitHub Check: build-lnx-arm
  • GitHub Check: build-macos-arm
  • GitHub Check: build-lnx
  • GitHub Check: build-macos
  • GitHub Check: build-win
  • GitHub Check: cppcheck-test
🔇 Additional comments (1)
src/openms/source/FORMAT/FLASHDeconvSpectrumFile.cpp (1)

330-333: Scoped enum handling and bounds check for activation method look good

Casting the scoped ActivationMethod to size_t for both the < SIZE_OF_ACTIVATIONMETHOD guard and the array index is correct and consistent with the new enum class semantics, and the check prevents any out-of-range access to NamesOfActivationMethodShort. No further changes needed here.

@timosachsenberg timosachsenberg changed the title Convert Precursor::ActivationMethod to enum class Support wrapping of enum classes. Remove boost smart_ptr and bump up autowrap Nov 29, 2025

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (5)
src/openms_gui/source/VISUAL/LayerDataChrom.cpp (1)

23-23: Remove unused Boost include.

After migrating to std::make_shared, this Boost header is no longer needed.

Apply this diff:

-#include <boost/make_shared.hpp>
src/openms_gui/source/VISUAL/APPLICATIONS/TOPPViewBase.cpp (1)

67-67: Remove unused boost/make_shared.hpp include at line 67.

The verification confirms this include is no longer needed. The file contains only this single Boost include, and there are no remaining usages of boost::make_shared or boost::shared_ptr in the code. After the migration to std::make_shared, this include should be removed.

src/topp/OpenSwathWorkflow.cpp (2)

459-522: Fix missing standard headers for new utilities

The new helpers and data structures in this file rely on standard library components that are not explicitly included here:

  • is_valid_win and apply_window use std::isfinite (Line 541), which formally requires <cmath>.
  • loadPriorityPeptideSequences and the priority_peptides set (Lines 620, 1005) use std::unordered_set, which requires <unordered_set>.

Compilation may currently succeed via transitive includes, but this is not guaranteed and can break when headers change. It’s safer for this TU to include the needed headers directly, e.g.:

 #include <cassert>
 #include <limits>
+
+#include <cmath>
+#include <unordered_set>

Also applies to: 541-607, 620-661, 770-805, 960-987, 1004-1051, 1110-1186, 1188-1317


459-522: Minor robustness & logging issues in auto window estimation

A few small points in the new auto-estimation logic:

  • parseEstimateExtractionWindows_ treats an empty string as “none” (all flags false), although the docstring says empty/malformed values should raise InvalidParameter. If you want strict behavior, consider an explicit if (s.empty()) throw ...; after trimming.
  • In the nonlinear calibration branch (Lines 1188+), the warning messages for MS2/MS1 m/z use calibration_result.ms2_mz_window_ppm / .ms1_mz_window_ppm even though the applied estimates come from estimated_mz_extraction_window / estimated_ms1_mz_extraction_window returned by OpenSwathCalibrationWorkflow. This makes the log slightly misleading; using the estimated_* variables in the message would better reflect what was actually computed in the nonlinear step.

These don’t affect numerical results but tightening them would make configuration errors and logs easier to interpret.

Also applies to: 541-607, 770-805, 1110-1186, 1188-1317

src/openms/include/OpenMS/ANALYSIS/OPENSWATH/MRMScoring.h (1)

11-11: Add <memory> include for FeatureType alias

FeatureType is now defined as std::shared_ptr<OpenSwath::IFeature>, but this header does not include <memory> itself. To keep the header self-contained and avoid relying on transitive includes, it would be safer to add:

 #pragma once
 
-#include <string>
+#include <string>
+#include <memory>

Also applies to: 62-62

🧹 Nitpick comments (30)
src/topp/MRMMapper.cpp (1)

139-146: Smart‑pointer migration is correct; consider more idiomatic construction

The switch to std::shared_ptr here is functionally fine, but you can simplify and decouple from the concrete pointer type by constructing via the alias and make_shared:

-    DataProcessingPtr dp = std::shared_ptr<DataProcessing>(new DataProcessing(dp_));
+    DataProcessingPtr dp = std::make_shared<DataProcessing>(dp_);

This avoids the explicit new, is the usual modern C++ pattern, and keeps the code aligned with DataProcessingPtr if its underlying type ever changes again.

src/tests/class_tests/openms/source/MzCalibration_test.cpp (1)

74-74: Pointer type migration looks good; consider std::make_shared for modern idiom.

The change from boost::shared_ptr to std::shared_ptr is correct and aligns with the PR's modernization effort.

Optionally, prefer std::make_shared for exception safety and efficiency:

-std::shared_ptr<DataProcessing> p_(new DataProcessing(p));
+auto p_ = std::make_shared<DataProcessing>(p);
src/topp/MRMTransitionGroupPicker.cpp (1)

252-260: Change to std::shared_ptr looks correct; consider std::make_shared for idiomatic style

The migration to std::shared_ptr<PeakMap> here is fine and keeps the surrounding logic unchanged. For more idiomatic modern C++, you could simplify the allocation:

-    std::shared_ptr<PeakMap > exp ( new PeakMap );
+    auto exp = std::make_shared<PeakMap>();

This is slightly clearer, avoids repeating the type, and is the common pattern in newer codebases.

src/openms_gui/include/OpenMS/VISUAL/PlotCanvas.h (1)

911-931: Prefer make_shared and rely on the alias instead of explicit std::shared_ptr

The initialization on Line 917 is correct but a bit verbose and hard-wires std::shared_ptr despite having DataProcessingPtr:

DataProcessingPtr p = std::shared_ptr<DataProcessing>(new DataProcessing);

Consider simplifying to avoid raw new, use single-allocation make_shared, and rely on the alias:

DataProcessingPtr p = std::make_shared<DataProcessing>();
// or even:
auto p = std::make_shared<DataProcessing>();

This keeps the code shorter and better aligned with modern C++ practices while preserving flexibility if DataProcessingPtr ever changes.

src/topp/OpenSwathFileSplitter.cpp (1)

107-123: Prefer std::make_shared for exp_meta construction

Minor style/idiom nit: consider using std::make_shared instead of new with std::shared_ptr for better clarity and slightly improved exception safety.

-    std::shared_ptr<ExperimentalSettings> exp_meta(new ExperimentalSettings);
+    auto exp_meta = std::make_shared<ExperimentalSettings>();

This keeps the behavior identical while following modern C++ conventions.

src/openms_gui/source/VISUAL/TVIdentificationViewController.cpp (1)

981-985: Switch to std::make_shared is correct; optionally modernize neighboring shared_ptr construction

The change to

ExperimentSharedPtrType new_exp_sptr = std::make_shared<AnnotatedMSRun>();

is a clean, type-safe replacement for the former Boost make_shared usage and keeps ownership semantics intact when passing new_exp_sptr into addPeakLayer.

As an optional follow-up for consistency with this migration, you could also construct od_dummy via std::make_shared<OnDiscMSExperiment>() (or the corresponding alias) instead of new OnDiscMSExperiment(), but this is not required for correctness here.

src/openms/source/FORMAT/IBSpectraFile.cpp (1)

78-107: guessExperimentType_ migration to std::shared_ptr is sound; consider std::make_shared.

The switch of the return type to std::shared_ptr<IsobaricQuantitationMethod> and the logic for selecting the concrete quantitation method are consistent and behavior-preserving. You may optionally modernize the three return sites to use std::make_shared<...>() for slightly better performance and exception safety:

-  if (cm.getColumnHeaders().size() == 4)
-  {
-    return std::shared_ptr<IsobaricQuantitationMethod>(new ItraqFourPlexQuantitationMethod);
-  }
+  if (cm.getColumnHeaders().size() == 4)
+  {
+    return std::make_shared<ItraqFourPlexQuantitationMethod>();
+  }
   else if (cm.getColumnHeaders().size() == 6)
   {
-    return std::shared_ptr<IsobaricQuantitationMethod>(new TMTSixPlexQuantitationMethod);
+    return std::make_shared<TMTSixPlexQuantitationMethod>();
   }
   else if (cm.getColumnHeaders().size() == 8)
   {
-    return std::shared_ptr<IsobaricQuantitationMethod>(new ItraqEightPlexQuantitationMethod);
+    return std::make_shared<ItraqEightPlexQuantitationMethod>();
   }
src/tests/class_tests/openms/source/SwathMapMassCorrection_test.cpp (2)

166-166: Prefer std::make_shared over direct new for exception safety and efficiency.

The conversion from boost::shared_ptr to std::shared_ptr modernizes the codebase effectively. However, using direct new with the shared_ptr constructor is less exception-safe and performs two allocations instead of one.

Consider applying this pattern to improve exception safety and performance:

-  std::shared_ptr<PeakMap > exp(new PeakMap);
+  std::shared_ptr<PeakMap> exp = std::make_shared<PeakMap>();
-  std::shared_ptr<PeakMap > exp2(new PeakMap);
+  std::shared_ptr<PeakMap> exp2 = std::make_shared<PeakMap>();

Also applies to: 189-189


437-437: Prefer std::make_shared over direct new for exception safety and efficiency.

Same recommendation as the earlier section: the modernization to std::shared_ptr is good, but using std::make_shared would be more idiomatic and safer.

Apply this pattern:

-  std::shared_ptr<PeakMap > exp(new PeakMap);
+  std::shared_ptr<PeakMap> exp = std::make_shared<PeakMap>();
-  std::shared_ptr<PeakMap > exp2(new PeakMap);
+  std::shared_ptr<PeakMap> exp2 = std::make_shared<PeakMap>();
-  std::shared_ptr<PeakMap > exp_ms1(new PeakMap);
+  std::shared_ptr<PeakMap> exp_ms1 = std::make_shared<PeakMap>();

Also applies to: 478-478, 518-518

doc/code_examples/Tutorial_GUI_Plot1D.cpp (1)

32-32: Optional: also modernize on_disc_exp_sptr construction

For consistency with the move to standard smart pointers, you could consider changing

LayerDataBase::ODExperimentSharedPtrType on_disc_exp_sptr(new OnDiscMSExperiment());

to a std::make_shared-based construction (if ODExperimentSharedPtrType is now an alias for std::shared_ptr<OnDiscMSExperiment>), e.g.:

LayerDataBase::ODExperimentSharedPtrType on_disc_exp_sptr = std::make_shared<OnDiscMSExperiment>();

Purely stylistic; not required for this PR.

src/openms/include/OpenMS/FORMAT/DATAACCESS/SwathFileConsumer.h (1)

303-306: std::shared_ptr migration looks fine; consider modernized construction and explicit include

The switch from boost::shared_ptr to std::shared_ptr for swath_maps_/ms1_map_ and the various exp locals is semantically correct and keeps the existing ownership model intact. As small optional cleanups:

  • Use std::make_shared to construct PeakMap instances instead of std::shared_ptr<PeakMap>(new PeakMap(...)) for better readability, exception safety, and slightly reduced allocations, e.g.:

  • std::shared_ptr exp(new PeakMap(settings_));

  • swath_maps_.push_back(exp);

  • swath_maps_.push_back(std::make_shared(settings_));
    
    and similarly for `ms1_map_` and the `ensureMapsAreFilled_` allocations.
    
    
  • Where you immediately assign to a member or vector element, you can also skip the temporary and assign directly:

  • std::shared_ptr exp(new PeakMap);

  • swath_maps_[i] = exp;

  • swath_maps_[i] = std::make_shared();
    
    
  • If not already done elsewhere, consider adding an explicit #include <memory> in this header to avoid depending on transitive includes for std::shared_ptr.

These are non-blocking style improvements; the current code is functionally OK. Based on learnings, this also keeps memory usage efficient for large datasets.

Also applies to: 345-347, 361-363, 440-442, 460-462, 500-506, 513-519

src/tests/class_tests/openms/source/MRMFeatureFinderScoring_test.cpp (3)

59-59: Consider using std::make_shared for better practices.

While the current approach works, prefer std::make_shared<PeakMap>() over new PeakMap for improved exception safety and performance (single allocation for control block and object).

Apply this diff:

-  std::shared_ptr<PeakMap> swath_map (new PeakMap);
+  std::shared_ptr<PeakMap> swath_map = std::make_shared<PeakMap>();
   TransitionGroupMapType transition_group_map;
   MRMFeatureFinderScoring::MRMTransitionGroupType transition_group;
 
   // Load the chromatograms (mzML) and the meta-information (TraML)
-  std::shared_ptr<PeakMap> exp (new PeakMap);
+  std::shared_ptr<PeakMap> exp = std::make_shared<PeakMap>();

Also applies to: 64-64


221-221: Consider using std::make_shared for better practices.

Same as the previous test section - prefer std::make_shared<PeakMap>() over new PeakMap.

Apply this diff:

-  std::shared_ptr<PeakMap> swath_map (new PeakMap);
+  std::shared_ptr<PeakMap> swath_map = std::make_shared<PeakMap>();
   TransitionGroupMapType transition_group_map;
 
   // Load the chromatograms (mzML) and the meta-information (TraML)
-  std::shared_ptr<PeakMap> exp (new PeakMap);
+  std::shared_ptr<PeakMap> exp = std::make_shared<PeakMap>();

Also applies to: 225-225


307-307: Consider using std::make_shared for better practices.

Same recommendation - prefer std::make_shared<PeakMap>() over new PeakMap.

Apply this diff:

-  std::shared_ptr<PeakMap> exp (new PeakMap);
+  std::shared_ptr<PeakMap> exp = std::make_shared<PeakMap>();
src/topp/OpenSwathRTNormalizer.cpp (1)

197-198: Use std::make_shared for improved performance and exception safety.

The migration from boost::shared_ptr to std::shared_ptr is correct. The recommendation to prefer std::make_shared over direct new allocation is valid and follows patterns already established in the codebase (e.g., MRMFeatureFinderScoring.cpp lines 161–162). Benefits include single allocation of control block and object together, and stronger exception safety.

The design where swath_map remains empty is intentional—it serves as a separate data structure distinct from xic_map, which is populated with chromatogram data. Both empty and populated maps are passed to getSpectrumAccessOpenMSPtr as intended.

Apply this refactor:

-      std::shared_ptr<MapType> swath_map (new MapType()); // the map with the extracted ion chromatograms
-      std::shared_ptr<MapType> xic_map (new MapType());
+      std::shared_ptr<MapType> swath_map = std::make_shared<MapType>(); // the map with the extracted ion chromatograms
+      std::shared_ptr<MapType> xic_map = std::make_shared<MapType>();
src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp (1)

431-431: Avoid duplicating MS1 PeakMap copies; reuse a single shared PeakMap and SpectrumAccessPtr.

Right now ms_data_ is copied twice onto the heap: once via std::make_shared<MSExperiment>(ms_data_) for setMS1Map (Line 431) and again via std::make_shared<PeakMap>(ms_data_) for spec_temp (Lines 510–512). For large MS1 experiments this is a noticeable, unnecessary memory overhead, since both consumers only need read‑only access to the same data.

You can create a single std::shared_ptr<PeakMap> once, build one SpectrumAccessPtr from it, and reuse that both for feat_finder_.setMS1Map and for extraction, while still allowing ms_data_.reset() later to free the original member:

@@
-    feat_finder_.setStrictFlag(false);
-    // to use MS1 Swath scores:
-    feat_finder_.setMS1Map(SimpleOpenMSSpectraFactory::getSpectrumAccessOpenMSPtr(std::make_shared<MSExperiment>(ms_data_)));
+    feat_finder_.setStrictFlag(false);
+    // to use MS1 Swath scores:
+    std::shared_ptr<PeakMap> shared = std::make_shared<PeakMap>(ms_data_);
+    OpenSwath::SpectrumAccessPtr ms1_access =
+        SimpleOpenMSSpectraFactory::getSpectrumAccessOpenMSPtr(shared);
+    feat_finder_.setMS1Map(ms1_access);
@@
-    std::shared_ptr<PeakMap> shared = std::make_shared<PeakMap>(ms_data_);
-    OpenSwath::SpectrumAccessPtr spec_temp =
-        SimpleOpenMSSpectraFactory::getSpectrumAccessOpenMSPtr(shared);
+    OpenSwath::SpectrumAccessPtr spec_temp = ms1_access;

This keeps a single heap copy of the MS1 data and a single SpectrumAccessOpenMS instance, reusing them in both places, while preserving existing semantics for ms_data_.reset() and uses of shared later in the function.

Also applies to: 510-512

src/openms/source/FORMAT/HANDLERS/CachedMzMLHandler.cpp (1)

239-257: std::shared_ptr migration for DataProcessing looks fine

Switching dp from boost::shared_ptr to std::shared_ptr in both metadata writers preserves behavior and matches the wider migration. If you touch this again, you could optionally modernize to auto dp = std::make_shared<DataProcessing>(); to avoid repeating the type and the raw new, but that’s not required here.

Also applies to: 282-300

src/openms/include/OpenMS/FORMAT/XMassFile.h (1)

131-156: std::shared_ptr usage is fine; minor modernization possible

Switching data_processing_vector to std::shared_ptr<DataProcessing> preserves the original semantics when passing into spectrum.setDataProcessing. If you touch this again, you could:

  • Prefer the alias DataProcessingPtr (if available) for consistency with other code, and/or
  • Use std::make_shared<DataProcessing>(data_processing) instead of an explicit new.

Also ensure at least one included header in this file pulls in <memory> so this header does not rely on transitive includes.

src/tests/class_tests/openms/source/OpenSwathSpectrumAccessOpenMS_test.cpp (1)

18-18: std::shared_ptr migration in tests looks consistent

The switch from boost::shared_ptr to std::shared_ptr for PeakMap and OpenSwath::ISpectrumAccess in this test file is consistent with the updated SpectrumAccessOpenMS API and keeps the test behavior unchanged. If you ever touch this again, you could replace the new PeakMap patterns with std::make_shared<PeakMap>() to avoid raw new even in tests.

Also applies to: 34-37, 49-54, 63-64, 72-87, 95-97, 112-113, 145-147, 168-170, 185-187, 206-208, 231-233, 252-254, 286-288, 317-319, 331-333

src/openms/source/APPLICATIONS/TOPPBase.cpp (1)

2354-2365: DataProcessing pointer migration preserves behavior

Creating one std::shared_ptr<DataProcessing> and pushing it to all spectra and chromatograms matches the previous ownership model with Boost pointers. If you want to modernize further, auto dp_ = std::make_shared<DataProcessing>(dp); would avoid explicit new.

src/openms/source/KERNEL/OnDiscMSExperiment.cpp (1)

36-45: std::shared_ptr migration looks correct; consider std::make_shared for clarity

Assigning meta_ms_experiment_ via std::shared_ptr<PeakMap>(new PeakMap) is functionally fine and consistent with the previous Boost usage. If you touch this again, consider meta_ms_experiment_ = std::make_shared<PeakMap>(); to be more idiomatic and slightly cheaper in allocations.

src/tests/class_tests/openms/source/ChromatogramSettings_test.cpp (1)

379-385: Test adapts correctly to std::shared_ptr; minor style tweak possible

Using DataProcessingPtr dp = std::shared_ptr<DataProcessing>(new DataProcessing); is correct for the updated alias. You could simplify to DataProcessingPtr dp = std::make_shared<DataProcessing>(); (or auto dp = std::make_shared<DataProcessing>();) for cleaner, idiomatic test code.

src/openms/include/OpenMS/FORMAT/HANDLERS/MzXMLHandler.h (1)

169-173: data_processing_ switched to std::shared_ptr consistently

Changing data_processing_ to std::vector<std::shared_ptr<DataProcessing>> is consistent with the rest of the migration away from Boost smart pointers and should be ABI‑compatible for internal use. Optionally, you could use the existing DataProcessingPtr alias for consistency with other code paths.

src/tests/class_tests/openms/source/SpectrumSettings_test.cpp (1)

281-283: Prefer std::make_shared (and/or DataProcessingPtr) for clarity and efficiency

All three sites construct DataProcessing via std::shared_ptr<DataProcessing>(new DataProcessing). You can tighten this up and avoid the raw new by using make_shared, which also makes the intent clearer:

-    DataProcessingPtr dp = std::shared_ptr<DataProcessing>(new DataProcessing); 
+    DataProcessingPtr dp = std::make_shared<DataProcessing>();

and analogously at the other two occurrences.

Also applies to: 328-330, 375-382

src/openms/include/OpenMS/FORMAT/HANDLERS/MzDataHandler.h (1)

184-185: Consider explicitly including <memory> for std::shared_ptr

Switching data_processing_ to std::shared_ptr<DataProcessing> is correct, but this header doesn’t include <memory> itself. To avoid depending on transitive includes from other headers, consider adding:

#include <memory>

near the other standard includes, or ensure it’s guaranteed via a central header.

src/openms/source/ANALYSIS/OPENSWATH/DATAACCESS/SpectrumAccessOpenMS.cpp (1)

30-33: Consider using std::make_shared for consistency and potential performance benefits.

The change correctly uses std::shared_ptr for the return type. For a minor improvement, consider using std::make_shared which provides a single allocation for both the control block and object:

 std::shared_ptr<OpenSwath::ISpectrumAccess> SpectrumAccessOpenMS::lightClone() const
 {
-    return std::shared_ptr<SpectrumAccessOpenMS>(new SpectrumAccessOpenMS(*this));
+    return std::make_shared<SpectrumAccessOpenMS>(*this);
 }

This pattern could also be applied to other lightClone() implementations in SpectrumAccessSqMass, SpectrumAccessOpenMSCached, SpectrumAccessOpenMSInMemory, and SpectrumAccessQuadMZTransforming for consistency.

src/openms/source/ANALYSIS/OPENSWATH/DATAACCESS/MRMFeatureAccessOpenMS.cpp (1)

24-24: Prefer std::make_shared for exception safety and efficiency.

While the current code is correct, using std::make_shared<FeatureOpenMS>(...) instead of std::shared_ptr<FeatureOpenMS>(new FeatureOpenMS(...)) provides better exception safety and typically performs a single memory allocation instead of two.

Apply this refactor:

-      std::shared_ptr<FeatureOpenMS> ptr = std::shared_ptr<FeatureOpenMS>(new FeatureOpenMS(mrmfeature.getFeature(*it)));
+      std::shared_ptr<FeatureOpenMS> ptr = std::make_shared<FeatureOpenMS>(mrmfeature.getFeature(*it));

And similarly for line 32:

-      std::shared_ptr<FeatureOpenMS> ptr = std::shared_ptr<FeatureOpenMS>(new FeatureOpenMS(mrmfeature.getPrecursorFeature(*it)));
+      std::shared_ptr<FeatureOpenMS> ptr = std::make_shared<FeatureOpenMS>(mrmfeature.getPrecursorFeature(*it));

Also applies to: 32-32

src/openms/source/FORMAT/SwathFile.cpp (1)

57-57: Prefer std::make_shared for PeakMap allocations.

Consider using std::make_shared<PeakMap>() instead of std::shared_ptr<PeakMap>(new PeakMap) for better exception safety and memory efficiency.

Apply this refactor pattern at lines 57, 200, 294, and 302:

-    std::shared_ptr<PeakMap > exp(new PeakMap);
+    std::shared_ptr<PeakMap> exp = std::make_shared<PeakMap>();

Also applies to: 200-200, 294-294, 302-302

src/tests/class_tests/openms/source/SwathFile_test.cpp (1)

109-109: Consider using std::make_shared in tests for consistency.

While not critical in test code, using std::make_shared<ExperimentalSettings>() instead of std::shared_ptr<ExperimentalSettings>(new ExperimentalSettings()) would align with modern C++ best practices.

Apply this pattern:

-  std::shared_ptr<ExperimentalSettings> meta = std::shared_ptr<ExperimentalSettings>(new ExperimentalSettings());
+  std::shared_ptr<ExperimentalSettings> meta = std::make_shared<ExperimentalSettings>();

Also applies to: 132-132, 161-161, 194-194

src/tests/class_tests/openms/source/SpectrumAccessQuadMZTransforming_test.cpp (1)

24-24: Consider using std::make_shared in test helpers.

For consistency with modern C++ practices, consider using std::make_shared<PeakMap>() instead of std::shared_ptr<PeakMap>(new PeakMap).

-  std::shared_ptr<PeakMap > exp2(new PeakMap);
+  std::shared_ptr<PeakMap> exp2 = std::make_shared<PeakMap>();

And at line 45:

-std::shared_ptr<PeakMap > exp(new PeakMap);
+std::shared_ptr<PeakMap> exp = std::make_shared<PeakMap>();

Also applies to: 45-45

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp (1)

459-460: Use PeakMap in make_shared for type clarity and consistency

getSpectrumAccessOpenMSPtr is declared with const std::shared_ptr<PeakMap>&, while this call uses std::make_shared<MSExperiment>(ms_data_). If PeakMap is an alias for MSExperiment, this is functionally fine, but using the alias directly would be clearer and consistent with the rest of the file (e.g. line 764) and with the factory signature:

-    feat_finder_.setMS1Map(SimpleOpenMSSpectraFactory::getSpectrumAccessOpenMSPtr(std::make_shared<MSExperiment>(ms_data_)));
+    feat_finder_.setMS1Map(
+      SimpleOpenMSSpectraFactory::getSpectrumAccessOpenMSPtr(
+        std::make_shared<PeakMap>(ms_data_)));

Also note that this performs a full copy of ms_data_; combined with the additional copy at line 764 this keeps two heap copies of the MS1 data alive during runSingleGroup_. This mirrors the previous boost-based behavior, but if memory becomes an issue for very large datasets, it might be worth refactoring to share a single std::shared_ptr<PeakMap> between the MS1 map and chromatogram extraction path.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 17e5690 and 1a88014.

📒 Files selected for processing (2)
  • src/openms/source/FEATUREFINDER/FeatureFinderAlgorithmMetaboIdent.cpp (1 hunks)
  • src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/openms/source/FEATUREFINDER/FeatureFinderAlgorithmMetaboIdent.cpp
🧰 Additional context used
📓 Path-based instructions (1)
src/openms/**/*.{cpp,h,hpp,cc,cxx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms

Files:

  • src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)

Applied to files:

  • src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms

Applied to files:

  • src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp
📚 Learning: 2025-08-14T10:19:54.371Z
Learnt from: jpfeuffer
Repo: OpenMS/OpenMS PR: 8167
File: src/topp/Digestor.cpp:200-226
Timestamp: 2025-08-14T10:19:54.371Z
Learning: In OpenMS (C++ bioinformatics framework), use boost random libraries instead of std library random distributions for cross-platform reproducible random number generation, as std library distributions are not reproducible across platforms.

Applied to files:

  • src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets

Applied to files:

  • src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality

Applied to files:

  • src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp
🧬 Code graph analysis (1)
src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp (1)
src/openms/source/ANALYSIS/OPENSWATH/DATAACCESS/SimpleOpenMSSpectraAccessFactory.cpp (2)
  • getSpectrumAccessOpenMSPtr (41-54)
  • getSpectrumAccessOpenMSPtr (41-41)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: build-lnx
  • GitHub Check: build-lnx-arm
  • GitHub Check: build-macos
  • GitHub Check: build-win
  • GitHub Check: build-macos-arm
  • GitHub Check: build-and-test (ubuntu-22.04-arm, g++, 11)
  • GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
  • GitHub Check: build-and-test (macos-26, xcode, 26.0)
  • GitHub Check: build-and-test (macos-15-intel, xcode, 16.0.0)
  • GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
  • GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
  • GitHub Check: cppcheck-test
🔇 Additional comments (1)
src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp (1)

764-819: Std smart‑pointer migration here looks correct

The migration to std::shared_ptr<PeakMap> and std::make_shared<PeakMap>(ms_data_) integrates cleanly with SimpleOpenMSSpectraFactory::getSpectrumAccessOpenMSPtr(shared) and the subsequent use of (*shared)[0] for chromatogram annotation. The lifetime of shared and spec_temp is confined to the extraction loop, and ms_data_.reset() happens only after all uses, so there are no new ownership or lifetime issues introduced by this change.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@timosachsenberg
timosachsenberg enabled auto-merge (squash) November 29, 2025 15:49
@jpfeuffer

Copy link
Copy Markdown
Contributor

Looks good and since tests pass should be correct.

@timosachsenberg
timosachsenberg merged commit 54006d1 into develop Nov 30, 2025
@timosachsenberg
timosachsenberg deleted the claude/finish-openms-pr-7860-01LmhYPcZ8NpWGru4zeX8Mbi branch November 30, 2025 10:11
@jpfeuffer

Copy link
Copy Markdown
Contributor

@timosachsenberg This PR destroyed dozens of APIs in pyopenms!!
It converted all TODOS into wrap-ignores.

Please fix this. And also please fix the workarounds introduced due to removal of those APIs (e.g. changes to drange)

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

Will provide a fix. And a test.

Copilot AI added a commit that referenced this pull request Dec 16, 2025
Remove all 5 wrap-ignore comments that were added in PR #8405:
- ChromatogramPeak.pxd: Removed wrap-ignore from constructor, getPosition(), and setPosition()
- DRange.pxd: Removed wrap-ignore from constructor and encloses() method

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

3 participants