Skip to content

[OpenSwathWorkflow, Parquet] Add Parquet output support for XIC chromatograms (C++ core) - #8737

Merged
timosachsenberg merged 2 commits into
developfrom
feat/xic_parquet_cpp
Feb 4, 2026
Merged

timosachsenberg merged 2 commits into
developfrom
feat/xic_parquet_cpp

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Feb 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR adds support for OpenSWATH chromatogram Parquet files (.xic). It introduces a Parquet writer for chromatograms, a reader with filtering and predicate pushdown, and test coverage including TOPP regression checks.

The schema uses a similar (expanded) schema that was implemented in PyProphet to convert the sqMass chromatograms to parquet. Adding parquet xic output directly to OpenSwathWorkflow skips the additional extra conversion step, and we still see the storage benefits from using parquet compared to sqMass.

890M 20200505_EVOSEP_200SPD_SG06-16_mlhela_200ng_PY8_S3-A1_1_2737.sqMass
367M 20200505_EVOSEP_200SPD_SG06-16_mlhela_200ng_PY8_S3-A1_1_2737.xic

Additions

  • MSChromatogramParquetConsumer writes .xic Parquet files with a PyProphet‑compatible schema (metadata + compressed RT/intensity arrays).
  • XICParquetFile reads .xic files with filter expressions; supports multi‑file input and Arrow Dataset predicate pushdown with compute fallback.
  • ParquetFilter typed, chainable Parquet filter builder for predicate pushdown.
  • TextExporter now supports .xic input, exporting summary or exploded TSV/CSV/TXT for testable text output.
  • OpenSwathWorkflow added -out_chrom_ext xic option for Parquet output.
  • Tests for writer/reader class, TOPP regression tests.

Note

This is the C++ core part of #8725. Python/Cython bindings will be added in a follow-up PR that depends on this one.

Based on work by @singjc in PR #8725.

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.) - Will be in follow-up PR

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Parquet (.xic) support: export OpenSWATH chromatograms, read/query XIC Parquet files with typed and text filters, and include Parquet as an output format in OpenSwathWorkflow and TextExporter.
  • Tests
    • Added unit and integration tests covering Parquet consumer, XIC Parquet reader, and updated Arrow export tests.
  • Other
    • New runtime/build guards and packaging adjustments for Parquet/Arrow integration.

This PR adds support for OpenSWATH chromatogram Parquet files (.xic).
It introduces a Parquet writer for chromatograms, a reader with filtering
and predicate pushdown, and test coverage including TOPP regression checks.

The schema uses a similar (expanded) schema that was implemented in
PyProphet to convert the sqMass chromatograms to parquet. Adding parquet
xic output directly to OpenSwathWorkflow skips the additional extra
conversion step, and provides storage benefits from using parquet
compared to sqMass.

Additions:
- MSChromatogramParquetConsumer: writes .xic Parquet files with a
  PyProphet-compatible schema (metadata + compressed RT/intensity arrays)
- XICParquetFile: reads .xic files with filter expressions; supports
  multi-file input and Arrow Dataset predicate pushdown with compute fallback
- ParquetFilter: typed, chainable Parquet filter builder for predicate pushdown
- TextExporter: now supports .xic input, exporting summary or exploded
  TSV/CSV/TXT for testable text output
- OpenSwathWorkflow: added -out_chrom_ext xic option for Parquet output
- Unit and TOPP tests for the new functionality

Note: Python bindings will be added in a follow-up PR.

Based on work from PR #8725 by @singjc.

Co-Authored-By: singjc <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
timosachsenberg added a commit that referenced this pull request Feb 4, 2026
This PR adds Python bindings for reading XIC data from Parquet files,
enabling integration with pandas, pyarrow, and pyopenms_viz.

Additions:
- XICParquetFile Python bindings with:
  - list-of-files constructor support
  - get_data_dict, get_chromatograms, to_df, to_arrow
  - get_analyte_dict, get_analyte_df, get_run_dict, get_run_df
  - df_columns for column discovery
  - Filter expressions with predicate pushdown support
- ParquetFilter/ParquetFilterBuilder Python bindings for typed filter construction
- ParquetQuery/ChromatogramQuery for chainable querying
- Unit tests for Python bindings

Example usage:
```python
import pyopenms as poms
import glob

files = glob.glob('*.xic')
xic_h = poms.XICParquetFile(files)
xic_h.get_chromatograms(filter="precursor_id=1318 & annotation=y3^1").plot(
    kind="chromatogram", x="rt", y="intensity", by="source_file"
)
```

Depends on PR #8737 (C++ core).
Based on work from PR #8725 by @singjc.

Co-Authored-By: singjc <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Feb 4, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds Parquet/XIC support across OpenMS: new reader/writer (XICParquetFile, MSChromatogramParquetConsumer), Parquet filter API, build-system WITH_PARQUET propagation, TOPP/TextExporter/OpenSwathWorkflow integration, and tests; also hides some ArrowExport Arrow-table APIs behind internal linkage.

Changes

Cohort / File(s) Summary
CMake build & packaging
cmake/OpenMSConfig.cmake.in, cmake/cmake_findExternalLibs.cmake, cmake/package_general.cmake, src/pyOpenMS/CMakeLists.txt
Add/export feature flags (WITH_PARQUET, WITH_HDF5, WITH_GUI), Arrow/Parquet/ArrowDataset target discovery and selection, and include Arrow/Parquet runtime dirs for packaging/pyOpenMS.
Core build lists & targets
src/openms/CMakeLists.txt, src/openms/include/OpenMS/FORMAT/sources.cmake, src/openms/source/FORMAT/sources.cmake, src/openms/source/FORMAT/DATAACCESS/sources.cmake
Conditionally include new Parquet sources/headers under WITH_PARQUET; add compile define WITH_ARROW_DATASET when dataset target found; reorder sources.
File types registry
src/openms/include/OpenMS/FORMAT/FileTypes.h, src/openms/source/FORMAT/FileTypes.cpp
Add new FileTypes::CHROMPARQUET ("xic") and register it as readable/writeable.
Public headers & exports
src/openms/include/OpenMS/FORMAT/ParquetFilter.h, src/openms/include/OpenMS/FORMAT/XICParquetFile.h, src/openms/include/OpenMS/FORMAT/DATAACCESS/MSChromatogramParquetConsumer.h
New public APIs: typed Parquet filter builder, XICParquetFile reader API (load/getChromatograms/getRuns/getAnalytes/getColumns), and MSChromatogramParquetConsumer declaration.
Implementations: Parquet I/O & filters
src/openms/source/FORMAT/ParquetFilter.cpp, src/openms/source/FORMAT/XICParquetFile.cpp, src/openms/source/FORMAT/DATAACCESS/MSChromatogramParquetConsumer.cpp
Implement ParquetFilter, XICParquetFile (read/filter/decode/combine, Arrow dataset pushdown + in-memory fallback), and MSChromatogramParquetConsumer (encode RT/intensity, optional compression, write Parquet).
ArrowExport API change
src/openms/include/OpenMS/FORMAT/ArrowExport.h, src/openms/source/FORMAT/ArrowExport.cpp
Removed public ArrowExport::exportSpectraToArrow/exportChromatogramsToArrow signatures; functions converted to internal free functions (anonymous namespace) and tests adapted to use C Data Interface.
OpenSwath / TOPP / TextExporter integration
src/openms/include/OpenMS/APPLICATIONS/OpenSwathBase.h, src/openms/source/APPLICATIONS/OpenSwathBase.cpp, src/topp/OpenSwathWorkflow.cpp, src/topp/TextExporter.cpp
Extend prepareChromOutput signature to accept source_file; add CHROMPARQUET handling (guarded by WITH_PARQUET) and thread source_file through; TextExporter gains XICParquetFile reading and summary/explode TSV export modes.
Tests & test data
src/tests/class_tests/openms/source/MSChromatogramParquetConsumer_test.cpp, src/tests/class_tests/openms/source/XICParquetFile_test.cpp, src/tests/class_tests/openms/source/ArrowExport_test.cpp, src/tests/class_tests/openms/source/FileTypes_test.cpp, src/tests/class_tests/openms/data/*, src/tests/topp/CMakeLists.txt, src/tests/class_tests/openms/executables.cmake
Add unit and TOPP tests for Parquet reader/writer, update ArrowExport tests to C Data Interface, add test fixtures (TraML/mzML/.xic); gate tests on WITH_PARQUET.

Sequence Diagram(s)

sequenceDiagram
    participant TOPP as OpenSwathWorkflow
    participant Base as OpenSwathBase
    participant Consumer as MSChromatogramParquetConsumer
    participant Parquet as Parquet File
    Base->>Base: FileHandler::getType(out_chrom)
    Base->>Base: detect CHROMPARQUET
    Base->>Consumer: construct(filename, run_id, source_file, transition_exp)
    TOPP->>Consumer: consumeChromatogram(chrom)
    Consumer->>Consumer: encode RT/INT, build Arrow arrays
    Consumer->>Parquet: write Parquet table
    Consumer->>Base: finalize / report errors
Loading
sequenceDiagram
    participant App as TextExporter
    participant Reader as XICParquetFile
    participant Arrow as Arrow/Parquet I/O
    participant Filter as ParquetFilter
    App->>Reader: new XICParquetFile(file)
    App->>Filter: build filter expression
    App->>Reader: getChromatograms(output, filter)
    Reader->>Arrow: open/read schema (dataset optional)
    Reader->>Arrow: apply filter (pushdown if available)
    Arrow->>Reader: return filtered rows
    Reader->>Reader: decode RT/INT blobs (zlib/numpress)
    Reader->>App: return XICChromatogram objects (summary or explode)
Loading

Possibly related PRs

Suggested reviewers

  • jpfeuffer
  • singjc
  • poshul

Poem

🐰 In fields of bytes I hop and play,
Parquet paths now pave the way,
Filters stitched and tables bright,
XICs leap into the light—
nibble data, then sprint away!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title '[OpenSwathWorkflow, Parquet] Add Parquet output support for XIC chromatograms (C++ core)' directly and clearly describes the main change: adding Parquet output support for XIC chromatograms in the C++ core with OpenSwathWorkflow integration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/xic_parquet_cpp

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: 3

🤖 Fix all issues with AI agents
In `@src/openms/include/OpenMS/FORMAT/XICParquetFile.h`:
- Around line 226-259: The getAnalytes signature currently requires columns but
the doc says they are optional; change the declaration of getAnalytes in
XICParquetFile.h to provide a default empty vector for the columns parameter
(e.g., const std::vector<String>& columns = {}) and mirror the same default in
the corresponding definition/implementation (function named getAnalytes) so
callers can omit the argument; if you prefer not to add a default, instead
update the doc comment to remove the word "optional" and clarify that columns
are required—ensure the declaration, implementation, and docs remain consistent.
- Around line 63-143: The three public structs XICChromatogram, XICRunInfo, and
XICAnalyte must be exported on Windows: add the OPENMS_DLLAPI macro to each
struct declaration (i.e., change "struct XICChromatogram", "struct XICRunInfo",
and "struct XICAnalyte" to "struct OPENMS_DLLAPI XICChromatogram", "struct
OPENMS_DLLAPI XICRunInfo", and "struct OPENMS_DLLAPI XICAnalyte") so their
typeinfo and symbols are properly exported for the public API.

In `@src/topp/TextExporter.cpp`:
- Around line 1681-1683: The CHROMPARQUET branch creates an ofstream named
outstr and immediately constructs an SVOutStream (symbols: ofstream
outstr(out.c_str()), SVOutStream output(...), output.modifyStrings(false)) but
doesn't validate that the output file was successfully opened; add the same
check used in the mzML branch after creating outstr (e.g., test outstr.is_open()
or outstr.fail()), and if the file open failed emit a clear error/log and
return/throw the same error path used by the mzML branch so the function exits
early instead of continuing with a bad stream.
🧹 Nitpick comments (5)
src/openms/source/FORMAT/DATAACCESS/MSChromatogramParquetConsumer.cpp (1)

445-448: Consider making compression strategy configurable.

The use_lossy_compression flag is hardcoded to true. While MSNumpress lossy compression is a reasonable default for chromatogram data (especially since this targets PyProphet compatibility), consider exposing this as a constructor parameter for use cases requiring lossless export.

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

239-366: Consider whether ParquetFilterBuilder provides value over ParquetFilter.

ParquetFilterBuilder appears to duplicate the entire ParquetFilter interface, simply forwarding all calls to an internal ParquetFilter instance. Both classes offer the same fluent builder pattern.

If the intent is API stability (allowing ParquetFilter internals to change while ParquetFilterBuilder remains stable), this is reasonable. Otherwise, consider whether one class would suffice to reduce maintenance burden.

src/openms/source/FORMAT/XICParquetFile.cpp (3)

1027-1121: Manual filter fallback is correct but memory-intensive.

The row-by-row slicing approach (batch->Slice(row, 1)) creates many small RecordBatch objects, which may be inefficient for large datasets. However, this is a fallback path when Arrow compute filtering fails, so the trade-off is acceptable.


1487-1493: Post-filter validation is redundant but harmless.

These checks duplicate the Arrow/compute filter conditions. While they add a small performance overhead, they serve as a defensive safety net in case of filter implementation bugs.


1609-1609: Minor: Inconsistent indentation.

The std::shared_ptr<arrow::Schema> declaration appears to have leading whitespace inconsistency compared to surrounding lines.

📝 Proposed fix for indentation
-  std::shared_ptr<arrow::Schema> schema = readParquetSchemaAllFiles_(filenames_);
+    std::shared_ptr<arrow::Schema> schema = readParquetSchemaAllFiles_(filenames_);

Comment on lines +63 to +143
@brief Lightweight chromatogram container for XIC parquet rows.
*/
struct XICChromatogram
{
Int64 run_id{0};
String source_file;
Int64 ms_level{0};

bool has_precursor_id{false};
Int64 precursor_id{0};
bool has_transition_id{false};
Int64 transition_id{0};
String modified_sequence;
bool has_precursor_charge{false};
Int64 precursor_charge{0};
bool has_product_charge{false};
Int64 product_charge{0};
bool has_detecting_transition{false};
Int64 detecting_transition{0};
bool has_precursor_decoy{false};
Int64 precursor_decoy{0};
bool has_product_decoy{false};
Int64 product_decoy{0};
bool has_transition_ordinal{false};
Int64 transition_ordinal{0};
String transition_type;
String annotation;

std::vector<double> rt;
std::vector<double> intensity;
};

/**
@brief Unique run information (run_id, source_file).
*/
struct XICRunInfo
{
Int64 run_id{0};
String source_file;
};

/**
@brief Analyte metadata container.

If @p nest_transitions is false in getAnalytes(), transition-level fields
are stored in the scalar members (transition_id, product_charge, etc.).
If @p nest_transitions is true, transition-level fields are stored in the
vector members (transition_ids, product_charges, etc.), with one entry
per unique transition belonging to the precursor.
*/
struct XICAnalyte
{
bool has_precursor_id{false};
Int64 precursor_id{0};
String modified_sequence;
bool has_precursor_charge{false};
Int64 precursor_charge{0};
bool has_precursor_decoy{false};
Int64 precursor_decoy{0};

bool has_transition_id{false};
Int64 transition_id{0};
bool has_product_charge{false};
Int64 product_charge{0};
bool has_transition_ordinal{false};
Int64 transition_ordinal{0};
bool has_detecting_transition{false};
Int64 detecting_transition{0};
bool has_product_decoy{false};
Int64 product_decoy{0};
String transition_type;
String annotation;

std::vector<Int64> transition_ids;
std::vector<Int64> product_charges;
std::vector<Int64> transition_ordinals;
std::vector<Int64> detecting_transitions;
std::vector<Int64> product_decoys;
std::vector<String> transition_types;
std::vector<String> annotations;
};

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.

⚠️ Potential issue | 🟠 Major

Export the nested public structs with OPENMS_DLLAPI.

These nested structs are part of the public API; without explicit export they can cause typeinfo/linkage issues on Windows.

🛠️ Suggested fix
-    struct XICChromatogram
+    struct OPENMS_DLLAPI XICChromatogram
     {
       Int64 run_id{0};
       String source_file;
       Int64 ms_level{0};
@@
-    struct XICRunInfo
+    struct OPENMS_DLLAPI XICRunInfo
     {
       Int64 run_id{0};
       String source_file;
     };
@@
-    struct XICAnalyte
+    struct OPENMS_DLLAPI XICAnalyte
     {
       bool has_precursor_id{false};
       Int64 precursor_id{0};
       String modified_sequence;

As per coding guidelines: Add OPENMS_DLLAPI macro to all non-template exported classes, structs, functions, and variables in headers.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@brief Lightweight chromatogram container for XIC parquet rows.
*/
struct XICChromatogram
{
Int64 run_id{0};
String source_file;
Int64 ms_level{0};
bool has_precursor_id{false};
Int64 precursor_id{0};
bool has_transition_id{false};
Int64 transition_id{0};
String modified_sequence;
bool has_precursor_charge{false};
Int64 precursor_charge{0};
bool has_product_charge{false};
Int64 product_charge{0};
bool has_detecting_transition{false};
Int64 detecting_transition{0};
bool has_precursor_decoy{false};
Int64 precursor_decoy{0};
bool has_product_decoy{false};
Int64 product_decoy{0};
bool has_transition_ordinal{false};
Int64 transition_ordinal{0};
String transition_type;
String annotation;
std::vector<double> rt;
std::vector<double> intensity;
};
/**
@brief Unique run information (run_id, source_file).
*/
struct XICRunInfo
{
Int64 run_id{0};
String source_file;
};
/**
@brief Analyte metadata container.
If @p nest_transitions is false in getAnalytes(), transition-level fields
are stored in the scalar members (transition_id, product_charge, etc.).
If @p nest_transitions is true, transition-level fields are stored in the
vector members (transition_ids, product_charges, etc.), with one entry
per unique transition belonging to the precursor.
*/
struct XICAnalyte
{
bool has_precursor_id{false};
Int64 precursor_id{0};
String modified_sequence;
bool has_precursor_charge{false};
Int64 precursor_charge{0};
bool has_precursor_decoy{false};
Int64 precursor_decoy{0};
bool has_transition_id{false};
Int64 transition_id{0};
bool has_product_charge{false};
Int64 product_charge{0};
bool has_transition_ordinal{false};
Int64 transition_ordinal{0};
bool has_detecting_transition{false};
Int64 detecting_transition{0};
bool has_product_decoy{false};
Int64 product_decoy{0};
String transition_type;
String annotation;
std::vector<Int64> transition_ids;
std::vector<Int64> product_charges;
std::vector<Int64> transition_ordinals;
std::vector<Int64> detecting_transitions;
std::vector<Int64> product_decoys;
std::vector<String> transition_types;
std::vector<String> annotations;
};
/**
`@brief` Lightweight chromatogram container for XIC parquet rows.
*/
struct OPENMS_DLLAPI XICChromatogram
{
Int64 run_id{0};
String source_file;
Int64 ms_level{0};
bool has_precursor_id{false};
Int64 precursor_id{0};
bool has_transition_id{false};
Int64 transition_id{0};
String modified_sequence;
bool has_precursor_charge{false};
Int64 precursor_charge{0};
bool has_product_charge{false};
Int64 product_charge{0};
bool has_detecting_transition{false};
Int64 detecting_transition{0};
bool has_precursor_decoy{false};
Int64 precursor_decoy{0};
bool has_product_decoy{false};
Int64 product_decoy{0};
bool has_transition_ordinal{false};
Int64 transition_ordinal{0};
String transition_type;
String annotation;
std::vector<double> rt;
std::vector<double> intensity;
};
/**
`@brief` Unique run information (run_id, source_file).
*/
struct OPENMS_DLLAPI XICRunInfo
{
Int64 run_id{0};
String source_file;
};
/**
`@brief` Analyte metadata container.
If `@p` nest_transitions is false in getAnalytes(), transition-level fields
are stored in the scalar members (transition_id, product_charge, etc.).
If `@p` nest_transitions is true, transition-level fields are stored in the
vector members (transition_ids, product_charges, etc.), with one entry
per unique transition belonging to the precursor.
*/
struct OPENMS_DLLAPI XICAnalyte
{
bool has_precursor_id{false};
Int64 precursor_id{0};
String modified_sequence;
bool has_precursor_charge{false};
Int64 precursor_charge{0};
bool has_precursor_decoy{false};
Int64 precursor_decoy{0};
bool has_transition_id{false};
Int64 transition_id{0};
bool has_product_charge{false};
Int64 product_charge{0};
bool has_transition_ordinal{false};
Int64 transition_ordinal{0};
bool has_detecting_transition{false};
Int64 detecting_transition{0};
bool has_product_decoy{false};
Int64 product_decoy{0};
String transition_type;
String annotation;
std::vector<Int64> transition_ids;
std::vector<Int64> product_charges;
std::vector<Int64> transition_ordinals;
std::vector<Int64> detecting_transitions;
std::vector<Int64> product_decoys;
std::vector<String> transition_types;
std::vector<String> annotations;
};
🤖 Prompt for AI Agents
In `@src/openms/include/OpenMS/FORMAT/XICParquetFile.h` around lines 63 - 143, The
three public structs XICChromatogram, XICRunInfo, and XICAnalyte must be
exported on Windows: add the OPENMS_DLLAPI macro to each struct declaration
(i.e., change "struct XICChromatogram", "struct XICRunInfo", and "struct
XICAnalyte" to "struct OPENMS_DLLAPI XICChromatogram", "struct OPENMS_DLLAPI
XICRunInfo", and "struct OPENMS_DLLAPI XICAnalyte") so their typeinfo and
symbols are properly exported for the public API.

Comment on lines +226 to +259
/**
@brief Return unique run metadata (run_id, source_file).

This method never decodes RT/intensity arrays and always returns distinct
rows.
*/
void getRuns(std::vector<XICRunInfo>& output) const;

/**
@brief Return unique analyte metadata.

If @p nest_transitions is false, each row represents a unique
precursor-transition pair. If @p nest_transitions is true, each row
represents a unique precursor with transition-level fields aggregated
into vectors.

This method never decodes RT/intensity arrays and always returns distinct
entries.

@param[out] output Output analyte metadata
@param[in] columns Optional list of analyte columns to return (empty for defaults)
@param[in] nest_transitions Aggregate transition fields per precursor
*/
void getAnalytes(std::vector<XICAnalyte>& output,
const std::vector<String>& columns,
bool nest_transitions = true) const;

/**
@brief Return the parquet schema column names.

@param[out] output Column names.
*/
void getColumns(std::vector<String>& output) const;

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.

⚠️ Potential issue | 🟡 Minor

Align getAnalytes signature with the “optional columns” doc.

The docs say columns are optional, but the signature requires an argument. Consider a default empty list (or update the doc).

💡 Suggested tweak
-    void getAnalytes(std::vector<XICAnalyte>& output,
-                     const std::vector<String>& columns,
-                     bool nest_transitions = true) const;
+    void getAnalytes(std::vector<XICAnalyte>& output,
+                     const std::vector<String>& columns = std::vector<String>(),
+                     bool nest_transitions = true) const;
🤖 Prompt for AI Agents
In `@src/openms/include/OpenMS/FORMAT/XICParquetFile.h` around lines 226 - 259,
The getAnalytes signature currently requires columns but the doc says they are
optional; change the declaration of getAnalytes in XICParquetFile.h to provide a
default empty vector for the columns parameter (e.g., const std::vector<String>&
columns = {}) and mirror the same default in the corresponding
definition/implementation (function named getAnalytes) so callers can omit the
argument; if you prefer not to add a default, instead update the doc comment to
remove the word "optional" and clarify that columns are required—ensure the
declaration, implementation, and docs remain consistent.

Comment thread src/topp/TextExporter.cpp
Comment on lines +1681 to +1683
ofstream outstr(out.c_str());
SVOutStream output(outstr, sep, replacement, quoting_method);
output.modifyStrings(false);

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.

⚠️ Potential issue | 🟡 Minor

Missing output file creation validation.

The mzML branch (lines 1574-1577) validates that the output file was successfully created. The CHROMPARQUET branch should include the same check for consistency and robustness.

🛡️ Proposed fix to add file creation validation
         ofstream outstr(out.c_str());
+        if (!outstr)
+        {
+          throw Exception::UnableToCreateFile(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, out);
+        }
         SVOutStream output(outstr, sep, replacement, quoting_method);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ofstream outstr(out.c_str());
SVOutStream output(outstr, sep, replacement, quoting_method);
output.modifyStrings(false);
ofstream outstr(out.c_str());
if (!outstr)
{
throw Exception::UnableToCreateFile(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, out);
}
SVOutStream output(outstr, sep, replacement, quoting_method);
output.modifyStrings(false);
🤖 Prompt for AI Agents
In `@src/topp/TextExporter.cpp` around lines 1681 - 1683, The CHROMPARQUET branch
creates an ofstream named outstr and immediately constructs an SVOutStream
(symbols: ofstream outstr(out.c_str()), SVOutStream output(...),
output.modifyStrings(false)) but doesn't validate that the output file was
successfully opened; add the same check used in the mzML branch after creating
outstr (e.g., test outstr.is_open() or outstr.fail()), and if the file open
failed emit a clear error/log and return/throw the same error path used by the
mzML branch so the function exits early instead of continuing with a bad stream.

When building pyOpenMS standalone via find_package(OpenMS), the
OPENMS_ARROW_TARGET variable is not available because it's only set
in cmake_findExternalLibs.cmake during the main OpenMS build and not
exported in OpenMSConfig.cmake.

This caused wheel builds to fail with:
  CMake Error at CMakeLists.txt:347 (get_target_property):
    get_target_property called with incorrect number of arguments

Add Arrow discovery logic to find the Arrow target when building
standalone with WITH_PARQUET enabled.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@timosachsenberg
timosachsenberg enabled auto-merge (squash) February 4, 2026 14:45
@timosachsenberg
timosachsenberg merged commit 6e67041 into develop Feb 4, 2026
40 of 41 checks passed
@timosachsenberg
timosachsenberg deleted the feat/xic_parquet_cpp branch February 4, 2026 14:45
timosachsenberg added a commit that referenced this pull request Feb 4, 2026
This PR adds Python bindings for reading XIC data from Parquet files,
enabling integration with pandas, pyarrow, and pyopenms_viz.

Additions:
- XICParquetFile Python bindings with:
  - list-of-files constructor support
  - get_data_dict, get_chromatograms, to_df, to_arrow
  - get_analyte_dict, get_analyte_df, get_run_dict, get_run_df
  - df_columns for column discovery
  - Filter expressions with predicate pushdown support
- ParquetFilter/ParquetFilterBuilder Python bindings for typed filter construction
- ParquetQuery/ChromatogramQuery for chainable querying
- Unit tests for Python bindings

Example usage:
```python
import pyopenms as poms
import glob

files = glob.glob('*.xic')
xic_h = poms.XICParquetFile(files)
xic_h.get_chromatograms(filter="precursor_id=1318 & annotation=y3^1").plot(
    kind="chromatogram", x="rt", y="intensity", by="source_file"
)
```

Depends on PR #8737 (C++ core).
Based on work from PR #8725 by @singjc.

Co-Authored-By: singjc <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
timosachsenberg added a commit that referenced this pull request Feb 5, 2026
* Add pyOpenMS bindings for XICParquetFile

This PR adds Python bindings for reading XIC data from Parquet files,
enabling integration with pandas, pyarrow, and pyopenms_viz.

Additions:
- XICParquetFile Python bindings with:
  - list-of-files constructor support
  - get_data_dict, get_chromatograms, to_df, to_arrow
  - get_analyte_dict, get_analyte_df, get_run_dict, get_run_df
  - df_columns for column discovery
  - Filter expressions with predicate pushdown support
- ParquetFilter/ParquetFilterBuilder Python bindings for typed filter construction
- ParquetQuery/ChromatogramQuery for chainable querying
- Unit tests for Python bindings

Example usage:
```python
import pyopenms as poms
import glob

files = glob.glob('*.xic')
xic_h = poms.XICParquetFile(files)
xic_h.get_chromatograms(filter="precursor_id=1318 & annotation=y3^1").plot(
    kind="chromatogram", x="rt", y="intensity", by="source_file"
)
```

Depends on PR #8737 (C++ core).
Based on work from PR #8725 by @singjc.

Co-Authored-By: singjc <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>

* Fix Windows pyOpenMS build: remove conflicting String cppclass import

Remove `from String cimport String` from XICParquetFile.pyx addon.

This import brought in the C++ cppclass declaration, which conflicts
with the autowrap-generated cdef class wrapper on Windows. The addon
uses `isinstance(x, String)` which requires the Python type (cdef class),
not the cppclass. The cdef class is already available in scope when
the addon is injected into the generated module.

Co-Authored-By: Claude Opus 4.5 <[email protected]>

---------

Co-authored-by: singjc <[email protected]>
Co-authored-by: Claude Opus 4.5 <[email protected]>
timosachsenberg added a commit that referenced this pull request Feb 5, 2026
…atograms (C++ core) (#8737)

* Add Parquet support for XIC chromatogram output (C++ core)

This PR adds support for OpenSWATH chromatogram Parquet files (.xic).
It introduces a Parquet writer for chromatograms, a reader with filtering
and predicate pushdown, and test coverage including TOPP regression checks.

The schema uses a similar (expanded) schema that was implemented in
PyProphet to convert the sqMass chromatograms to parquet. Adding parquet
xic output directly to OpenSwathWorkflow skips the additional extra
conversion step, and provides storage benefits from using parquet
compared to sqMass.

Additions:
- MSChromatogramParquetConsumer: writes .xic Parquet files with a
  PyProphet-compatible schema (metadata + compressed RT/intensity arrays)
- XICParquetFile: reads .xic files with filter expressions; supports
  multi-file input and Arrow Dataset predicate pushdown with compute fallback
- ParquetFilter: typed, chainable Parquet filter builder for predicate pushdown
- TextExporter: now supports .xic input, exporting summary or exploded
  TSV/CSV/TXT for testable text output
- OpenSwathWorkflow: added -out_chrom_ext xic option for Parquet output
- Unit and TOPP tests for the new functionality

Note: Python bindings will be added in a follow-up PR.

Based on work from PR #8725 by @singjc.

Co-Authored-By: singjc <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>

* Fix pyOpenMS standalone build when WITH_PARQUET is enabled

When building pyOpenMS standalone via find_package(OpenMS), the
OPENMS_ARROW_TARGET variable is not available because it's only set
in cmake_findExternalLibs.cmake during the main OpenMS build and not
exported in OpenMSConfig.cmake.

This caused wheel builds to fail with:
  CMake Error at CMakeLists.txt:347 (get_target_property):
    get_target_property called with incorrect number of arguments

Add Arrow discovery logic to find the Arrow target when building
standalone with WITH_PARQUET enabled.

Co-Authored-By: Claude Opus 4.5 <[email protected]>

---------

Co-authored-by: singjc <[email protected]>
Co-authored-by: Claude Opus 4.5 <[email protected]>
timosachsenberg added a commit that referenced this pull request Feb 13, 2026
…rrect references

Add 22 missing PR entries across all sections (TOPP tools, PyOpenMS,
OpenMS Library, Fixes, Build System) and fix two incorrect PR number
references (#8633→#8637 for SpectrumNativeIDParser, #8725→#8737/#8738
for XICParquetFile).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
timosachsenberg added a commit that referenced this pull request Feb 13, 2026
…rrect references (#8759)

Add 22 missing PR entries across all sections (TOPP tools, PyOpenMS,
OpenMS Library, Fixes, Build System) and fix two incorrect PR number
references (#8633→#8637 for SpectrumNativeIDParser, #8725→#8737/#8738
for XICParquetFile).

Co-authored-by: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant