Repository navigation
(feat,osw): Save extracted ion mobilograms to parquet C++ - #8871
Conversation
…s to Parquet format
…d output finalization
… consumeMobilogram method
… and mobilogram outputs
…n OSW and SQL consumer
…or handling and debug logging
…ram and mobilogram files (.xic, .xim)
…n chromatogram and mobilogram files
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds Parquet-based mobilogram I/O and runtime mobilogram emission: new Changes
Sequence Diagram(s)sequenceDiagram
participant TOPP as TOPP/OpenSwathWorkflow
participant Workflow as OpenSwathWorkflow
participant Scorer as OpenSwathScoring
participant IM as IonMobilityScoring
participant Consumer as MobilogramParquetConsumer
participant Parquet as ParquetFile
TOPP->>Workflow: performExtraction(..., mobilogram_consumer)
Workflow->>Scorer: calculateDIAScores(..., mobilogram_consumer, feature_id)
Scorer->>IM: driftScoring(..., mobilogram_consumer, feature_rt, feature_id)
IM->>IM: computeIonMobilogram(...)
IM->>Consumer: consumeMobilogram(mobilogram, type, ms_level, transition_id, feature_rt, feature_id)
Consumer->>Parquet: buffer and write Arrow batches
IM-->>Scorer: return drift scores
Scorer-->>Workflow: return feature scores
Workflow->>Consumer: finalize()
Consumer->>Parquet: flush and close file
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cpp (1)
517-518:⚠️ Potential issue | 🔴 CriticalExtra closing brace will cause compilation error.
There's an unmatched closing brace at line 518. The
updateMembers_()function ends at line 517, and the namespace should have already been closed. This extra brace will cause a compilation error.🐛 Proposed fix
gauss_.setParameters(gfilter_parameters); } - } +}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cpp` around lines 517 - 518, There is an extra closing brace after the end of updateMembers_(): remove the unmatched brace so that updateMembers_() ends correctly and the surrounding namespace closing braces remain balanced; locate the end of the updateMembers_() function in PeakPickerMobilogram.cpp (symbol: updateMembers_()) and delete the stray `}` that follows it to restore proper brace matching for the namespace.src/openms/source/ANALYSIS/OPENSWATH/OpenSwathWorkflow.cpp (1)
734-765:⚠️ Potential issue | 🟠 MajorPropagate mobilogram writer failures instead of skipping the assay.
Line 736 now pulls parquet output into this
tryblock, but the trailingcatch (const std::exception&)still logs and continues as if every failure were a recoverable scoring problem. If the mobilogram writer throws here (disk full, Arrow/parquet error, permission issue), the run can silently emit a partial.ximwhile the workflow keeps going. Please narrow the catch to scoring-domain exceptions, or rethrow output/write exceptions oncemobilogram_consumeris enabled.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/OPENSWATH/OpenSwathWorkflow.cpp` around lines 734 - 765, The current try around featureFinder.scorePeakgroups(transition_group, trafo, swath_maps, output, ms1only, mobilogram_consumer) is catching all std::exception and continuing, which hides mobilogram_consumer write/IO failures; change the control flow so only scoring-domain exceptions (e.g. Exception::InvalidRange, Exception::IllegalArgument) are caught and cause skipping, while any other exceptions (including IO/parquet/Arrow errors from mobilogram_consumer) are rethrown. Concretely, either move writing/outside-mobilogram logic out of the scoring try block or, in the catch for std::exception, detect if mobilogram_consumer is enabled and rethrow (or simply rethrow all non-scoring exceptions), keeping the existing logging+continue behavior only for the two scoring exceptions referenced by Exception::InvalidRange and Exception::IllegalArgument and the scorePeakgroups call.
🧹 Nitpick comments (9)
src/openms/source/ANALYSIS/OPENSWATH/CalibrationWorkflow.cpp (2)
54-54: Same concern as above for nonlinear peptides per bin.The
setMaxIntforauto_irt:irt_peptides_per_bin_nonlinearis also commented out. Apply the same resolution as the linear counterpart for consistency.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/OPENSWATH/CalibrationWorkflow.cpp` at line 54, The commented-out max limit for nonlinear IRT peptides needs the same fix as the linear case: uncomment or add a defaults_.setMaxInt call for the key "auto_irt:irt_peptides_per_bin_nonlinear" with the same sensible cap used for the linear setting (e.g., 10000) in CalibrationWorkflow.cpp so that defaults_ enforces a maximum; locate the commented line around the existing defaults_ usage and mirror the change applied to the linear counterpart (use the exact symbol defaults_.setMaxInt and the exact key "auto_irt:irt_peptides_per_bin_nonlinear").
43-43: Clarify intent: commented-out max constraint lacks rationale.The
setMaxIntconstraint forauto_irt:irt_peptides_per_binhas been disabled without explanation. This allows users to set arbitrarily large values, which could impact memory usage or performance. Consider either:
- Removing the commented line entirely if the constraint is no longer needed
- Adding a brief comment explaining why the constraint was removed
- Setting a higher but still reasonable upper bound
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/OPENSWATH/CalibrationWorkflow.cpp` at line 43, The commented-out defaults_.setMaxInt call for the "auto_irt:irt_peptides_per_bin" key removed the upper bound without explanation; either reintroduce a reasonable cap (e.g., change the commented line to defaults_.setMaxInt("auto_irt:irt_peptides_per_bin", 10000) to limit memory/CPU impact) or, if unlimited is intentional, delete the dead line and add a short clarifying comment above referencing defaults_.setMaxInt and the "auto_irt:irt_peptides_per_bin" key explaining why no max is enforced (e.g., performance/memory tradeoff or dynamic handling).src/openms/include/OpenMS/FORMAT/XIMParquetFile.h (1)
164-165: Consider adding move semantics for better performance.The class declares copy constructor/assignment as defaulted but omits move operations. For a class holding
std::vector<String>, adding move semantics could improve performance when transferring ownership.♻️ Proposed addition
XIMParquetFile(const XIMParquetFile& rhs) = default; XIMParquetFile& operator=(const XIMParquetFile& rhs) = default; + XIMParquetFile(XIMParquetFile&& rhs) = default; + XIMParquetFile& operator=(XIMParquetFile&& rhs) = default; + ~XIMParquetFile() = default;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/include/OpenMS/FORMAT/XIMParquetFile.h` around lines 164 - 165, Add move semantics to XIMParquetFile to allow efficient transfer of its std::vector<String> members: declare a move constructor XIMParquetFile(XIMParquetFile&&) and move assignment XIMParquetFile& operator=(XIMParquetFile&&) (marking them noexcept if the contained types are noexcept) and default them, e.g. use = default; so moves are used instead of costly copies for functions/methods that return or reassign XIMParquetFile.src/openms/source/ANALYSIS/OPENSWATH/OpenSwathScoring.cpp (1)
12-13: Duplicate include.
<OpenMS/CONCEPT/LogStream.h>is included twice.♻️ Remove duplicate include
`#include` <OpenMS/CONCEPT/Macros.h> `#include` <OpenMS/CONCEPT/LogStream.h> -#include <OpenMS/CONCEPT/LogStream.h>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/OPENSWATH/OpenSwathScoring.cpp` around lines 12 - 13, The file contains a duplicate include of OpenMS/CONCEPT/LogStream.h; remove the redundant include directive so only a single `#include` <OpenMS/CONCEPT/LogStream.h> remains (check for any other accidental duplicate includes in the same translation unit), leaving the rest of OpenSwathScoring.cpp unchanged.src/tests/class_tests/openms/source/XIMParquetFile_test.cpp (1)
56-64: Duplicate test cases with identical parameters.The
filtered_stringandfiltered_argstests use identical parameters and perform the same assertions. Consider differentiating them or consolidating into a single test.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/tests/class_tests/openms/source/XIMParquetFile_test.cpp` around lines 56 - 64, The two test blocks create duplicated checks: both call xim.getMobilograms with identical arguments and assert the same properties for filtered_string and filtered_args; remove redundancy by consolidating into a single test or change one call to exercise a different parameter path (e.g., pass a non-empty string or different numeric filters) so you exercise different code paths; update the assertions accordingly for the chosen case and keep references to xim.getMobilograms and the XIMMobilogram vectors (filtered_string/filtered_args) to locate and modify the tests.src/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cpp (1)
336-344: Overly defensive try-catch around bounds-checked array access.Wrapping standard array access in try-catch is unnecessary here since the loop already bounds-checks with
i < floatDataArray.size(). Standard library containers don't throw on valid index access viaoperator[]. This adds overhead without benefit.♻️ Simplified version
for (size_t i = 0; i < floatDataArray.size(); ++i) { - // defensive: wrap access in try to surface potential UB/access issues - try - { - result.push_back(static_cast<double>(floatDataArray[i])); - } - catch (const std::exception& e) - { - OPENMS_LOG_DEBUG << "[DBG] Exception while reading floatDataArray[" << i << "] : " << e.what() << std::endl; - throw; - } + result.push_back(static_cast<double>(floatDataArray[i])); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cpp` around lines 336 - 344, The try-catch around reading floatDataArray[i] in PeakPickerMobilogram.cpp is unnecessary because the loop already bounds-checks and operator[] won't throw; remove the entire try { result.push_back(static_cast<double>(floatDataArray[i])); } catch (...) block and replace it with a direct push of the casted value (i.e., result.push_back(static_cast<double>(floatDataArray[i]))), keeping the surrounding loop and variables (floatDataArray, result) intact to avoid added overhead and preserve behavior.src/tests/class_tests/openms/source/MobilogramParquetConsumer_test.cpp (1)
68-85: Test name and intent mismatch.The test is named
MobilogramParquetConsumer_destructor_no_throwbut it's actually testing that the constructor doesn't throw when given a path to a non-existent directory. The destructor is never explicitly tested here.Additionally, testing that a constructor silently accepts an invalid output path may mask real errors. Consider whether the constructor should validate the path or if this is intentional lazy initialization.
💡 Suggested rename for clarity
-START_SECTION(MobilogramParquetConsumer_destructor_no_throw) +START_SECTION(MobilogramParquetConsumer_constructor_invalid_path)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/tests/class_tests/openms/source/MobilogramParquetConsumer_test.cpp` around lines 68 - 85, The test currently named MobilogramParquetConsumer_destructor_no_throw actually exercises the constructor with a non-existent output directory; rename the test to MobilogramParquetConsumer_constructor_no_throw (or MobilogramParquetConsumer_constructor_handles_missing_directory) to match intent, and either adjust the assertions to reflect intended behavior of the constructor (e.g., assert it does not throw) or update the constructor to validate the output path and change the test to expect a throw; also add a separate test MobilogramParquetConsumer_destructor_no_throw that explicitly constructs and then destroys a MobilogramParquetConsumer to verify the destructor behavior. Ensure references to MobilogramParquetConsumer and the constructor call remain consistent.src/openms/source/APPLICATIONS/OpenSwathBase.cpp (1)
356-358: Unnecessary address-of operator in unused variable cast.The cast to suppress the unused variable warning uses
(void)&source_filebut should be(void)source_file. While both work, taking the address is unnecessary.♻️ Simplified unused variable suppression
`#ifndef` WITH_PARQUET - (void)&source_file; + (void)source_file; throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/APPLICATIONS/OpenSwathBase.cpp` around lines 356 - 358, Replace the unnecessary address-of suppression in the WITH_PARQUET fallback: instead of casting the address with (void)&source_file, use (void)source_file to silence the unused-variable warning; update the block guarded by the WITH_PARQUET macro where source_file is referenced and keep the existing throw Exception::NotImplemented(..., OPENMS_PRETTY_FUNCTION) behavior unchanged.src/openms/source/ANALYSIS/OPENSWATH/IonMobilityScoring.cpp (1)
145-166: KeepcomputeIonMobilogramextraction-only.
mobilogram_consumeris not used here, and Line 166 suppresses it inside the hot loop. Since all writes already happen in the callers after alignment, this helper now carries output-related API surface for no behavior change. I’d drop the parameter from this helper entirely, or at least move the(void)suppression above the loop if you need it temporarily.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/OPENSWATH/IonMobilityScoring.cpp` around lines 145 - 166, The computeIonMobilogram helper currently has an unused MobilogramParquetConsumer* mobilogram_consumer parameter (and a (void)mobilogram_consumer; inside the loop) which leaks output-related API into an extraction-only function; remove the mobilogram_consumer parameter from the computeIonMobilogram signature and all internal references (including the (void) suppression), and update all callers to stop passing mobilogram_consumer, or if callers are numerous and you prefer a minimal change, move the (void)mobilogram_consumer; line to the start of the function (before the loop) and document it as deprecated — target symbols: computeIonMobilogram and mobilogram_consumer (type MobilogramParquetConsumer).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@CHANGELOG`:
- Line 185: Fix the typo in the CHANGELOG by replacing the misspelled phrase
"extraced ion mobilogram files" with "extracted ion mobilogram files" in the
entry that reads "Added support for reading/writing Parquet extracted ion
chromatogram files (.xic) and extraced ion mobilogram files (.xim)."; update
that sentence so both occurrences read correctly.
In `@src/openms/source/FORMAT/DATAACCESS/MobilogramParquetConsumer.cpp`:
- Around line 232-240: The code is holding write_mutex_ while doing expensive
compression in encodeMobilogram_, serializing parallel workers; call
encodeMobilogram_(m) and compute next_binary_bytes (using
encoded.mobility_encoded.size()/intensity_encoded.size()) before acquiring
write_mutex_, then acquire std::lock_guard<std::mutex> lock(write_mutex_) only
to check/update pending_binary_bytes_ and pending_rows_ and call flushChunk_()
if needed; ensure you still use the same encoded object inside the locked region
when appending/buffering and update pending_binary_bytes_ and pending_rows_
consistently (references: write_mutex_, encodeMobilogram_,
pending_binary_bytes_, pending_rows_, MAX_BUFFERED_BINARY_BYTES_, flushChunk_).
In `@src/openms/source/FORMAT/XIMParquetFile.cpp`:
- Around line 689-746: The helper normalizeAndPruneColumns_ currently silently
drops unsupported/misspelled filter columns (populating dropped_columns) which
can turn a filtered query into an unfiltered read; change it to fail fast: after
computing dropped_columns (using buildSchemaNameMap_ and inspecting
expr.conditions) detect if any user-supplied conditions were removed and throw
an exception (or return an error) that includes the dropped column names and the
original expr so callers cannot proceed with a pruned/invalid filter; at
minimum, if pruning results in expr.conditions becoming empty, raise an error
instead of letting the caller continue with an unfiltered read.
- Around line 1650-1690: The code currently allows nesting transitions
(nest_transitions) even when no precursor-level columns are requested, which
causes all rows to share an empty precursor_key_str and collapse transitions;
after you validate and build normalized_columns (based on requested_columns and
allowed_columns), add a guard that if nest_transitions is true then
normalized_columns must contain at least one of the precursor discriminator
fields {"PRECURSOR_ID", "MODIFIED_SEQUENCE", "PRECURSOR_CHARGE",
"PRECURSOR_DECOY"} and if not, throw an Exception::InvalidValue (use the same
file/line/function pattern) with a clear message requiring a precursor-level
column for nested output so the grouping logic that builds precursor_key_str has
valid discriminators.
In `@src/topp/OpenSwathWorkflow.cpp`:
- Around line 1317-1324: The multi-run filename generation currently slices the
full out_mobilogram path into base_name/extension and then prefixes
file_basename, which can produce an invalid path like
"sample_/tmp/results/out.xim"; fix by splitting out_mobilogram into directory
and filename (stem + extension), then build out_mobilogram_current by keeping
the original directory and prepending file_basename only to the filename (stem)
before re-attaching the extension; update the code around variables
out_mobilogram, base_name, extension and out_mobilogram_current (the block that
calls prepareMobilogramOutput) to perform directory/filename separation and
recomposition so the parent directory is preserved.
---
Outside diff comments:
In `@src/openms/source/ANALYSIS/OPENSWATH/OpenSwathWorkflow.cpp`:
- Around line 734-765: The current try around
featureFinder.scorePeakgroups(transition_group, trafo, swath_maps, output,
ms1only, mobilogram_consumer) is catching all std::exception and continuing,
which hides mobilogram_consumer write/IO failures; change the control flow so
only scoring-domain exceptions (e.g. Exception::InvalidRange,
Exception::IllegalArgument) are caught and cause skipping, while any other
exceptions (including IO/parquet/Arrow errors from mobilogram_consumer) are
rethrown. Concretely, either move writing/outside-mobilogram logic out of the
scoring try block or, in the catch for std::exception, detect if
mobilogram_consumer is enabled and rethrow (or simply rethrow all non-scoring
exceptions), keeping the existing logging+continue behavior only for the two
scoring exceptions referenced by Exception::InvalidRange and
Exception::IllegalArgument and the scorePeakgroups call.
In `@src/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cpp`:
- Around line 517-518: There is an extra closing brace after the end of
updateMembers_(): remove the unmatched brace so that updateMembers_() ends
correctly and the surrounding namespace closing braces remain balanced; locate
the end of the updateMembers_() function in PeakPickerMobilogram.cpp (symbol:
updateMembers_()) and delete the stray `}` that follows it to restore proper
brace matching for the namespace.
---
Nitpick comments:
In `@src/openms/include/OpenMS/FORMAT/XIMParquetFile.h`:
- Around line 164-165: Add move semantics to XIMParquetFile to allow efficient
transfer of its std::vector<String> members: declare a move constructor
XIMParquetFile(XIMParquetFile&&) and move assignment XIMParquetFile&
operator=(XIMParquetFile&&) (marking them noexcept if the contained types are
noexcept) and default them, e.g. use = default; so moves are used instead of
costly copies for functions/methods that return or reassign XIMParquetFile.
In `@src/openms/source/ANALYSIS/OPENSWATH/CalibrationWorkflow.cpp`:
- Line 54: The commented-out max limit for nonlinear IRT peptides needs the same
fix as the linear case: uncomment or add a defaults_.setMaxInt call for the key
"auto_irt:irt_peptides_per_bin_nonlinear" with the same sensible cap used for
the linear setting (e.g., 10000) in CalibrationWorkflow.cpp so that defaults_
enforces a maximum; locate the commented line around the existing defaults_
usage and mirror the change applied to the linear counterpart (use the exact
symbol defaults_.setMaxInt and the exact key
"auto_irt:irt_peptides_per_bin_nonlinear").
- Line 43: The commented-out defaults_.setMaxInt call for the
"auto_irt:irt_peptides_per_bin" key removed the upper bound without explanation;
either reintroduce a reasonable cap (e.g., change the commented line to
defaults_.setMaxInt("auto_irt:irt_peptides_per_bin", 10000) to limit memory/CPU
impact) or, if unlimited is intentional, delete the dead line and add a short
clarifying comment above referencing defaults_.setMaxInt and the
"auto_irt:irt_peptides_per_bin" key explaining why no max is enforced (e.g.,
performance/memory tradeoff or dynamic handling).
In `@src/openms/source/ANALYSIS/OPENSWATH/IonMobilityScoring.cpp`:
- Around line 145-166: The computeIonMobilogram helper currently has an unused
MobilogramParquetConsumer* mobilogram_consumer parameter (and a
(void)mobilogram_consumer; inside the loop) which leaks output-related API into
an extraction-only function; remove the mobilogram_consumer parameter from the
computeIonMobilogram signature and all internal references (including the (void)
suppression), and update all callers to stop passing mobilogram_consumer, or if
callers are numerous and you prefer a minimal change, move the
(void)mobilogram_consumer; line to the start of the function (before the loop)
and document it as deprecated — target symbols: computeIonMobilogram and
mobilogram_consumer (type MobilogramParquetConsumer).
In `@src/openms/source/ANALYSIS/OPENSWATH/OpenSwathScoring.cpp`:
- Around line 12-13: The file contains a duplicate include of
OpenMS/CONCEPT/LogStream.h; remove the redundant include directive so only a
single `#include` <OpenMS/CONCEPT/LogStream.h> remains (check for any other
accidental duplicate includes in the same translation unit), leaving the rest of
OpenSwathScoring.cpp unchanged.
In `@src/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cpp`:
- Around line 336-344: The try-catch around reading floatDataArray[i] in
PeakPickerMobilogram.cpp is unnecessary because the loop already bounds-checks
and operator[] won't throw; remove the entire try {
result.push_back(static_cast<double>(floatDataArray[i])); } catch (...) block
and replace it with a direct push of the casted value (i.e.,
result.push_back(static_cast<double>(floatDataArray[i]))), keeping the
surrounding loop and variables (floatDataArray, result) intact to avoid added
overhead and preserve behavior.
In `@src/openms/source/APPLICATIONS/OpenSwathBase.cpp`:
- Around line 356-358: Replace the unnecessary address-of suppression in the
WITH_PARQUET fallback: instead of casting the address with (void)&source_file,
use (void)source_file to silence the unused-variable warning; update the block
guarded by the WITH_PARQUET macro where source_file is referenced and keep the
existing throw Exception::NotImplemented(..., OPENMS_PRETTY_FUNCTION) behavior
unchanged.
In `@src/tests/class_tests/openms/source/MobilogramParquetConsumer_test.cpp`:
- Around line 68-85: The test currently named
MobilogramParquetConsumer_destructor_no_throw actually exercises the constructor
with a non-existent output directory; rename the test to
MobilogramParquetConsumer_constructor_no_throw (or
MobilogramParquetConsumer_constructor_handles_missing_directory) to match
intent, and either adjust the assertions to reflect intended behavior of the
constructor (e.g., assert it does not throw) or update the constructor to
validate the output path and change the test to expect a throw; also add a
separate test MobilogramParquetConsumer_destructor_no_throw that explicitly
constructs and then destroys a MobilogramParquetConsumer to verify the
destructor behavior. Ensure references to MobilogramParquetConsumer and the
constructor call remain consistent.
In `@src/tests/class_tests/openms/source/XIMParquetFile_test.cpp`:
- Around line 56-64: The two test blocks create duplicated checks: both call
xim.getMobilograms with identical arguments and assert the same properties for
filtered_string and filtered_args; remove redundancy by consolidating into a
single test or change one call to exercise a different parameter path (e.g.,
pass a non-empty string or different numeric filters) so you exercise different
code paths; update the assertions accordingly for the chosen case and keep
references to xim.getMobilograms and the XIMMobilogram vectors
(filtered_string/filtered_args) to locate and modify the tests.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1c160738-28f7-41a3-9950-745b2a36c862
📒 Files selected for processing (27)
CHANGELOGsrc/openms/include/OpenMS/ANALYSIS/OPENSWATH/IonMobilityScoring.hsrc/openms/include/OpenMS/ANALYSIS/OPENSWATH/MRMFeatureFinderScoring.hsrc/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathScoring.hsrc/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathWorkflow.hsrc/openms/include/OpenMS/APPLICATIONS/OpenSwathBase.hsrc/openms/include/OpenMS/FORMAT/DATAACCESS/MobilogramParquetConsumer.hsrc/openms/include/OpenMS/FORMAT/FileTypes.hsrc/openms/include/OpenMS/FORMAT/XIMParquetFile.hsrc/openms/include/OpenMS/FORMAT/sources.cmakesrc/openms/source/ANALYSIS/OPENSWATH/CalibrationWorkflow.cppsrc/openms/source/ANALYSIS/OPENSWATH/IonMobilityScoring.cppsrc/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFinderScoring.cppsrc/openms/source/ANALYSIS/OPENSWATH/OpenSwathScoring.cppsrc/openms/source/ANALYSIS/OPENSWATH/OpenSwathWorkflow.cppsrc/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cppsrc/openms/source/APPLICATIONS/OpenSwathBase.cppsrc/openms/source/FORMAT/DATAACCESS/MobilogramParquetConsumer.cppsrc/openms/source/FORMAT/DATAACCESS/sources.cmakesrc/openms/source/FORMAT/FileTypes.cppsrc/openms/source/FORMAT/XIMParquetFile.cppsrc/openms/source/FORMAT/sources.cmakesrc/tests/class_tests/openms/data/XIMParquetFile_23_input.ximsrc/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/MobilogramParquetConsumer_test.cppsrc/tests/class_tests/openms/source/XIMParquetFile_test.cppsrc/topp/OpenSwathWorkflow.cpp
…e precursor discriminator requirement
…filter expressions
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/openms/include/OpenMS/ANALYSIS/OPENSWATH/IonMobilityScoring.h (1)
80-95:⚠️ Potential issue | 🟡 MinorDocument
mobilogram_consumeras a non-owning parameter.These public overloads now accept a raw
MobilogramParquetConsumer*, but the Doxygen only says it is optional. Please state that the pointer is non-owning, must remain valid for the duration of the call, and can surface write-related exceptions when export is enabled.As per coding guidelines,
Every public method must include a Doxygen comment with@brief,@PARAM[in/out/in,out] for all parameters,@returnfor return values, and@throwsfor exceptions.Also applies to: 110-124, 139-152, 167-183, 196-205
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/include/OpenMS/ANALYSIS/OPENSWATH/IonMobilityScoring.h` around lines 80 - 95, Update the Doxygen for the public overloads that accept a raw MobilogramParquetConsumer* (e.g., the driftScoring(...) declaration) to explicitly state that the pointer is non-owning, must remain valid for the duration of the call, and that enabling exports may surface write-related exceptions; add a `@brief` and `@param`[in]/@param[out] annotations for every parameter (including mobilogram_consumer), an `@throws` describing possible write exceptions, and an `@return` if applicable; apply the same wording to all other public overloads that take a MobilogramParquetConsumer* so the ownership and exception behavior is consistently documented.src/topp/OpenSwathWorkflow.cpp (1)
1304-1313:⚠️ Potential issue | 🟠 MajorMake both output consumers exception-safe around
performExtraction().The two consumers are still managed manually. If
prepareMobilogramOutput()orwf.performExtraction()throws,chromatogramConsumerleaks, and if extraction throws after the mobilogram writer is created it never gets finalized. Wrap both raw pointers immediately and finalize the mobilogram writer from an exception-safe scope.♻️ One way to harden the lifetime handling
- Interfaces::IMSDataConsumer* chromatogramConsumer; + Interfaces::IMSDataConsumer* chromatogram_consumer_raw = nullptr; @@ - prepareChromOutput(&chromatogramConsumer, exp_meta, transition_exp, out_chrom_current, cur_run, current_run_files[0]); + prepareChromOutput(&chromatogram_consumer_raw, exp_meta, transition_exp, out_chrom_current, cur_run, current_run_files[0]); + std::unique_ptr<Interfaces::IMSDataConsumer> chromatogramConsumer(chromatogram_consumer_raw); @@ - MobilogramParquetConsumer* mobilogramConsumer = nullptr; + MobilogramParquetConsumer* mobilogram_consumer_raw = nullptr; @@ - prepareMobilogramOutput(&mobilogramConsumer, exp_meta, transition_exp, out_mobilogram_current, cur_run, current_run_files[0]); + prepareMobilogramOutput(&mobilogram_consumer_raw, exp_meta, transition_exp, out_mobilogram_current, cur_run, current_run_files[0]); + std::unique_ptr<MobilogramParquetConsumer> mobilogramConsumer(mobilogram_consumer_raw); @@ - MSDataSqlConsumer* sql_cons = dynamic_cast<MSDataSqlConsumer*>(chromatogramConsumer); + MSDataSqlConsumer* sql_cons = dynamic_cast<MSDataSqlConsumer*>(chromatogramConsumer.get()); @@ - wf.performExtraction(swath_maps, trafo_rtnorm, cp_current, cp_ms1_current, feature_finder_param_run, transition_exp, - active_feature_map, true, oswwriter, chromatogramConsumer, batchSize, ms1_isotopes, load_into_memory, mrm_map_param, mobilogramConsumer); - - if (mobilogramConsumer != nullptr) - { - mobilogramConsumer->finalize(); - delete mobilogramConsumer; - mobilogramConsumer = nullptr; - } - - delete chromatogramConsumer; + try + { + wf.performExtraction(swath_maps, trafo_rtnorm, cp_current, cp_ms1_current, feature_finder_param_run, transition_exp, + active_feature_map, true, oswwriter, chromatogramConsumer.get(), batchSize, ms1_isotopes, load_into_memory, mrm_map_param, mobilogramConsumer.get()); + if (mobilogramConsumer != nullptr) + { + mobilogramConsumer->finalize(); + } + } + catch (...) + { + if (mobilogramConsumer != nullptr) + { + try { mobilogramConsumer->finalize(); } catch (...) {} + } + throw; + }Also applies to: 1315-1367
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/OpenSwathWorkflow.cpp` around lines 1304 - 1313, The chromatogramConsumer and mobilogram writer created by prepareChromOutput and prepareMobilogramOutput must be made exception-safe: wrap the raw Interfaces::IMSDataConsumer* and the mobilogram writer pointer immediately in RAII holders (e.g., std::unique_ptr or a scope-guarded wrapper) so they are deleted if prepareMobilogramOutput or wf.performExtraction() throws, and ensure the mobilogram writer is finalized (closed/flushed) from a destructor or a scope guard rather than only after performExtraction completes; update the code paths around prepareChromOutput, prepareMobilogramOutput, and wf.performExtraction to use these RAII wrappers and move any explicit finalize() calls into the wrapper destructor or a finally-style scope guard to guarantee cleanup on exceptions.
♻️ Duplicate comments (1)
src/topp/OpenSwathWorkflow.cpp (1)
1315-1329:⚠️ Potential issue | 🟠 MajorMirror this directory-preserving logic for
out_chrom_currenttoo.This block fixes the multi-run XIM filename case, but the chromatogram block a few lines above still prefixes
file_basenameonto the fullout_chrompath. With an output like/tmp/results/out.xic, that still producessample_/tmp/results/out.xicand breaks per-run chromatogram export.🧭 Apply the same split/recompose pattern to `out_chrom_current`
- if (!out_chrom.empty() && run_groups.size() > 1) - { - // For multi-run, use basename prefix to make unique filenames - String base_name = out_chrom.substr(0, out_chrom.find_last_of('.')); - String extension = out_chrom.substr(out_chrom.find_last_of('.')); - out_chrom_current = file_basename + "_" + base_name + extension; - } + if (!out_chrom.empty() && run_groups.size() > 1) + { + String parent = File::path(out_chrom); + String filename = File::basename(out_chrom); + String stem = filename.substr(0, filename.find_last_of('.')); + String extension = filename.substr(filename.find_last_of('.')); + String prefixed_filename = file_basename + "_" + stem + extension; + out_chrom_current = (parent == "." ? prefixed_filename : parent + "/" + prefixed_filename); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/OpenSwathWorkflow.cpp` around lines 1315 - 1329, The chromatogram output logic should mirror the directory-preserving logic used for mobilograms: locate the code handling out_chrom_current (and the call to prepareChromatogramOutput or similar) and replace the naive prefixing of file_basename + out_chrom with the same split-recompose pattern used for mobilograms (use File::path(out_chrom), File::basename(out_chrom), extract stem/extension, build fname_with_prefix = file_basename + "_" + stem + extension, and set out_chrom_current to parent == "." ? fname_with_prefix : parent + "/" + fname_with_prefix) so per-run chromatogram filenames keep the original parent directory.
🧹 Nitpick comments (1)
src/tests/class_tests/openms/source/FileTypes_test.cpp (1)
133-135: AssertMOBILPARQUETdirectly instead of only bumping the totals.Line 133 and Line 135 only prove that the counts changed. This can still pass if some unrelated entry in
src/openms/source/FORMAT/FileTypes.cppchanges whileFileTypes::MOBILPARQUETis no longer registered as readable. Please add a containment check forFileTypes::MOBILPARQUET, and replace the hard-coded65withSIZE_OF_TYPEor drop that redundant assertion since Line 137 already covers it.♻️ Proposed test tightening
FileTypeList g = FileTypeList::typesWithProperties(f); TEST_EQUAL(g.getTypes().size(), 42); + TEST_TRUE(g.contains(FileTypes::MOBILPARQUET)); // Test that empty filter returns the full list - TEST_EQUAL(FileTypeList::typesWithProperties({}).size(), 65); + TEST_EQUAL(FileTypeList::typesWithProperties({}).size(), static_cast<size_t>(FileTypes::Type::SIZE_OF_TYPE));Based on learnings: Applies to src/tests/class_tests/**/*_test.cpp : Write unit tests for new functionality and ensure existing tests pass before suggesting changes.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/tests/class_tests/openms/source/FileTypes_test.cpp` around lines 133 - 135, The test currently only asserts total counts and can miss that FileTypes::MOBILPARQUET was removed; update the test in FileTypes_test.cpp to explicitly check that the registered types contain FileTypes::MOBILPARQUET (e.g., verify g.getTypes() or the result of FileTypeList::typesWithProperties({}) includes FileTypes::MOBILPARQUET) and remove or replace the hard-coded 65 assertion with a symbolic SIZE_OF_TYPE constant or simply drop that redundant count check so the test asserts presence of MOBILPARQUET directly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/openms/include/OpenMS/FORMAT/DATAACCESS/MobilogramParquetConsumer.h`:
- Around line 30-41: The Doxygen says transition_exp is "optional/nullable" but
the constructor MobilogramParquetConsumer(const String& filename, UInt64 run_id,
const String& source_file, const OpenSwath::LightTargetedExperiment&
transition_exp) takes a const reference (not nullable), so update the docs to
reflect the actual contract: explicitly state that callers should pass an empty
OpenSwath::LightTargetedExperiment to indicate "no annotation" (or, if you
intend a true nullable API, change the signature to accept a pointer or
std::optional<OpenSwath::LightTargetedExperiment> and update callers/tests
accordingly); modify the Doxygen comment for MobilogramParquetConsumer to
clearly describe which behavior is expected and follow header documentation
guidelines.
In `@src/openms/source/FORMAT/DATAACCESS/MobilogramParquetConsumer.cpp`:
- Around line 236-243: The consumer currently allows consumeMobilogram() to
proceed after finalize() which sets wrote_ and closes the writer; under the
write_mutex_ guard add a check at the start of consumeMobilogram() (and the
other write path around lines 333-376) to detect wrote_ == true and immediately
throw a runtime_error (or similar) to fail fast; do this check before computing
next_binary_bytes or calling flushChunk_() so no further file operations
(including reopen/truncate via flushChunk_()) can occur after finalization.
- Around line 140-164: The helper parseOrAssignId_ currently accepts parsed
negative IDs (e.g. -1) which collide with the sentinel "unset" values; modify
parseOrAssignId_ so that after converting text to int64_t (in the block using
text.toInt64()) you only accept and insert the parsed value if value >= 0 (and
still manage next_id when value >= next_id), otherwise treat it as an invalid
parse and fall through to the auto-assign path that finds the next non-negative
unused ID; keep references to next_id and used_ids unchanged and ensure you
don't insert negative values into used_ids or return them.
In `@src/openms/source/FORMAT/XIMParquetFile.cpp`:
- Around line 580-597: The IN-operator branch only strips '['/']' but
tokenize_() can emit '(' and ')' so expressions like "TRANSITION_ID IN (1,2)"
leave parentheses as values and later cause conversion failures; in the op ==
"IN" block (where tokens, i, and cond.values are handled) detect and accept both
'['/']' and '(' / ')' as valid list delimiters (consume the opening delimiter,
gather comma-separated tokens into cond.values, then consume the matching
closing delimiter), or if you prefer to disallow parentheses explicitly, detect
'(' and immediately throw a targeted parse Exception::InvalidValue mentioning
the unexpected '(' so the error occurs at parse time rather than during
conversion.
---
Outside diff comments:
In `@src/openms/include/OpenMS/ANALYSIS/OPENSWATH/IonMobilityScoring.h`:
- Around line 80-95: Update the Doxygen for the public overloads that accept a
raw MobilogramParquetConsumer* (e.g., the driftScoring(...) declaration) to
explicitly state that the pointer is non-owning, must remain valid for the
duration of the call, and that enabling exports may surface write-related
exceptions; add a `@brief` and `@param`[in]/@param[out] annotations for every
parameter (including mobilogram_consumer), an `@throws` describing possible write
exceptions, and an `@return` if applicable; apply the same wording to all other
public overloads that take a MobilogramParquetConsumer* so the ownership and
exception behavior is consistently documented.
In `@src/topp/OpenSwathWorkflow.cpp`:
- Around line 1304-1313: The chromatogramConsumer and mobilogram writer created
by prepareChromOutput and prepareMobilogramOutput must be made exception-safe:
wrap the raw Interfaces::IMSDataConsumer* and the mobilogram writer pointer
immediately in RAII holders (e.g., std::unique_ptr or a scope-guarded wrapper)
so they are deleted if prepareMobilogramOutput or wf.performExtraction() throws,
and ensure the mobilogram writer is finalized (closed/flushed) from a destructor
or a scope guard rather than only after performExtraction completes; update the
code paths around prepareChromOutput, prepareMobilogramOutput, and
wf.performExtraction to use these RAII wrappers and move any explicit finalize()
calls into the wrapper destructor or a finally-style scope guard to guarantee
cleanup on exceptions.
---
Duplicate comments:
In `@src/topp/OpenSwathWorkflow.cpp`:
- Around line 1315-1329: The chromatogram output logic should mirror the
directory-preserving logic used for mobilograms: locate the code handling
out_chrom_current (and the call to prepareChromatogramOutput or similar) and
replace the naive prefixing of file_basename + out_chrom with the same
split-recompose pattern used for mobilograms (use File::path(out_chrom),
File::basename(out_chrom), extract stem/extension, build fname_with_prefix =
file_basename + "_" + stem + extension, and set out_chrom_current to parent ==
"." ? fname_with_prefix : parent + "/" + fname_with_prefix) so per-run
chromatogram filenames keep the original parent directory.
---
Nitpick comments:
In `@src/tests/class_tests/openms/source/FileTypes_test.cpp`:
- Around line 133-135: The test currently only asserts total counts and can miss
that FileTypes::MOBILPARQUET was removed; update the test in FileTypes_test.cpp
to explicitly check that the registered types contain FileTypes::MOBILPARQUET
(e.g., verify g.getTypes() or the result of
FileTypeList::typesWithProperties({}) includes FileTypes::MOBILPARQUET) and
remove or replace the hard-coded 65 assertion with a symbolic SIZE_OF_TYPE
constant or simply drop that redundant count check so the test asserts presence
of MOBILPARQUET directly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3ef1ca1f-da39-489b-8eb9-a7543a99afbc
📒 Files selected for processing (7)
CHANGELOGsrc/openms/include/OpenMS/ANALYSIS/OPENSWATH/IonMobilityScoring.hsrc/openms/include/OpenMS/FORMAT/DATAACCESS/MobilogramParquetConsumer.hsrc/openms/source/FORMAT/DATAACCESS/MobilogramParquetConsumer.cppsrc/openms/source/FORMAT/XIMParquetFile.cppsrc/tests/class_tests/openms/source/FileTypes_test.cppsrc/topp/OpenSwathWorkflow.cpp
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
src/openms/source/FORMAT/XIMParquetFile.cpp (1)
580-597:⚠️ Potential issue | 🟡 MinorAccept
IN (...)or reject it before conversion.The
INoperator branch only strips[/]delimiters, buttokenize_()emits(and)as standalone tokens (line 471). A filter likeTRANSITION_ID IN (1, 2)will therefore keep the parentheses as values and later fail during integer conversion. Handle both delimiter pairs, or throw a targeted parse error when(is encountered.💡 Proposed fix to handle both bracket types
if (op == "IN") { - if (i < tokens.size() && tokens[i] == "[") ++i; - while (i < tokens.size() && tokens[i] != "]") + String close_token; + if (i < tokens.size() && (tokens[i] == "[" || tokens[i] == "(")) + { + close_token = (tokens[i] == "[") ? "]" : ")"; + ++i; + } + else + { + throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, + "IN operator expects a bracketed value list", filter); + } + while (i < tokens.size() && tokens[i] != close_token) { if (tokens[i] != ",") { cond.values.push_back(tokens[i]); } ++i; } if (cond.values.empty()) { throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "IN operator expects at least one value", filter); } - if (i < tokens.size() && tokens[i] == "]") ++i; + if (i >= tokens.size() || tokens[i] != close_token) + { + throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, + "Unclosed IN list", filter); + } + ++i; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/FORMAT/XIMParquetFile.cpp` around lines 580 - 597, The IN operator branch in the IN-handling block (where op == "IN") currently only strips '[' and ']' but tokenize_() can emit '(' and ')' as separate tokens, causing parentheses to be treated as values for cond.values; update that branch in XIMParquetFile.cpp so it treats both delimiter pairs equivalently: accept and skip either "[" or "(" before the loop and skip the matching "]" or ")" after, or alternatively detect a "(" token and throw a clear parse Exception::InvalidValue referencing the filter to reject IN with parentheses before conversion; ensure you update the same block that pushes into cond.values so parentheses are never appended.
🧹 Nitpick comments (3)
src/openms/source/FORMAT/XIMParquetFile.cpp (3)
656-658: Consider logging whenfeature_rtfilter is requested but ignored.The
feature_rtparameter is accepted bybuildFilterFromArgs_but explicitly ignored (cast tovoid). While the comment at line 703 explains why (floating-point not supported by the integer/string filter DSL), users callinggetMobilogramswith afeature_rtfilter might not realize it's being silently dropped. Consider logging a warning whenfeature_rt >= 0.0.💡 Add warning when feature_rt is ignored
if (feature_id >= 0) builder.eq("FEATURE_ID", feature_id); - (void)feature_rt; + if (feature_rt >= 0.0) + { + OPENMS_LOG_WARN << "FEATURE_RT filter not supported in predicate pushdown; will be applied in post-filter\n"; + } return builder.expression();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/FORMAT/XIMParquetFile.cpp` around lines 656 - 658, buildFilterFromArgs_ currently accepts a feature_rt parameter but casts it to void and silently ignores it; when callers (e.g., getMobilograms) pass feature_rt >= 0.0 this behavior is confusing. Modify buildFilterFromArgs_ to detect feature_rt >= 0.0 and emit a warning via the existing logging facility (or the class logger) indicating that feature_rt filtering is not supported by the integer/string DSL and is being ignored; reference the function name buildFilterFromArgs_, the parameter feature_rt, and call sites like getMobilograms in the log message so users know which API ignored the filter.
1654-1654: Fix indentation alignment.Line 1654 appears to have incorrect indentation (missing leading spaces) compared to the surrounding code block. As per coding guidelines, use consistent 2-space indentation.
♻️ Suggested fix
- std::shared_ptr<arrow::Schema> schema = readParquetSchemaAllFiles_(filenames_); + std::shared_ptr<arrow::Schema> schema = readParquetSchemaAllFiles_(filenames_);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/FORMAT/XIMParquetFile.cpp` at line 1654, The line with "std::shared_ptr<arrow::Schema> schema = readParquetSchemaAllFiles_(filenames_);" is misindented; update its leading whitespace to match the surrounding 2-space indentation style used in this block (inside XIMParquetFile.cpp), ensuring it aligns with surrounding statements and keeps the declaration of variable "schema" and the call to "readParquetSchemaAllFiles_" visually consistent with the enclosing scope.
1100-1108: Consider batching filtered rows for better memory efficiency.The current approach creates a single-row
RecordBatchslice for each matching row, which can be memory-inefficient for large result sets with high selectivity. While this is a fallback path (used when Arrow compute fails), consider accumulating matching row indices and slicing in larger chunks.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/FORMAT/XIMParquetFile.cpp` around lines 1100 - 1108, The loop currently pushes a one-row batch per match (batch->Slice(row, 1)), which is inefficient; change evaluateFilterExpression_ usage to accumulate matching row indices (e.g., a vector<int64_t> matched_rows) and when the vector reaches a threshold (like 1024) or at loop end produce larger batches instead of single-row slices: for contiguous ranges use batch->Slice(start, length) to append multi-row slices to batches, and for non-contiguous selections use Arrow's Take/TakeOptions (or equivalent API) to create a multi-row RecordBatch from the collected indices; reference evaluateFilterExpression_, parsed.connectors, batch->Slice, and the batches vector when locating where to implement the accumulation and chunked slicing logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/openms/source/FORMAT/XIMParquetFile.cpp`:
- Line 1534: The equality check using mobilogram.feature_rt != feature_rt is
unsafe for doubles; change the condition to use a tolerance-based comparison
(e.g., fabs(mobilogram.feature_rt - feature_rt) > epsilon) and only perform it
when mobilogram.has_feature_rt is true, or document that exact binary-equality
is guaranteed; update the if to use a named epsilon (e.g., const double
RT_TOLERANCE) and compare with fabs/near-equal helper so the branch becomes: if
(feature_rt >= 0.0 && (!mobilogram.has_feature_rt || fabs(mobilogram.feature_rt
- feature_rt) > RT_TOLERANCE)) continue.
- Line 58: Replace the redundant ValueOrDie() call by using the dereference
operator for consistency: where you construct the reader (the line with
std::unique_ptr<parquet::arrow::FileReader> reader =
std::move(reader_result.ValueOrDie());), change it to move from *reader_result
(i.e., std::move(*reader_result)) to match the existing pattern used with
*infile_result and Arrow C++ idioms.
---
Duplicate comments:
In `@src/openms/source/FORMAT/XIMParquetFile.cpp`:
- Around line 580-597: The IN operator branch in the IN-handling block (where op
== "IN") currently only strips '[' and ']' but tokenize_() can emit '(' and ')'
as separate tokens, causing parentheses to be treated as values for cond.values;
update that branch in XIMParquetFile.cpp so it treats both delimiter pairs
equivalently: accept and skip either "[" or "(" before the loop and skip the
matching "]" or ")" after, or alternatively detect a "(" token and throw a clear
parse Exception::InvalidValue referencing the filter to reject IN with
parentheses before conversion; ensure you update the same block that pushes into
cond.values so parentheses are never appended.
---
Nitpick comments:
In `@src/openms/source/FORMAT/XIMParquetFile.cpp`:
- Around line 656-658: buildFilterFromArgs_ currently accepts a feature_rt
parameter but casts it to void and silently ignores it; when callers (e.g.,
getMobilograms) pass feature_rt >= 0.0 this behavior is confusing. Modify
buildFilterFromArgs_ to detect feature_rt >= 0.0 and emit a warning via the
existing logging facility (or the class logger) indicating that feature_rt
filtering is not supported by the integer/string DSL and is being ignored;
reference the function name buildFilterFromArgs_, the parameter feature_rt, and
call sites like getMobilograms in the log message so users know which API
ignored the filter.
- Line 1654: The line with "std::shared_ptr<arrow::Schema> schema =
readParquetSchemaAllFiles_(filenames_);" is misindented; update its leading
whitespace to match the surrounding 2-space indentation style used in this block
(inside XIMParquetFile.cpp), ensuring it aligns with surrounding statements and
keeps the declaration of variable "schema" and the call to
"readParquetSchemaAllFiles_" visually consistent with the enclosing scope.
- Around line 1100-1108: The loop currently pushes a one-row batch per match
(batch->Slice(row, 1)), which is inefficient; change evaluateFilterExpression_
usage to accumulate matching row indices (e.g., a vector<int64_t> matched_rows)
and when the vector reaches a threshold (like 1024) or at loop end produce
larger batches instead of single-row slices: for contiguous ranges use
batch->Slice(start, length) to append multi-row slices to batches, and for
non-contiguous selections use Arrow's Take/TakeOptions (or equivalent API) to
create a multi-row RecordBatch from the collected indices; reference
evaluateFilterExpression_, parsed.connectors, batch->Slice, and the batches
vector when locating where to implement the accumulation and chunked slicing
logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e2c24310-66d6-475d-b261-5d1fe41ddaef
📒 Files selected for processing (1)
src/openms/source/FORMAT/XIMParquetFile.cpp
|
looks good but can you check the coderabbit comments? |
…force non-negative ID acceptance
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/openms/source/FORMAT/DATAACCESS/MobilogramParquetConsumer.cpp (1)
618-621: Replace the raw codec IDs with a shared enum.
5and6are part of the on-disk contract and are duplicated again insrc/openms/source/FORMAT/XIMParquetFile.cpp's decoder switch. Keeping them as naked integers makes the reader/writer mapping easy to break in a follow-up. Please move these values into a sharedenum class/constants consumed by both sides.As per coding guidelines, "Enums and macros: use UPPER_SNAKE_CASE naming; prefer
enum class".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/FORMAT/DATAACCESS/MobilogramParquetConsumer.cpp` around lines 618 - 621, Replace the magic integers 5 and 6 with a shared enum class: add a new enum class (e.g. COMPRESSION_CODEC or FILE_CODEC) in a common header and define UPPER_SNAKE_CASE members for the on-disk IDs (e.g. MOBILITY_COMPRESSION_LOSSY = 5, INTENSITY_COMPRESSION_LOSSY = 6 and a DEFAULT = 1). In MobilogramParquetConsumer.cpp replace encoded.mobility_compression = use_lossy ? 5 : 1 and encoded.intensity_compression = use_lossy ? 6 : 1 with the corresponding enum members (static_cast to the target integer type if needed). Also update the decoder switch in XIMParquetFile.cpp to switch on the same enum values instead of naked integers so the reader/writer mapping is centralized and consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/openms/source/FORMAT/XIMParquetFile.cpp`:
- Around line 282-323: The helper functions getOptionalInt_(),
getOptionalDouble_(), getOptionalString_(), and getBinaryView_() currently
perform unchecked static_pointer_casts which can lead to UB if the Arrow array
has an unexpected type; modify each to first check array->type_id() (or
array->type()->id()) and only downcast when the type matches (e.g.,
arrow::Type::INT64 for getOptionalInt_, DOUBLE for getOptionalDouble_, STRING
for getOptionalString_, and BINARY for getBinaryView_); follow the same
switch/validation pattern used in getIntValueFromArray_() and
getStringValueFromArray_() to return false (for optional getters) or
throw/handle an error consistently when the type is wrong, ensuring no unsafe
casts occur.
---
Nitpick comments:
In `@src/openms/source/FORMAT/DATAACCESS/MobilogramParquetConsumer.cpp`:
- Around line 618-621: Replace the magic integers 5 and 6 with a shared enum
class: add a new enum class (e.g. COMPRESSION_CODEC or FILE_CODEC) in a common
header and define UPPER_SNAKE_CASE members for the on-disk IDs (e.g.
MOBILITY_COMPRESSION_LOSSY = 5, INTENSITY_COMPRESSION_LOSSY = 6 and a DEFAULT =
1). In MobilogramParquetConsumer.cpp replace encoded.mobility_compression =
use_lossy ? 5 : 1 and encoded.intensity_compression = use_lossy ? 6 : 1 with the
corresponding enum members (static_cast to the target integer type if needed).
Also update the decoder switch in XIMParquetFile.cpp to switch on the same enum
values instead of naked integers so the reader/writer mapping is centralized and
consistent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d4648aad-4bfa-4ed4-bf35-73f0d9adc8cc
📒 Files selected for processing (5)
CHANGELOGsrc/openms/include/OpenMS/FORMAT/DATAACCESS/MobilogramParquetConsumer.hsrc/openms/source/FORMAT/DATAACCESS/MobilogramParquetConsumer.cppsrc/openms/source/FORMAT/XIMParquetFile.cppsrc/tests/class_tests/openms/executables.cmake
🚧 Files skipped from review as they are similar to previous changes (2)
- src/tests/class_tests/openms/executables.cmake
- src/openms/include/OpenMS/FORMAT/DATAACCESS/MobilogramParquetConsumer.h
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
src/openms/source/FORMAT/XIMParquetFile.cpp (4)
1703-1703: Minor indentation inconsistency.Line 1703 appears to have inconsistent indentation compared to the surrounding lines (missing 2 spaces).
♻️ Suggested fix
- std::shared_ptr<arrow::Schema> schema = readParquetSchemaAllFiles_(filenames_); + std::shared_ptr<arrow::Schema> schema = readParquetSchemaAllFiles_(filenames_);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/FORMAT/XIMParquetFile.cpp` at line 1703, The line declaring std::shared_ptr<arrow::Schema> schema = readParquetSchemaAllFiles_(filenames_); has inconsistent indentation; adjust its leading whitespace to match the surrounding block (add the missing two spaces) so it aligns with neighboring statements in XIMParquetFile.cpp and maintains consistent formatting for the readParquetSchemaAllFiles_ call and filenames_ variable usage.
158-173: Consider warning when requested columns are silently skipped.Columns not found in schema are silently ignored. If a caller has a typo or requests a column that doesn't exist, they won't be notified unless all columns are missing. Consider logging a warning for each skipped column.
💡 Suggested enhancement
for (const auto& name : columns) { const int idx = schema->GetFieldIndex(std::string(name)); if (idx >= 0) { column_indices.push_back(idx); } + else + { + OPENMS_LOG_WARN << "Requested column '" << name << "' not found in parquet schema, skipping.\n"; + } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/FORMAT/XIMParquetFile.cpp` around lines 158 - 173, The current loop using columns, schema->GetFieldIndex and column_indices silently ignores individual missing columns and only throws via Exception::MissingInformation when all are missing; change this so that after GetFieldIndex returns <0 you log or warn (e.g., via LOG_WARN or the project's logger) including the missing column name and filename, while still continuing to collect valid indices, and keep the existing exception when column_indices.empty(); update references in this block (columns, schema->GetFieldIndex, column_indices, filename, Exception::MissingInformation) to add the warning for each skipped column.
1148-1156: Row-by-row slicing is memory-inefficient for large result sets.Creating a new
RecordBatchviaSlice(row, 1)for each matching row generates O(n) small batch objects, which has significant memory overhead. Since this is a fallback path when Arrow compute filtering fails, the impact may be limited, but consider collecting matching row indices and building the filtered table more efficiently.💡 Alternative approach using index collection
std::vector<int64_t> matching_rows; matching_rows.reserve(num_rows / 10); // estimate for (int64_t row = 0; row < num_rows; ++row) { if (evaluateFilterExpression_(conditions, parsed.connectors, batch, row)) { matching_rows.push_back(row); } } // Build filtered batch from indices using arrow::compute::Take if (!matching_rows.empty()) { // Use Take kernel or batch slicing with larger chunks }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/FORMAT/XIMParquetFile.cpp` around lines 1148 - 1156, The current loop creates a new small RecordBatch per matching row via batch->Slice(row, 1), which is memory-inefficient; instead, inside the same scope where num_rows, batch, evaluateFilterExpression_, parsed.connectors and batches are available, collect matching row indices into a vector<int64_t> (e.g. matching_rows) while iterating, and after the loop use Arrow's bulk kernels (arrow::compute::Take with an index Array or arrow::compute::Filter with a boolean mask) to produce a single filtered RecordBatch (or larger chunks) and push that into batches; this replaces per-row Slice calls with a single efficient bulk operation.
117-117: Use OpenMSSizetype instead ofsize_t.Per coding guidelines, use
SizefromOpenMS/CONCEPT/Types.hfor STL.size()values.♻️ Suggested fix
- for (size_t i = 1; i < filenames.size(); ++i) + for (Size i = 1; i < filenames.size(); ++i)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/FORMAT/XIMParquetFile.cpp` at line 117, Replace the raw size_t loop index with OpenMS's Size type: change the loop header "for (size_t i = 1; i < filenames.size(); ++i)" to use OpenMS::Size (or Size if Types.h is included). Ensure the translation unit includes OpenMS/CONCEPT/Types.h (or already has it) so Size is available, and update any other local variables in this function that use size_t for .size() results to use Size for consistency.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/openms/source/FORMAT/XIMParquetFile.cpp`:
- Around line 341-357: The binary branch casts view.size() (size_t) to Int which
can overflow; in the arrow::Type::BINARY and arrow::Type::LARGE_BINARY handling
(the blocks that call typed->GetView(row) and return String(view.data(),
static_cast<Int>(view.size()))), check view.size() against
numeric_limits<Int>::max() and either use the project Size type for the String
constructor or throw an Exception::OutOfRange/InvalidValue if the blob is larger
than Int can hold; update the return to pass a safe size type (or
validated/capped value) so no silent overflow occurs.
---
Nitpick comments:
In `@src/openms/source/FORMAT/XIMParquetFile.cpp`:
- Line 1703: The line declaring std::shared_ptr<arrow::Schema> schema =
readParquetSchemaAllFiles_(filenames_); has inconsistent indentation; adjust its
leading whitespace to match the surrounding block (add the missing two spaces)
so it aligns with neighboring statements in XIMParquetFile.cpp and maintains
consistent formatting for the readParquetSchemaAllFiles_ call and filenames_
variable usage.
- Around line 158-173: The current loop using columns, schema->GetFieldIndex and
column_indices silently ignores individual missing columns and only throws via
Exception::MissingInformation when all are missing; change this so that after
GetFieldIndex returns <0 you log or warn (e.g., via LOG_WARN or the project's
logger) including the missing column name and filename, while still continuing
to collect valid indices, and keep the existing exception when
column_indices.empty(); update references in this block (columns,
schema->GetFieldIndex, column_indices, filename, Exception::MissingInformation)
to add the warning for each skipped column.
- Around line 1148-1156: The current loop creates a new small RecordBatch per
matching row via batch->Slice(row, 1), which is memory-inefficient; instead,
inside the same scope where num_rows, batch, evaluateFilterExpression_,
parsed.connectors and batches are available, collect matching row indices into a
vector<int64_t> (e.g. matching_rows) while iterating, and after the loop use
Arrow's bulk kernels (arrow::compute::Take with an index Array or
arrow::compute::Filter with a boolean mask) to produce a single filtered
RecordBatch (or larger chunks) and push that into batches; this replaces per-row
Slice calls with a single efficient bulk operation.
- Line 117: Replace the raw size_t loop index with OpenMS's Size type: change
the loop header "for (size_t i = 1; i < filenames.size(); ++i)" to use
OpenMS::Size (or Size if Types.h is included). Ensure the translation unit
includes OpenMS/CONCEPT/Types.h (or already has it) so Size is available, and
update any other local variables in this function that use size_t for .size()
results to use Size for consistency.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c90e7b58-447b-4323-b9c9-f6db4099c233
📒 Files selected for processing (1)
src/openms/source/FORMAT/XIMParquetFile.cpp
timosachsenberg
left a comment
There was a problem hiding this comment.
Code Review: Save Extracted Ion Mobilograms to Parquet
Major
-
Memory leak on exception —
src/topp/OpenSwathWorkflow.cpp:1329-1365
mobilogramConsumeris allocated withnewanddeleted later, but ifwf.performExtraction()throws, the delete is never reached. Should usestd::unique_ptr. -
Thread safety contract undocumented —
MobilogramParquetConsumer.h
setExpectedSize()must be called before any concurrentconsumeMobilogramcalls (from OpenMP parallel loop inMRMFeatureFinderScoring.cpp:623), but this isn't documented. -
consumeMobilogramsilently clears input —MobilogramParquetConsumer.cpp:305
TakesMobilogram&(mutable) and callsm.clear()at the end. This forces every call site to make a copy first (e.g.,Mobilogram mcopy = aligned_ms2_mobilograms[k]repeated ~6 times inIonMobilityScoring.cpp). Should takeconst Mobilogram&instead. -
Unused parameter —
IonMobilityScoring.cpp:166
mobilogram_consumeris passed tocomputeIonMobilogrambut only suppressed with(void)mobilogram_consumer;. Either use it or remove it from the signature.
Minor
-
Dead code —
MobilogramParquetConsumer.cpp:618,648-654
const bool use_lossy = true;is hardcoded, making theelsebranch (raw zlib) dead code. Either expose as a config option or remove the branch. -
Magic compression numbers —
MobilogramParquetConsumer.cpp:620-621
encoded.mobility_compression = use_lossy ? 5 : 1;— undocumented magic numbers. Should use named constants or an enum, matching the decoder inXIMParquetFile.cpp:395-462. -
Minimal test coverage —
MobilogramParquetConsumer_test.cpp,XIMParquetFile_test.cpp- No round-trip test (write → read → verify data)
- No verification of decoded mobility/intensity values
getAnalytes()andgetColumns()never tested- Destructor test (
MobilogramParquetConsumer_destructor_no_throw) actually tests lazy constructor, not destructor behavior
-
Schema mismatch risk —
MobilogramParquetConsumer.cpp:495-519,561-583
buildSchema_()andbuildTableFromBuilders_()maintain column order via two independent lists. A mismatch would silently produce corrupted data. Consider a single source of truth. -
Unnecessary SQLite dependency —
MobilogramParquetConsumer.cpp:11-13
IncludesSqliteConnector.honly forclearSignBit(). Consider moving that utility to a lightweight header.
Nit
-
Wrong void cast —
OpenSwathBase.cpp:301
(void*)&source_file;should be(void)source_file;. -
Inconsistent nullable sentinel values —
MobilogramParquetConsumer.h:53-66
-1for IDs,NaNfor RT, empty string for native ID — Doxygen just says "nullable use-case" without specifying which sentinel value means "not set" for each parameter. -
setExperimentalSettingsis a no-op —MobilogramParquetConsumer.cpp:339-341
Empty method body. Either implement or remove from public API.
…o use unique_ptr and improve const correctness
…rquet output The out_mobilogram option was added in #8871 to save extracted ion mobilograms (XIMs) to a Parquet file during diaPASEF analysis, but the TOPP tool's doxygen page did not mention this new output option. - Update output section heading to include 'ion mobilograms' - Add paragraph describing the -out_mobilogram parameter, its .xim extension requirement, WITH_PARQUET build dependency, and reference to the XIMParquetFile class for reading the output Co-authored-by: Copilot <[email protected]>
…rquet output (#8930) The out_mobilogram option was added in #8871 to save extracted ion mobilograms (XIMs) to a Parquet file during diaPASEF analysis, but the TOPP tool's doxygen page did not mention this new output option. - Update output section heading to include 'ion mobilograms' - Add paragraph describing the -out_mobilogram parameter, its .xim extension requirement, WITH_PARQUET build dependency, and reference to the XIMParquetFile class for reading the output Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
Description
This pull request add optional support for exporting extracted ion mobilograms to disk, primarily via a new
MobilogramParquetConsumerclass. The change propagates this optional consumer through several scoring and workflow functions in OpenSwathWorkflow, allowing mobilogram data to be written out alongside the usual scoring functionality.Will open a separate PR for pyopenms bindings once this PR is merged.
Mobilogram export integration:
MobilogramParquetConsumerand new optional parameters to scoring functions such asdriftScoring,driftScoringMS1,driftScoringMS1Contrast,driftIdScoring, andcomputeIonMobilogram_inIonMobilityScoring.h, enabling mobilogram export and associating mobilograms with feature metadata (e.g., retention time apex and feature ID). [1] [2] [3] [4] [5] [6] [7] [8] [9]mobilogram_consumerand feature ID parameters to scoring and feature finding methods inMRMFeatureFinderScoring.handOpenSwathScoring.h, including updates to documentation and function signatures. [1] [2] [3] [4] [5] [6] [7] [8] [9]Workflow and output preparation:
mobilogram_consumerparameter to workflow functions inOpenSwathWorkflow.hto enable mobilogram export during batch processing and scoring. [1] [2] [3] [4]prepareMobilogramOutputmethod inOpenSwathBase.hto set up mobilogram output, including documentation and support for Parquet export.These changes collectively enable the extraction and export of ion mobilograms as part of the OpenSWATH analysis workflow, improving data accessibility and downstream analysis capabilities.
Checklist
How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outIf you click in the column that lists the failed tests you will get detailed error messages.
Advanced commands (admins / reviewer only)
Click to expand
/reformat(experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.rebuild jenkinswill retrigger Jenkins-based CI buildsSummary by CodeRabbit
New Features
Tests
Chores