Repository navigation
Conversation
- Introduced MSChromatogramParquetConsumer for writing chromatograms to Parquet files. - Updated OpenSwathBase to handle new output format options including xic (Parquet). - Enhanced FileTypes to include CHROMPARQUET type for chromatogram output. - Modified output file registration in OpenSwathWorkflow to support new formats. - Added source file references for MSChromatogramParquetConsumer in CMake configurations.
… handling for dataset filtering
…t, including libxml2 linking for dataset pushdown
…ctors and methods for improved file handling
… type checking and conversion
…on metadata columns with Arrow integration
…and method parameters in __init__, get_data_dict, to_df, and get_chromatograms
…ods for improved object representation and file count retrieval
…d XICParquetFile, including loading and filtering functionalities, and update executables list to include new tests.
…dimensional arrays and ensuring clean output
…files and improve output options
…d schema documentation for Parquet output and note schema dependency
…implement methods to retrieve unique runs and analytes, and update tests for new functionality
… handling for getRuns, getAnalytes, and getColumns
…uns, getAnalytes, and getColumns for improved exception handling
… and validation of chromatogram and analyte structures
…able types instead of list instances for transition fields and dataframes
…mum level for parquet file writing
…and Parquet chromatogram output support
…rt and Parquet chromatogram output support
📝 WalkthroughWalkthroughAdds Parquet XIC I/O: a C++ reader ( Changes
Sequence Diagram(s)sequenceDiagram
participant TOPP as TOPP/OpenSwathWorkflow
participant OpenSwathBase as OpenSwathBase
participant ParquetConsumer as MSChromatogramParquetConsumer
participant ArrowParquet as Arrow/Parquet IO
TOPP->>OpenSwathBase: prepareChromOutput(out_chrom="xic", source_file)
OpenSwathBase->>ParquetConsumer: construct(filename, run_id, source_file, transitions)
ParquetConsumer->>ArrowParquet: build Arrow schema & buffers
loop per chromatogram
ParquetConsumer->>ParquetConsumer: consumeChromatogram(data)
ParquetConsumer->>ArrowParquet: append rows
end
ParquetConsumer->>ArrowParquet: write Parquet file (finalize)
ArrowParquet-->>ParquetConsumer: file written
ParquetConsumer-->>OpenSwathBase: consumer ready
sequenceDiagram
participant Python as pyOpenMS client
participant XICReader as XICParquetFile
participant ArrowCompute as Arrow Compute/Dataset
participant ParquetFile as Parquet files
Python->>XICReader: construct(filenames)
Python->>XICReader: get_chromatograms(filters)
alt Dataset available
XICReader->>ArrowCompute: build/submit filter expression
ArrowCompute->>ParquetFile: read columns with pushdown
ParquetFile-->>ArrowCompute: filtered/decoded batches
ArrowCompute-->>XICReader: tables/rows
else Dataset unavailable
XICReader->>ParquetFile: read & filter in-memory
ParquetFile-->>XICReader: filtered rows
end
XICReader-->>Python: return chromatogram structs / arrays
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: 6
🤖 Fix all issues with AI agents
In `@src/openms/source/FORMAT/DATAACCESS/MSChromatogramParquetConsumer.cpp`:
- Around line 170-175: The destructor ~MSChromatogramParquetConsumerImpl
currently calls write_() which can throw and thus may cause std::terminate;
change it so the write_() invocation is wrapped in a try/catch that catches
Exception::FileNotWritable, Exception::InvalidValue and a generic Exception (or
std::exception) and logs the error instead of rethrowing, leaving wrote_
unchanged — do not propagate exceptions from the destructor and ensure the catch
block uses the project logger (same logging style as elsewhere) to report the
error.
In `@src/openms/source/FORMAT/XICParquetFile.cpp`:
- Around line 758-765: The code currently returns arrow::compute::literal(false)
for unknown cond.op values (e.g., in the function that maps cond.op to
arrow::compute operations in XICParquetFile.cpp), which silently filters out all
rows; change this to throw a descriptive exception (e.g., std::invalid_argument)
that includes the unsupported operator string (cond.op) so callers see an
explicit error instead of silent failure, and ensure existing valid operators
(including "IN" handling) remain unchanged.
- Around line 390-502: tokenize_: currently unclosed quoted strings (in_string
== true) at end of input silently drop the buffered current content; update
tokenize_ to detect this malformed input after the main loop and throw an
informative exception (e.g., std::runtime_error or OpenMS Exception) that
includes the quote_char and the partial current token so callers can diagnose
the error, rather than returning silently; ensure you reference the function
tokenize_, the variables in_string, quote_char, and current when implementing
the check and error message.
- Around line 300-314: Validate that the raw byte buffer length is a multiple of
sizeof(double) before resizing and memcpy in the switch cases handling
compression types 0 and 1; specifically, in the no-compression branch (using
data.size()) and the zlib branch (using decoded.size() after
ZlibCompression::uncompressString), check (size % sizeof(double) == 0) and
handle failures (e.g., log/error/throw) instead of proceeding to
output.resize/count and std::memcpy in XICParquetFile.cpp to avoid
partial/dangling reads.
In `@src/tests/topp/CMakeLists.txt`:
- Around line 1658-1659: The TextExporter test invocation in the add_test named
"TOPP_OpenSwathWorkflow_1_xic_text" should include the -test flag to produce
deterministic TSV output; update the TextExporter command invocation (the
add_test line that calls ${TOPP_BIN_PATH}/TextExporter for
OpenSwathWorkflow_1.chrom.tmp.xic) to add -test so generated TSV no longer
contains environment-specific metadata and the subsequent add_test that runs
${DIFF} can reliably compare outputs.
In `@src/topp/TextExporter.cpp`:
- Around line 1713-1759: The loop over chromatograms uses c.rt[i] and
c.intensity[i] without checking lengths; add a validation inside the chroms loop
(before computing Size n_points = c.rt.size() or at least before any indexing)
to verify c.rt.size() == c.intensity.size(), and if they differ fail fast by
throwing an Exception::Base-derived error (or Exception::IllegalArgument) with a
clear message (do not use the nonexistent INCOMPATIBLE_INPUT_DATA ExitStatus);
this ensures both the explode branch (the for i loop) and the non-explode
minmax/int access paths are protected from out-of-bounds indexing on
c.intensity.
🧹 Nitpick comments (11)
src/openms/CMakeLists.txt (1)
58-65: Keep LibXml2 private unless it’s required by public headers.
It’s already linked privately below; exposing it inOPENMS_DEP_LIBRARIESmakes it a transitive dependency. If no public API requires it, consider keeping it PRIVATE only.♻️ Suggested adjustment
set(OPENMS_DEP_LIBRARIES LibSVM::LibSVM XercesC::XercesC Qt6::Core Qt6::Network - # Needed when Arrow Dataset (pushdown) is enabled; avoids missing libxml2 symbols at runtime. - $<$<BOOL:${OPENMS_ARROW_DATASET_TARGET}>:LibXml2::LibXml2> )src/tests/class_tests/openms/source/XICParquetFile_test.cpp (1)
46-68: Consider adding an#elsebranch for consistency.The
loadtest section at lines 23-43 includes an#elsebranch to testMissingFeatureexception when Parquet is unavailable. This section lacks a corresponding#elsebranch for consistency. While not strictly required sinceload_invalid_pathsection covers the exception path, adding one would ensure consistent coverage across all test sections.src/pyOpenMS/tests/unittests/test_XICParquetFile.py (1)
9-24: Consider using a more robust path resolution approach.The
_repo_root()function navigates up 4 parent directories from the test file, which is fragile if the file is moved. Consider using an environment variable or a marker file (likepyproject.tomlor.git) to locate the repository root more reliably.Alternative using marker file detection
def _repo_root(): """Find repository root by looking for .git directory.""" current = os.path.dirname(os.path.abspath(__file__)) while current != os.path.dirname(current): # Stop at filesystem root if os.path.isdir(os.path.join(current, ".git")): return current current = os.path.dirname(current) # Fallback to original method return os.path.abspath( os.path.join(os.path.dirname(__file__), "..", "..", "..", "..") )src/pyOpenMS/converters/special_autowrap_conversionproviders.py (1)
503-517: Consider updatingStdSetStringConverterfor consistency.
StdVectorStringConverterwas updated to accept bothbytesandstr, butStdSetStringConverterstill only acceptsbytes(seetype_check_expressionat line 505 andinput_conversionat lines 514-516). For API consistency, consider applying the same changes here.Suggested changes for StdSetStringConverter
def type_check_expression(self, cpp_type, arg_var): return Code().add(""" - |isinstance($arg_var, set) and all(isinstance(i, bytes) for i in + |isinstance($arg_var, set) and all(isinstance(i, (bytes, str)) for i in + $arg_var) """, locals()).render() def input_conversion(self, cpp_type, argument_var, arg_num): temp_var = "v%d" % arg_num item = "item%d" % arg_num + bytes_var = "_b%d" % arg_num code = Code().add(""" |cdef libcpp_set[_String] * $temp_var = new libcpp_set[_String]() - |cdef bytes $item + |cdef object $item + |cdef bytes $bytes_var |for $item in $argument_var: - | $temp_var.insert(_String(<char *>$item)) + | if isinstance($item, bytes): + | $bytes_var = <bytes>$item + | else: + | $bytes_var = (<str>$item).encode() + | $temp_var.insert(_String(<char *>$bytes_var)) """, locals())src/openms/include/OpenMS/FORMAT/DATAACCESS/MSChromatogramParquetConsumer.h (1)
63-73: Add Doxygen@briefblocks for the new public methods.The class-level doc is solid, but the constructor and overrides are missing method-level Doxygen with
@brief/@param, which is required for public headers.As per coding guidelines: Add Doxygen comments for new public methods and classes.📝 Example doc additions
public: + /** + `@brief` Construct a Parquet chromatogram consumer. + + `@param`[in] filename Output .xic filename + `@param`[in] run_id Run identifier + `@param`[in] source_file Source mzML filename + `@param`[in] transition_exp Transition metadata + */ MSChromatogramParquetConsumer(const String& filename, UInt64 run_id, const String& source_file, const OpenSwath::LightTargetedExperiment& transition_exp); ~MSChromatogramParquetConsumer() override; + /// `@brief` Consume a spectrum (ignored for Parquet chromatogram output). void consumeSpectrum(SpectrumType& s) override; + /// `@brief` Consume a chromatogram and append it to the Parquet table. void consumeChromatogram(ChromatogramType& c) override; + /// `@brief` Reserve internal buffers for expected sizes. void setExpectedSize(Size expectedSpectra, Size expectedChromatograms) override; + /// `@brief` Set experimental settings (currently unused). void setExperimentalSettings(const ExperimentalSettings& exp) override;src/openms/include/OpenMS/FORMAT/XICParquetFile.h (1)
172-228: Fill in missing@brief/@PARAM documentation for public methods.
load,getAnalytes, andgetColumnsshould include@briefand@paramentries (notably thecolumnsparameter).As per coding guidelines: Use Doxygen documentation with `@brief` tag and `@param` for all parameters.📝 Doc patch
- /// Load all chromatograms from the file(s). - void load(std::vector<XICChromatogram>& output) const; + /** + `@brief` Load all chromatograms from the file(s). + + `@param`[out] output Output chromatograms + */ + void load(std::vector<XICChromatogram>& output) const; @@ - /** - `@brief` Return unique analyte metadata. + /** + `@brief` Return unique analyte metadata. @@ - `@param`[out] output Output analyte metadata - `@param`[in] nest_transitions Aggregate transition fields per precursor + `@param`[out] output Output analyte metadata + `@param`[in] columns Column subset 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. - */ + /** + `@brief` Return the parquet schema column names. + + `@param`[out] output Column names in schema order + */ void getColumns(std::vector<String>& output) const;src/pyOpenMS/pxds/XICParquetFile.pxd (1)
76-86: Declare the copy constructor in the .pxd binding.The C++ class defines a copy constructor, but it isn’t exposed in the binding. Please add it (and keep the default ctor absent if that’s intentional).
Based on learnings: Declare default and copy constructors in `.pxd` files; use `cimport` not Python `import` for Cython imports.✅ Binding alignment
cdef cppclass XICParquetFile: XICParquetFile(String filename) except + nogil # wrap-doc: # Reader for OpenSWATH chromatogram Parquet files (.xic). XICParquetFile(const StringList& filenames) except + nogil # wrap-doc: # Reader for multiple OpenSWATH chromatogram Parquet files (.xic). + XICParquetFile(const XICParquetFile&) except + nogilsrc/openms/source/FORMAT/XICParquetFile.cpp (4)
136-151: Minor: Silent column skipping may hide user errors.Missing columns are silently skipped (lines 141-144), only throwing when no columns match. Consider logging a warning when requested columns are not found in the schema, so users are aware of potential typos or schema mismatches.
💡 Optional: Add warning for missing columns
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\n"; + } }
274-280: Potential truncation ingetBinaryView_.
view.size()returnsint64_tbut is cast toInt(typically 32-bit). For binary blobs > 2GB this would overflow. While unlikely for chromatogram data, usingSize(or directly using the string view constructor) would be safer.💡 Suggested fix
String getBinaryView_(const std::shared_ptr<arrow::Array>& array, int64_t row) { auto typed = std::static_pointer_cast<arrow::BinaryArray>(array); const auto view = typed->GetView(row); - return String(view.data(), static_cast<Int>(view.size())); + return String(view.data(), view.size()); }
504-567: Silent handling of malformed filters.The parser silently handles malformed filters (e.g., column without operator on line 519, operator without value on lines 543-546). This could lead to unexpected filtering behavior. Consider throwing descriptive errors for invalid filter syntax.
💡 Suggested improvement
while (i < tokens.size()) { String column = upper_(tokens[i++]); - if (i >= tokens.size()) break; + if (i >= tokens.size()) + { + throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, + "Filter column '" + column + "' missing operator", filter); + } String op = upper_(tokens[i++]); // ... existing code ... else { if (i < tokens.size()) { cond.values.push_back(tokens[i++]); } + else + { + throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, + "Filter operator '" + op + "' missing value", filter); + } }
1028-1078: Unnecessary initial table read when dataset pushdown succeeds.The code reads the full table at line 1031, but if
WITH_ARROW_DATASETis enabled and the filter is non-empty,readParquetTableDataset_re-reads the files with predicate pushdown (line 1059). The initial read is wasted in this case.♻️ Suggested optimization
output.clear(); - auto table = readParquetTable_(filenames_); - std::unordered_map<String, ColumnType> column_types = { // ... column_types definition ... }; + std::shared_ptr<arrow::Table> table; bool used_dataset = false; `#ifdef` WITH_ARROW_DATASET if (!filter.empty()) { try { table = readParquetTableDataset_(filenames_, filter, column_types); used_dataset = true; } catch (const std::exception& e) { OPENMS_LOG_WARN << "Arrow Dataset filter failed, falling back to compute filter: " << e.what() << '\n'; used_dataset = false; } catch (...) { OPENMS_LOG_WARN << "Arrow Dataset filter failed, falling back to compute filter.\n"; used_dataset = false; } } `#endif` if (!used_dataset) { + table = readParquetTable_(filenames_); table = applyArrowFilter_(table, filter, column_types); }
… final link for XICParquet
… parquet files and improve test coverage for destructor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/pyOpenMS/CMakeLists.txt`:
- Around line 350-360: The current logic assumes OPENMS_ARROW_TARGET, but
get_target_property will fail if it names a non-existent target; before calling
get_target_property, add a validation block that checks if OPENMS_ARROW_TARGET
is set and the target does not exist (if(OPENMS_ARROW_TARGET AND NOT TARGET
${OPENMS_ARROW_TARGET})), then clear or unset OPENMS_ARROW_TARGET and allow the
existing detection logic (checking TARGET Arrow::arrow_shared /
Arrow::arrow_static and the FATAL_ERROR path) to run; update the error message
path to still trigger when no valid Arrow target is found so failures remain
clear.
| # Standalone builds may not export OPENMS_ARROW_TARGET via OpenMSConfig.cmake. | ||
| if(NOT OPENMS_ARROW_TARGET) | ||
| if(TARGET Arrow::arrow_shared) | ||
| set(OPENMS_ARROW_TARGET Arrow::arrow_shared) | ||
| elseif(TARGET Arrow::arrow_static) | ||
| set(OPENMS_ARROW_TARGET Arrow::arrow_static) | ||
| endif() | ||
| endif() | ||
| if(NOT OPENMS_ARROW_TARGET) | ||
| message(FATAL_ERROR "WITH_PARQUET=ON but no Arrow target is available (OPENMS_ARROW_TARGET unset, Arrow::arrow_* not found).") | ||
| endif() |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# Find all occurrences of OPENMS_ARROW_TARGET
rg -n "OPENMS_ARROW_TARGET" --type cmakeRepository: OpenMS/OpenMS
Length of output: 2160
🏁 Script executed:
# Check the context around line 363 where get_target_property is used
sed -n '360,370p' src/pyOpenMS/CMakeLists.txtRepository: OpenMS/OpenMS
Length of output: 425
🏁 Script executed:
# Check how OPENMS_ARROW_TARGET is initially set in cmake_findExternalLibs.cmake
sed -n '170,185p' cmake/cmake_findExternalLibs.cmakeRepository: OpenMS/OpenMS
Length of output: 680
🏁 Script executed:
# Check if there's an OpenMSConfig.cmake or similar that might set OPENMS_ARROW_TARGET
find . -name "*Config.cmake" -o -name "*config.cmake" | head -20Repository: OpenMS/OpenMS
Length of output: 134
🏁 Script executed:
# Check cmake/package_general.cmake around line 63 to see how OPENMS_ARROW_TARGET is exported
sed -n '58,75p' cmake/package_general.cmakeRepository: OpenMS/OpenMS
Length of output: 1109
🏁 Script executed:
# Check if there's an OpenMSConfig.cmake generation or export that might set OPENMS_ARROW_TARGET
rg -n "OPENMS_ARROW_TARGET" cmake/ | grep -E "(install|export|configure)"Repository: OpenMS/OpenMS
Length of output: 39
🏁 Script executed:
# Check for OpenMSConfigVersion.cmake or similar that might be generated
find cmake/ -name "*.cmake.in" -o -name "*Config*.cmake*" | xargs ls -la 2>/dev/nullRepository: OpenMS/OpenMS
Length of output: 412
🏁 Script executed:
# Check if OPENMS_ARROW_TARGET is exported in OpenMSConfig.cmake.in
cat cmake/OpenMSConfig.cmake.inRepository: OpenMS/OpenMS
Length of output: 2802
🏁 Script executed:
# Check what happens after get_target_property - see if there's error handling
sed -n '363,375p' src/pyOpenMS/CMakeLists.txtRepository: OpenMS/OpenMS
Length of output: 496
Add target validation before using OPENMS_ARROW_TARGET to provide clearer error messages.
The code currently only checks if OPENMS_ARROW_TARGET is empty, but get_target_property at line 363 will hard-fail with a cryptic CMake error if OPENMS_ARROW_TARGET is set to an invalid target name. Add explicit validation with if(OPENMS_ARROW_TARGET AND NOT TARGET ${OPENMS_ARROW_TARGET}) before the get_target_property call to catch misconfigured values and fall back to detection logic, ensuring predictable error handling.
🔧 Suggested robustness tweak
# Standalone builds may not export OPENMS_ARROW_TARGET via OpenMSConfig.cmake.
- if(NOT OPENMS_ARROW_TARGET)
+ if(OPENMS_ARROW_TARGET AND NOT TARGET ${OPENMS_ARROW_TARGET})
+ unset(OPENMS_ARROW_TARGET)
+ endif()
+ if(NOT OPENMS_ARROW_TARGET)
if(TARGET Arrow::arrow_shared)
set(OPENMS_ARROW_TARGET Arrow::arrow_shared)
elseif(TARGET Arrow::arrow_static)
set(OPENMS_ARROW_TARGET Arrow::arrow_static)
endif()
endif()
- if(NOT OPENMS_ARROW_TARGET)
+ if(NOT OPENMS_ARROW_TARGET)
message(FATAL_ERROR "WITH_PARQUET=ON but no Arrow target is available (OPENMS_ARROW_TARGET unset, Arrow::arrow_* not found).")
+ elseif(NOT TARGET ${OPENMS_ARROW_TARGET})
+ message(FATAL_ERROR "WITH_PARQUET=ON but OPENMS_ARROW_TARGET='${OPENMS_ARROW_TARGET}' is not a valid CMake target.")
endif()🤖 Prompt for AI Agents
In `@src/pyOpenMS/CMakeLists.txt` around lines 350 - 360, The current logic
assumes OPENMS_ARROW_TARGET, but get_target_property will fail if it names a
non-existent target; before calling get_target_property, add a validation block
that checks if OPENMS_ARROW_TARGET is set and the target does not exist
(if(OPENMS_ARROW_TARGET AND NOT TARGET ${OPENMS_ARROW_TARGET})), then clear or
unset OPENMS_ARROW_TARGET and allow the existing detection logic (checking
TARGET Arrow::arrow_shared / Arrow::arrow_static and the FATAL_ERROR path) to
run; update the error message path to still trigger when no valid Arrow target
is found so failures remain clear.
- Fix indentation in XICParquetFile.cpp getColumns() method - Add Doxygen for ParquetFilter::expression(), empty(), and merge() Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In `@src/openms/include/OpenMS/FORMAT/ParquetFilter.h`:
- Around line 60-67: The Doxygen example uses "using namespace OpenMS;" which
must be removed; update the example(s) (the ParquetFilter example and the other
example around lines 227-234) to fully qualify types and calls instead of
relying on a using directive — e.g., replace any unqualified ParquetFilter
instantiation and method usage with the fully qualified OpenMS::ParquetFilter
and keep eq("PRECURSOR_ID", 1318), andNext(), eq("ANNOTATION", "y3^1") calls as
shown but with the class name qualified; ensure no "using namespace OpenMS" or
using declarations remain in these header examples.
- Around line 79-208: The Doxygen tags in the ParquetFilter public API use plain
`@param` and missing `@return` and do not follow the required `@brief` + blank line
pattern; update every method declaration in ParquetFilter (e.g., andNext(),
orNext(), eq(const String&, Int64), ne(...), lt(...), le(...), gt(...), ge(...),
in(...), eq(const String&, const String&), in(const String&, const
std::vector<String>&), expression(), empty(), and the static merge(...)) and the
corresponding methods in ParquetFilterBuilder to: 1) use a `@brief` line followed
by a blank line then details, 2) change all parameter tags to `@param`[in] for
input-only parameters, and 3) add a `@return` description for fluent methods
returning ParquetFilter& (or the appropriate return type) so the generated docs
conform to the header documentation rules; apply this consistently across the
other ranges mentioned.
In `@src/openms/source/FORMAT/XICParquetFile.cpp`:
- Around line 568-585: The IN-clause parser in XICParquetFile.cpp (inside the
block checking op == "IN") currently proceeds when the closing ']' is missing
and can treat subsequent tokens as values; update the logic in that block (the
loop using tokens, i, and cond.values) to detect a missing closing ']' after the
while loop and, if not found (i >= tokens.size() or tokens[i] != "]"), throw
Exception::InvalidValue with a clear message like "IN operator missing closing
']'" (similar style to the existing error) so the parser fails fast instead of
accepting malformed filters.
- Around line 305-310: The getBinaryView_ function lacks a null-value guard and
can call GetView() on a NULL entry; update getBinaryView_ (in
XICParquetFile.cpp) to check array->IsNull(row) before calling GetView() and, if
null, throw the same form of descriptive exception used by other helpers (e.g.,
getOptionalInt_ / getOptionalString_) indicating a malformed Parquet file and
the invalid row so callers can handle it safely.
🧹 Nitpick comments (1)
src/openms/source/FORMAT/XICParquetFile.cpp (1)
116-118: PreferSizefor STL index in schema loop.This loop iterates over a
std::vectorand should use OpenMSSizeto stay consistent with core type guidelines.🔧 Suggested change
- for (size_t i = 1; i < filenames.size(); ++i) + for (Size i = 1; i < filenames.size(); ++i)As per coding guidelines, Use OpenMS primitive types from
OpenMS/CONCEPT/Types.h(e.g.,Size,SignedSize) instead of standard types likeint,unsigned intfor STL container sizes.
| @section ParquetFilter_Example Example | ||
| @code | ||
| using namespace OpenMS; | ||
|
|
||
| ParquetFilter f; | ||
| f.eq("PRECURSOR_ID", 1318) | ||
| .andNext() | ||
| .eq("ANNOTATION", "y3^1"); |
There was a problem hiding this comment.
Avoid using namespace OpenMS; in header examples.
Even in Doxygen examples, this conflicts with the header rule and encourages copy‑paste into headers. Please fully qualify the example types instead.
🔧 Example update (apply to both examples)
- using namespace OpenMS;
-
- ParquetFilter f;
+ OpenMS::ParquetFilter f;As per coding guidelines, Never add using namespace or using std::... declarations in header files.
Also applies to: 227-234
🤖 Prompt for AI Agents
In `@src/openms/include/OpenMS/FORMAT/ParquetFilter.h` around lines 60 - 67, The
Doxygen example uses "using namespace OpenMS;" which must be removed; update the
example(s) (the ParquetFilter example and the other example around lines
227-234) to fully qualify types and calls instead of relying on a using
directive — e.g., replace any unqualified ParquetFilter instantiation and method
usage with the fully qualified OpenMS::ParquetFilter and keep eq("PRECURSOR_ID",
1318), andNext(), eq("ANNOTATION", "y3^1") calls as shown but with the class
name qualified; ensure no "using namespace OpenMS" or using declarations remain
in these header examples.
| /** | ||
| @brief Combine the next condition with logical AND. | ||
| */ | ||
| ParquetFilter& andNext(); | ||
|
|
||
| /** | ||
| @brief Combine the next condition with logical OR. | ||
| */ | ||
| ParquetFilter& orNext(); | ||
|
|
||
| /** | ||
| @brief Add an equality condition for an integer column. | ||
| @param column Column name. | ||
| @param value Integer value to compare. | ||
| */ | ||
| ParquetFilter& eq(const String& column, Int64 value); | ||
|
|
||
| /** | ||
| @brief Add an inequality condition for an integer column. | ||
| @param column Column name. | ||
| @param value Integer value to compare. | ||
| */ | ||
| ParquetFilter& ne(const String& column, Int64 value); | ||
|
|
||
| /** | ||
| @brief Add a less-than condition for an integer column. | ||
| @param column Column name. | ||
| @param value Integer value to compare. | ||
| */ | ||
| ParquetFilter& lt(const String& column, Int64 value); | ||
|
|
||
| /** | ||
| @brief Add a less-than-or-equal condition for an integer column. | ||
| @param column Column name. | ||
| @param value Integer value to compare. | ||
| */ | ||
| ParquetFilter& le(const String& column, Int64 value); | ||
|
|
||
| /** | ||
| @brief Add a greater-than condition for an integer column. | ||
| @param column Column name. | ||
| @param value Integer value to compare. | ||
| */ | ||
| ParquetFilter& gt(const String& column, Int64 value); | ||
|
|
||
| /** | ||
| @brief Add a greater-than-or-equal condition for an integer column. | ||
| @param column Column name. | ||
| @param value Integer value to compare. | ||
| */ | ||
| ParquetFilter& ge(const String& column, Int64 value); | ||
|
|
||
| /** | ||
| @brief Add an IN condition for an integer column. | ||
| @param column Column name. | ||
| @param values Integer values to compare. | ||
| */ | ||
| ParquetFilter& in(const String& column, const std::vector<Int64>& values); | ||
|
|
||
| /** | ||
| @brief Add an equality condition for a string column. | ||
| @param column Column name. | ||
| @param value String value to compare. | ||
| */ | ||
| ParquetFilter& eq(const String& column, const String& value); | ||
|
|
||
| /** | ||
| @brief Add an inequality condition for a string column. | ||
| @param column Column name. | ||
| @param value String value to compare. | ||
| */ | ||
| ParquetFilter& ne(const String& column, const String& value); | ||
|
|
||
| /** | ||
| @brief Add a less-than condition for a string column. | ||
| @param column Column name. | ||
| @param value String value to compare. | ||
| */ | ||
| ParquetFilter& lt(const String& column, const String& value); | ||
|
|
||
| /** | ||
| @brief Add a less-than-or-equal condition for a string column. | ||
| @param column Column name. | ||
| @param value String value to compare. | ||
| */ | ||
| ParquetFilter& le(const String& column, const String& value); | ||
|
|
||
| /** | ||
| @brief Add a greater-than condition for a string column. | ||
| @param column Column name. | ||
| @param value String value to compare. | ||
| */ | ||
| ParquetFilter& gt(const String& column, const String& value); | ||
|
|
||
| /** | ||
| @brief Add a greater-than-or-equal condition for a string column. | ||
| @param column Column name. | ||
| @param value String value to compare. | ||
| */ | ||
| ParquetFilter& ge(const String& column, const String& value); | ||
|
|
||
| /** | ||
| @brief Add an IN condition for a string column. | ||
| @param column Column name. | ||
| @param values String values to compare. | ||
| */ | ||
| ParquetFilter& in(const String& column, const std::vector<String>& values); | ||
|
|
||
| /** | ||
| @brief Return the filter expression. | ||
| @return The constructed filter expression. | ||
| */ | ||
| const FilterExpression& expression() const; | ||
|
|
||
| /** | ||
| @brief Check if the filter is empty (has no conditions). | ||
| @return True if the filter has no conditions. | ||
| */ | ||
| bool empty() const; | ||
|
|
||
| /** | ||
| @brief Merge two filter expressions with a connector. | ||
| @param[in] lhs Left-hand side filter expression. | ||
| @param[in] rhs Right-hand side filter expression. | ||
| @param[in] connector Logical connector ("AND" or "OR"). | ||
| @return Combined filter expression. | ||
| */ | ||
| static FilterExpression merge(const FilterExpression& lhs, | ||
| const FilterExpression& rhs, | ||
| const String& connector = "AND"); |
There was a problem hiding this comment.
Use @param[in] (and @return) for the public fluent API docs.
These methods currently use @param without direction. Please switch to @param[in] and add @return for the fluent methods so the generated docs comply with header documentation rules. Apply this consistently across both ParquetFilter and ParquetFilterBuilder.
🔧 Example update (apply pattern across methods)
- /**
- `@brief` Add an equality condition for an integer column.
- `@param` column Column name.
- `@param` value Integer value to compare.
- */
+ /**
+ `@brief` Add an equality condition for an integer column.
+ `@param`[in] column Column name.
+ `@param`[in] value Integer value to compare.
+ `@return` Reference to this filter for chaining.
+ */
ParquetFilter& eq(const String& column, Int64 value);As per coding guidelines, Use Doxygen documentation with @brief tag (required), followed by blank line and details; use @param[in], @param[out], or @param[in,out] for all parameters.
Also applies to: 245-362
🤖 Prompt for AI Agents
In `@src/openms/include/OpenMS/FORMAT/ParquetFilter.h` around lines 79 - 208, The
Doxygen tags in the ParquetFilter public API use plain `@param` and missing
`@return` and do not follow the required `@brief` + blank line pattern; update every
method declaration in ParquetFilter (e.g., andNext(), orNext(), eq(const
String&, Int64), ne(...), lt(...), le(...), gt(...), ge(...), in(...), eq(const
String&, const String&), in(const String&, const std::vector<String>&),
expression(), empty(), and the static merge(...)) and the corresponding methods
in ParquetFilterBuilder to: 1) use a `@brief` line followed by a blank line then
details, 2) change all parameter tags to `@param`[in] for input-only parameters,
and 3) add a `@return` description for fluent methods returning ParquetFilter& (or
the appropriate return type) so the generated docs conform to the header
documentation rules; apply this consistently across the other ranges mentioned.
| /// Read a binary cell as a String view. | ||
| String getBinaryView_(const std::shared_ptr<arrow::Array>& array, int64_t row) | ||
| { | ||
| auto typed = std::static_pointer_cast<arrow::BinaryArray>(array); | ||
| const auto view = typed->GetView(row); | ||
| return String(view.data(), static_cast<Int>(view.size())); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cd /root/workspace && find . -name "XICParquetFile.cpp" -type fRepository: OpenMS/OpenMS
Length of output: 122
🏁 Script executed:
wc -l src/openms/source/FORMAT/XICParquetFile.cppRepository: OpenMS/OpenMS
Length of output: 105
🏁 Script executed:
sed -n '295,320p' src/openms/source/FORMAT/XICParquetFile.cppRepository: OpenMS/OpenMS
Length of output: 843
🏁 Script executed:
# Search for all calls to getBinaryView_
rg "getBinaryView_" src/openms/source/FORMAT/XICParquetFile.cpp -B 3 -A 3Repository: OpenMS/OpenMS
Length of output: 734
🏁 Script executed:
# Check IsNull() usage patterns in the same file
rg "IsNull|->IsNull" src/openms/source/FORMAT/XICParquetFile.cppRepository: OpenMS/OpenMS
Length of output: 216
🏁 Script executed:
# Check for error handling patterns with Arrow arrays
rg "array->Is" src/openms/source/FORMAT/XICParquetFile.cpp -A 2 -B 2Repository: OpenMS/OpenMS
Length of output: 773
🏁 Script executed:
# Verify OpenMS exception patterns
rg "Exception::InvalidValue" src/openms/source/FORMAT/ -A 2 | head -20Repository: OpenMS/OpenMS
Length of output: 1811
🏁 Script executed:
# Check if tests exist for XICParquetFile
find . -name "*XICParquetFile*test*" -o -name "*test*XICParquetFile*"Repository: OpenMS/OpenMS
Length of output: 172
🏁 Script executed:
# Look at the context where getBinaryView_ is called
sed -n '320,365p' src/openms/source/FORMAT/XICParquetFile.cppRepository: OpenMS/OpenMS
Length of output: 1715
🏁 Script executed:
# Check if existing tests cover NULL scenarios
grep -n "NULL\|IsNull\|null" src/tests/class_tests/openms/source/XICParquetFile_test.cpp | head -15Repository: OpenMS/OpenMS
Length of output: 39
Add null-value guard to getBinaryView_ to prevent undefined behavior with malformed files.
The method lacks input validation while similar methods in the same file (getOptionalInt_, getOptionalString_, etc.) all guard against NULL values using array->IsNull(row). Malformed Parquet files with NULL RT or intensity blobs will cause GetView() to trigger undefined behavior. Add the standard null check and throw a descriptive exception:
Suggested fix
String getBinaryView_(const std::shared_ptr<arrow::Array>& array, int64_t row)
{
+ if (!array || array->IsNull(row))
+ {
+ throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
+ "NULL value in required binary column", String(row));
+ }
auto typed = std::static_pointer_cast<arrow::BinaryArray>(array);
const auto view = typed->GetView(row);
return String(view.data(), static_cast<Int>(view.size()));
}🤖 Prompt for AI Agents
In `@src/openms/source/FORMAT/XICParquetFile.cpp` around lines 305 - 310, The
getBinaryView_ function lacks a null-value guard and can call GetView() on a
NULL entry; update getBinaryView_ (in XICParquetFile.cpp) to check
array->IsNull(row) before calling GetView() and, if null, throw the same form of
descriptive exception used by other helpers (e.g., getOptionalInt_ /
getOptionalString_) indicating a malformed Parquet file and the invalid row so
callers can handle it safely.
| if (op == "IN") | ||
| { | ||
| if (i < tokens.size() && tokens[i] == "[") ++i; | ||
| while (i < tokens.size() && tokens[i] != "]") | ||
| { | ||
| 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; | ||
| } |
There was a problem hiding this comment.
Reject IN clauses missing the closing ].
If the closing bracket is omitted, the parser currently treats connectors/columns as values, producing a silently malformed filter. Fail fast when the bracket is required.
🛠️ Suggested guard
- if (op == "IN")
- {
- if (i < tokens.size() && tokens[i] == "[") ++i;
- while (i < tokens.size() && tokens[i] != "]")
+ if (op == "IN")
+ {
+ const bool has_bracket = (i < tokens.size() && tokens[i] == "[");
+ if (has_bracket) ++i;
+ while (i < tokens.size() && tokens[i] != "]")
{
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 (has_bracket)
+ {
+ if (i >= tokens.size() || tokens[i] != "]")
+ {
+ throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
+ "Missing closing ] for IN clause", filter);
+ }
+ ++i;
+ }
}🤖 Prompt for AI Agents
In `@src/openms/source/FORMAT/XICParquetFile.cpp` around lines 568 - 585, The
IN-clause parser in XICParquetFile.cpp (inside the block checking op == "IN")
currently proceeds when the closing ']' is missing and can treat subsequent
tokens as values; update the logic in that block (the loop using tokens, i, and
cond.values) to detect a missing closing ']' after the while loop and, if not
found (i >= tokens.size() or tokens[i] != "]"), throw Exception::InvalidValue
with a clear message like "IN operator missing closing ']'" (similar style to
the existing error) so the parser fails fast instead of accepting malformed
filters.
| set(OPENMS_DOC_DIR "@PACKAGE_INSTALL_DOC_DIR@") | ||
| set(OPENMS_LIB_DIR "@PACKAGE_INSTALL_LIB_DIR@") | ||
|
|
||
| # Feature flags from build configuration |
There was a problem hiding this comment.
Hmm good point. We haven't really thought about this yet.
Ideally we should pass this as PUBLIC target_compile_definitions to the OpenMS/SWATH target, such that it gets passed to downstream targets and the exported Cmake targets file automatically.
Alternatively, one might be able to access this already by including the OpenMS_config.h which should be configured by CMake and should be part of the distributed headers.
This might be fine for now but not ideal.
| elseif(TARGET Arrow::arrow_compute_shared) | ||
| set(OPENMS_ARROW_COMPUTE_TARGET Arrow::arrow_compute_shared) | ||
| else() | ||
| # Fallback: compute might be a plain library without a CMake target. |
There was a problem hiding this comment.
Did you actually encounter this? If so, do you have some more info on where this happens?
|
|
||
| if(OPENMS_ARROW_DATASET_TARGET) | ||
| message(STATUS "Using Arrow Dataset target: ${OPENMS_ARROW_DATASET_TARGET}") | ||
| # Arrow Dataset (static) may pull in libxml2 symbols; link explicitly. |
There was a problem hiding this comment.
Can we limit it to static Arrow then? Maybe report upstream, too?
| eol-bspline | ||
| ) | ||
|
|
||
| if (WITH_PARQUET) |
There was a problem hiding this comment.
Wait. Why twice? I think they should be either PUBLIC or PRIVATE but not both. Ideally private if we do not leak symbols.
| if(NOT TARGET OpenMS) | ||
| # Standalone build - find installed/built OpenMS | ||
| # Ensure Arrow targets are available if OpenMS was built with Parquet support. | ||
| find_package(Arrow QUIET) |
There was a problem hiding this comment.
This should be done in the OpenMS exported CMake config with a find_dependency call to also make sure a compatible Arrow version is found. But I am wondering why we suddenly need that. Are we exposing arrow symbols from OpenMS now? Can this be avoided?
|
I will try to make it private. the issue is arrow::table is exposed for pyopenms bindings. but it should be possible via the C interface |
- Remove exportSpectraToArrow() and exportChromatogramsToArrow() from public ArrowExport API, move to anonymous namespace as internal functions - Remove arrow::Table forward declaration from ArrowExport.h - Change Arrow linking from PUBLIC to PRIVATE in OpenMS CMakeLists.txt - Remove find_package(Arrow) from pyOpenMS CMakeLists.txt (no longer needed) - Update ArrowExport_test.cpp to use C Data Interface with helper functions - Fix linker errors when WITH_PARQUET=OFF: - Move XICParquetFile.cpp into WITH_PARQUET guard in sources.cmake - Add WITH_PARQUET guard for MSChromatogramParquetConsumer.cpp This addresses review feedback about Arrow symbol leakage - downstream consumers no longer need Arrow headers or link targets. Co-Authored-By: Claude Opus 4.5 <[email protected]>
pyOpenMS builds its own Arrow-based Cython modules (arrow_zerocopy, parquet_filter) when WITH_PARQUET=ON, so it needs Arrow targets directly for standalone/wheel builds. The previous commit incorrectly removed find_package(Arrow) entirely. Now Arrow is only searched when WITH_PARQUET is enabled. Co-Authored-By: Claude Opus 4.5 <[email protected]>
…path The addition of PYOPENMS_SRC_DIR to Cython's include directories was causing 'String' redeclared errors on Windows. When the source directory is in the include path, Cython finds both the original String.pxd (with cdef cppclass String) and the autowrap-generated _pyopenms_N.pxd (with cdef class String), treating them as conflicting declarations. Revert to using only autowrap's generated include directories. Co-Authored-By: Claude Opus 4.5 <[email protected]>
| def type_check_expression(self, cpp_type, arg_var): | ||
| return Code().add(""" | ||
| |isinstance($arg_var, list) and all(isinstance(i, bytes) for i in | ||
| |isinstance($arg_var, list) and all(isinstance(i, (bytes, str)) for i in |
There was a problem hiding this comment.
Hmm.. first of all, I am a bit worried about feature creep. I think one can do list of strings in 100 ways in autowrap now.
Second, this won't type correctly (see matching_python_type_full above) when used as an output type so in theory you would need another conversion provider or introduce asymmetric typing for conversion providers in autowrap.
Third, note that for long lists this can be some runtime penalty.
| if not WITH_PARQUET: | ||
| pxd_files = [f for f in pxd_files if not os.path.basename(f).startswith('Arrow')] | ||
| print("WITH_PARQUET is disabled, excluding Arrow*.pxd files from wrapping") | ||
| def _is_parquet_related(name): |
There was a problem hiding this comment.
Hmm I did not see this before. I think @timosachsenberg introduced it.
I think it is fine for now but we should really rethink modularization before adding more conditional compilation stuff.
There was a problem hiding this comment.
The issue is that these files get automatically parsed otherwise.
There was a problem hiding this comment.
I know. But maybe it could be in a separate folder or in a specific module that depends on arrow etc., not one huge thing where you have to apply surgery to all the things that dont work when certain dependencies are missing.
There was a problem hiding this comment.
ok. I think this would also be easier with nanobind as it is cmake based and we could have proper macros to exclude them.
| from String cimport String | ||
| from StringList cimport StringList |
There was a problem hiding this comment.
maybe somewhere here is the issue?
| from XICParquetFile cimport XICRunInfo as _XICRunInfo | ||
| from ParquetFilter cimport ParquetFilterBuilder as _CppParquetFilterBuilder | ||
| from pyopenms._parquet_filter cimport ParquetFilterBuilder as _PyParquetFilterBuilder | ||
| from ._pyopenms_1 cimport convString, convOutputString |
There was a problem hiding this comment.
Or the combination with here.
|
ok let's first split the C++ part in this PR and get it merged. and have another PR for python |
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]>
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]>
…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]>
Thanks for splitting into separate PRs. Can probably close this when ready, in favour of the split PRs. For the python bindings, I think there is some circular issue with the String imports and the autowrapped pxd/pyx files for XICParquetFile, ParquetFilter and the _parquet_filter. Wasn't sure why it only failed compilation for Windows though, and not linux and macos. |
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]>
* 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]>
…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]>
…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]>
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, pyOpenMS bindings with DataFrame/Arrow helpers, 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.
Additions:
.xicParquet files with a PyProphet‑compatible schema (metadata + compressed RT/intensity arrays)..xicfiles with filter expressions; supports multi‑file input and Arrow Dataset predicate pushdown with compute fallback.XICParquetFilewith:get_data_dict,get_chromatograms,to_df,to_arrow,get_analyte_dict,get_analyte_df,get_run_dict,get_run_df,df_columns.xicinput, exporting summary or exploded TSV/CSV/TXT for testable text output. This was added so we can convert the XIC parquet to a tsv file for regression tests.pyOpenMS
Added bindings to load the XICs from the parquet file using pyopenms, which includes using predicate push downs for filtering the data prior to loading into memory. This also integrates nicely with pyopenms_viz.
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