Skip to content

Rename QuantmsIO to QPXFile with new QPX implementation - #8756

Merged
timosachsenberg merged 7 commits into
developfrom
feature/rename-quantmsio-to-qpxfile
Feb 13, 2026
Merged

timosachsenberg merged 7 commits into
developfrom
feature/rename-quantmsio-to-qpxfile

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Feb 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Renames QuantmsIO → QPXFile and QuantmsIOConverter → QPXConverter for consistency with existing QPX components (ConsensusMapArrowExport, Python to_psm_qpx())
  • Rewrites the PSM Parquet export using the newer QPX pattern from ConsensusMapArrowExport, replacing the old QuantmsIO implementation
  • Key improvements:
    • ProForma canonical peptidoform notation (replaces bracket substitution hack)
    • Structured modifications with UniMod accessions (list<struct{name, accession, positions}>)
    • Structured additional_scores using Scores::isKnownScoreType() (list<struct{score_name, score_value, higher_better}>)
    • protein_accessions as list<utf8> (was comma-separated string or null)
    • float64 precision for PEP, calculated_mz, observed_mz, rt (was float32)
    • Correct calculated_mz via seq.getMZ(charge) (was getMonoWeight())
    • Scan extraction from native IDs via SpectrumNativeIDParser
    • Nullable is_decoy (null when target_decoy metavalue missing, was always 0/1)
    • psm_metavalues / spectrum_metavalues structured columns
    • QPX file metadata in Parquet key-value metadata matching Python to_psm_qpx()
    • Static API (exportToArrow/exportToParquet) matching ConsensusMapArrowExport pattern
    • ParquetWriteConfig support with ZSTD compression

Test plan

  • QPXFile_test passes (4 test sections: exportToArrow, export_all_psms, exportToParquet with metadata verification, structured modifications)
  • QPXConverter TOPP tool builds successfully
  • CI build and test suite
  • Verify no stale QuantmsIO references remain (grep -r "QuantmsIO" src/ doc/ returns empty)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added export_all_psms flag to control exporting all PSMs or best-hit only.
    • New QPX export path: produces Arrow/Parquet PSM files with rich QPX metadata and schema; Python binding added for Parquet export.
  • Refactor

    • Renamed/rebranded the PSM-to-Parquet converter from QuantmsIOConverter to QPXConverter and replaced the legacy converter implementation.
  • Tests

    • Added comprehensive QPX export tests; legacy QuantmsIO tests removed.

Replace the old QuantmsIO class and QuantmsIOConverter TOPP tool with
QPXFile and QPXConverter, using the newer QPX export pattern from
ConsensusMapArrowExport. Key improvements over the old QuantmsIO:

- ProForma canonical peptidoform notation (not bracket substitution)
- Structured modifications with UniMod accessions
  (list<struct{name, accession, positions}>)
- Structured additional_scores with higher_better flag
  (list<struct{score_name, score_value, higher_better}>)
- protein_accessions as list<utf8> (not comma-separated string)
- float64 precision for PEP, calculated_mz, observed_mz, rt
- calculated_mz via seq.getMZ(charge) (correct m/z calculation)
- Scan extraction from native IDs via SpectrumNativeIDParser
- Nullable is_decoy (null when target_decoy metavalue missing)
- predicted_rt and ion_mobility from metavalues
- psm_metavalues and spectrum_metavalues structured columns
- OpenMS-specific columns: spectrum_reference, score, score_type,
  rank (0-based), P_ID
- QPX file metadata in Parquet key-value metadata matching
  Python to_psm_qpx() output
- Static API (exportToArrow/exportToParquet) matching
  ConsensusMapArrowExport pattern
- ParquetWriteConfig support with ZSTD compression
- Builder capacity reservation for OOM safety

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

coderabbitai Bot commented Feb 12, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Replaces the QuantmsIO exporter and TOPP tool with a new QPX implementation: adds OpenMS::QPXFile (Arrow builder + Parquet writer), new TOPP tool QPXConverter, tests and pybind declarations, updates build/docs/changelog, and removes QuantmsIO and its tests.

Changes

Cohort / File(s) Summary
Core PSM export
src/openms/include/OpenMS/FORMAT/QPXFile.h, src/openms/source/FORMAT/QPXFile.cpp, src/openms/include/OpenMS/FORMAT/QuantmsIO.h (removed), src/openms/source/FORMAT/QuantmsIO.cpp (removed)
Adds OpenMS::QPXFile with exportToArrow and exportToParquet (Arrow schema, nested fields, file metadata, Parquet writer config); removes legacy OpenMS::QuantmsIO header and implementation.
TOPP tool & CLI
src/topp/QPXConverter.cpp, src/topp/executables.cmake, doc/CMakeLists.txt, doc/doxygen/public/TOPP.doxygen
Renames tool QuantmsIOConverter → QPXConverter, updates CLI/doc includes/placeholders, switches include to QPXFile.h, and adds export_all_psms CLI flag; calls QPXFile::exportToParquet.
Build, sources & registry
src/openms/source/FORMAT/sources.cmake, src/openms/include/OpenMS/FORMAT/sources.cmake, src/openms/source/APPLICATIONS/ToolHandler.cpp, src/topp/executables.cmake
Updates source lists, headers, and tool registry entries under WITH_PARQUET to reference QPXFile/QPXConverter instead of QuantmsIO/QuantmsIOConverter.
Tests
src/tests/class_tests/openms/source/QPXFile_test.cpp, src/tests/class_tests/openms/source/QuantmsIO_test.cpp (removed), src/tests/class_tests/openms/CMakeLists.txt, src/tests/class_tests/openms/executables.cmake
Adds comprehensive QPXFile unit tests (Arrow schema checks, Parquet round-trip, metadata, multi-PSM handling); removes legacy QuantmsIO tests and updates test targets to QPXFile_test.
Python bindings / wrapping
src/pyOpenMS/pxds/QPXFile.pxd, src/pyOpenMS/create_cpp_extension.py
Adds Cython pxd for QPXFile::exportToParquet and updates autowrap filter to exclude QPXFile.pxd when WITH_PARQUET is disabled.
Docs & changelog
CHANGELOG_PARAMS, doc/CMakeLists.txt, doc includes
Renames documented tool references and placeholder HTML from QuantmsIOConverter → QPXConverter and updates referenced doc filenames.

Sequence Diagram(s)

sequenceDiagram
  participant TOPP as "TOPP QPXConverter"
  participant QPX as "OpenMS::QPXFile"
  participant Arrow as "Arrow Table Builder"
  participant Parquet as "Parquet Writer"
  participant FS as "Filesystem"

  TOPP->>QPX: exportToParquet(protein_ids, peptide_ids, filename, export_all_psms, config)
  QPX->>Arrow: exportToArrow(protein_ids, peptide_ids, export_all_psms)
  Arrow-->>QPX: arrow::Table
  QPX->>Parquet: configure writer (compression, pagesize, stats)
  QPX->>Parquet: write(arrow::Table, filename)
  Parquet->>FS: create/write file
  Parquet-->>QPX: success/failure
  QPX-->>TOPP: return success/failure (log result)
Loading

Possibly related PRs

Suggested reviewers

  • jpfeuffer

Poem

🐇 I nibble bytes and hop through rows,
QPX arrives where QuantmsIO goes.
Arrow builds and Parquet sings,
PSMs snug in tidy things.
Hooray — export done, the rabbit bows!

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary change: renaming QuantmsIO to QPXFile and implementing a new QPX export mechanism, which aligns with the detailed changeset across header files, source implementations, TOPP tools, and tests.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into develop

✏️ 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 feature/rename-quantmsio-to-qpxfile

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

🤖 Fix all issues with AI agents
In `@src/openms/include/OpenMS/FORMAT/QPXFile.h`:
- Around line 1-83: Add a pyOpenMS .pxd for QPXFile so the new C++ API is
exposed to Python: create src/pyOpenMS/pxds/QPXFile.pxd with a cdef extern from
block declaring the OpenMS::QPXFile class and its two static methods
exportToArrow and exportToParquet, and include/forward-declare needed types
(QPXFile, exportToArrow, exportToParquet, ParquetWriteConfig,
PeptideIdentificationList, ProteinIdentification and arrow::Table equivalents)
following existing .pxd patterns to match signatures so the bindings generator
picks them up.

In `@src/openms/source/APPLICATIONS/ToolHandler.cpp`:
- Around line 162-164: Add a pyOpenMS binding stub named QPXFile.pxd for the new
public class QPXFile so Python bindings match other file format classes; create
the .pxd with the same conditional compilation guards (`#ifdef` WITH_PARQUET ...
`#endif`) and declare the QPXFile class signature (matching
src/openms/include/OpenMS/FORMAT/QPXFile.h) so the bindings are generated when
WITH_PARQUET is enabled and omitted otherwise.

In `@src/openms/source/FORMAT/QPXFile.cpp`:
- Around line 366-367: The observed_mz field is being appended unconditionally
via observed_mz_builder.Append(pep_id.getMZ()); add the same NaN guard used for
RT (e.g., check that mz == mz or use std::isnan) before calling
observed_mz_builder.Append so NaN values are not written; locate the append call
in QPXFile.cpp (observed_mz_builder.Append and pep_id.getMZ) and wrap it with
the NaN check so it only appends when the MZ is valid.
- Around line 666-670: The code uses std::gmtime(&time_t) to format
creation_date which is not thread-safe; replace it with a thread-safe variant by
creating a local struct tm (e.g., struct tm tm_buf) and calling the reentrant
function (gmtime_r on POSIX or gmtime_s on Windows) to populate tm_buf, then
pass &tm_buf to std::put_time instead of std::gmtime(&time_t); update the block
around now/time_t/date_ss (the creation_date generation in QPXFile.cpp /
exportToParquet) to use this local tm buffer and conditional compilation to pick
gmtime_r vs gmtime_s for portability.

In `@src/tests/class_tests/openms/source/QPXFile_test.cpp`:
- Around line 143-146: The test uses a weak assertion comparing
mod_pf.find("PEPTIDER") to npos which is meaningless because the expected base
sequence is "PEMTIDER"; instead assert that the ProForma string from
pf_arr->GetString(1) contains modification notation (e.g., '[' or ']') and is
non-empty. Update the assertion(s) that reference mod_pf and
pf_arr->GetString(1) to check for presence of '[' (or a UNIMOD tag) and/or that
mod_pf != base sequence to ensure a modification was applied, replacing the
current TEST_EQUAL(mod_pf.find("PEPTIDER") == std::string::npos, true) with a
check that mod_pf.find('[') != std::string::npos (and keep
TEST_EQUAL(mod_pf.empty(), false)).
🧹 Nitpick comments (4)
src/tests/class_tests/openms/source/QPXFile_test.cpp (1)

34-181: Good coverage of the basic export path.

The test validates schema structure, column names, data types, and key field values effectively. Consider also adding a spot-check on calculated_mz (e.g., verifying against AASequence::fromString("PEPTIDER").getMZ(2)) to confirm the getMZ(charge) calculation that replaced the old getMonoWeight() logic.

src/topp/QPXConverter.cpp (1)

82-124: Consider adding ProgressLogger for progress reporting.

The main_() method performs file I/O and potentially heavy export operations on large datasets but doesn't use ProgressLogger. As per coding guidelines, TOPP command-line tools should use ProgressLogger for progress reporting.

♻️ Suggested ProgressLogger integration
   ExitCodes main_(int, const char**) override
   {
+    ProgressLogger progress_logger;
+    progress_logger.setLogType(log_type_);
+
     //-------------------------------------------------------------
     // parsing parameters
     //-------------------------------------------------------------
     const String in = getStringOption_("in");
     const String out = getStringOption_("out");
     const bool export_all = getFlag_("export_all_psms");

     // ... loading ...

+    progress_logger.startProgress(0, 1, "Exporting to QPX Parquet...");
     OPENMS_LOG_INFO << "Converting to parquet format..." << endl;
     if (!QPXFile::exportToParquet(protein_identifications, peptide_identifications, out, export_all))
     {
       OPENMS_LOG_ERROR << "Failed to write Parquet file: " << out << endl;
       return CANNOT_WRITE_OUTPUT_FILE;
     }
+    progress_logger.endProgress();

As per coding guidelines: "Use ProgressLogger in command-line tools for progress reporting to users."

src/openms/source/FORMAT/QPXFile.cpp (2)

54-647: exportToArrow is very complex (~600 lines, flagged by static analysis).

This single method handles builder initialization, capacity reservation, data iteration with nested modification extraction, score detection, metavalue filtering, array finalization, and schema construction. Consider extracting cohesive sections into private helper functions in a follow-up:

  • Modification extraction (lines 242-324) → e.g., buildModifications(...)
  • Metavalue extraction (lines 494-545) → e.g., buildMetavalues(...)
  • Array finalization (lines 551-606) could be streamlined with a helper

This would improve readability and testability without changing behavior.


705-727: Compression switch lacks a default case.

While all five ParquetWriteConfig::Compression enum values are handled, adding a default branch (or a compile-time assertion) would guard against future enum extensions silently falling through without compression being set.

♻️ Suggested defensive default
     case ParquetWriteConfig::Compression::ZSTD:
       builder.compression(arrow::Compression::ZSTD);
       builder.compression_level(config.compression_level);
       break;
+    default:
+      OPENMS_LOG_WARN << "QPXFile: Unknown compression type, defaulting to ZSTD" << std::endl;
+      builder.compression(arrow::Compression::ZSTD);
+      builder.compression_level(config.compression_level);
+      break;
   }

Comment on lines +1 to +83
// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
// SPDX-License-Identifier: BSD-3-Clause
//
// --------------------------------------------------------------------------
// $Maintainer: Timo Sachsenberg $
// $Authors: Timo Sachsenberg $
// --------------------------------------------------------------------------

#pragma once

#include <OpenMS/config.h>

#ifdef WITH_PARQUET

#include <OpenMS/CONCEPT/Types.h>
#include <OpenMS/METADATA/ProteinIdentification.h>
#include <OpenMS/METADATA/PeptideIdentification.h>
#include <OpenMS/METADATA/PeptideIdentificationList.h>
#include <OpenMS/FORMAT/MSExperimentArrowExport.h>

#include <memory>
#include <vector>

// Forward declarations
namespace arrow
{
class Table;
}

namespace OpenMS
{

/**
@brief Export PSM (Peptide Spectrum Match) data to Apache Arrow format following QPX PSM schema

This class provides static methods to export PeptideIdentification/ProteinIdentification
data to Apache Arrow Tables and Parquet files. The schema follows the QPX (Quantitative
Proteomics Exchange) PSM format.

@experimental This API is experimental and may change in future versions.

@ingroup FileIO
*/
class OPENMS_DLLAPI QPXFile
{
public:
/**
@brief Export PSM data to Apache Arrow Table

Exports peptide spectrum matches following the QPX PSM schema. Each
PeptideHit becomes one row with identification, score, and metadata.

@param[in] protein_identifications Vector of protein identifications
@param[in] peptide_identifications List of peptide identifications
@param[in] export_all_psms If true, export all hits per spectrum (default: false, only best hit)
@return Shared pointer to Arrow Table, or nullptr on error
*/
static std::shared_ptr<arrow::Table> exportToArrow(
const std::vector<ProteinIdentification>& protein_identifications,
const PeptideIdentificationList& peptide_identifications,
bool export_all_psms = false);

/**
@brief Export PSM data to Parquet file

@param[in] protein_identifications Vector of protein identifications
@param[in] peptide_identifications List of peptide identifications
@param[in] filename Output file path
@param[in] export_all_psms If true, export all hits per spectrum (default: false, only best hit)
@param[in] config Parquet writing options
@return true on success, false on error
*/
static bool exportToParquet(
const std::vector<ProteinIdentification>& protein_identifications,
const PeptideIdentificationList& peptide_identifications,
const String& filename,
bool export_all_psms = false,
const ParquetWriteConfig& config = ParquetWriteConfig{});
};

} // namespace OpenMS

#endif // WITH_PARQUET

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if QPXFile.pxd exists for pyOpenMS bindings
echo "=== Checking for QPXFile.pxd ==="
fd "QPXFile.pxd" --type f

# Check if old QuantmsIO.pxd still exists
echo "=== Checking for stale QuantmsIO.pxd ==="
fd "QuantmsIO.pxd" --type f

# Check executables.cmake for QPXConverter registration
echo "=== Checking executables.cmake for QPXConverter ==="
rg -n "QPXConverter" src/topp/executables.cmake 2>/dev/null || echo "QPXConverter not found in executables.cmake"

# Check ToolHandler.cpp for QPXConverter registration
echo "=== Checking ToolHandler.cpp for QPXConverter ==="
rg -n "QPXConverter" src/openms/source/APPLICATIONS/ToolHandler.cpp 2>/dev/null || echo "QPXConverter not found in ToolHandler.cpp"

# Check for any stale QuantmsIO references
echo "=== Checking for stale QuantmsIO references ==="
rg -n "QuantmsIO" --type cpp --type cmake -g '!CHANGELOG*' 2>/dev/null | head -30

Repository: OpenMS/OpenMS

Length of output: 400


Header looks well-structured, but .pxd file for pyOpenMS bindings is missing.

The class follows conventions: Doxygen documentation, OPENMS_DLLAPI, forward declarations, and parameter annotations are all correct. The WITH_PARQUET guard properly wraps the entire class.

However, a corresponding .pxd file must be created at src/pyOpenMS/pxds/QPXFile.pxd to expose this new public API to Python bindings. Per project guidelines, all C++ API changes require corresponding pyOpenMS bindings. The tool registration for QPXConverter in src/topp/executables.cmake (line 159) and src/openms/source/APPLICATIONS/ToolHandler.cpp (line 163) is already in place, and no stale QuantmsIO references remain.

Create the .pxd file following the OpenMS pattern: declare the C++ class with cdef extern from and expose the two static methods (exportToArrow and exportToParquet).

🤖 Prompt for AI Agents
In `@src/openms/include/OpenMS/FORMAT/QPXFile.h` around lines 1 - 83, Add a
pyOpenMS .pxd for QPXFile so the new C++ API is exposed to Python: create
src/pyOpenMS/pxds/QPXFile.pxd with a cdef extern from block declaring the
OpenMS::QPXFile class and its two static methods exportToArrow and
exportToParquet, and include/forward-declare needed types (QPXFile,
exportToArrow, exportToParquet, ParquetWriteConfig, PeptideIdentificationList,
ProteinIdentification and arrow::Table equivalents) following existing .pxd
patterns to match signatures so the bindings generator picks them up.

Comment on lines 162 to 164
#ifdef WITH_PARQUET
tools_map["QuantmsIOConverter"] = Internal::ToolDescription("QuantmsIOConverter", cat_file_converter);
tools_map["QPXConverter"] = Internal::ToolDescription("QPXConverter", cat_file_converter);
#endif

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if old QuantmsIO.pxd still exists and if new QPXFile.pxd has been created
echo "=== Searching for old QuantmsIO.pxd ==="
fd -t f "QuantmsIO" --extension pxd

echo "=== Searching for new QPXFile.pxd ==="
fd -t f "QPXFile" --extension pxd

echo "=== Searching for any remaining QuantmsIO references ==="
rg -l "QuantmsIO" --type-add 'build:*.cmake' --type-add 'build:*.txt' -g '!CHANGELOG*'

Repository: OpenMS/OpenMS

Length of output: 191


🏁 Script executed:

#!/bin/bash
# Find QPXFile and QPXConverter definitions
echo "=== Searching for QPXFile.h ==="
fd -t f "QPXFile" --extension h

echo "=== Searching for QPXConverter references in C++ ==="
rg "QPXConverter" --type cpp --type h

echo "=== Finding similar file converter .pxd files ==="
echo "Looking for common file format .pxd files:"
fd -t f "\.(pxd)$" src/pyOpenMS/pxds/ | grep -i "file\|mzml\|mzxml\|dta" | head -20

Repository: OpenMS/OpenMS

Length of output: 1841


🏁 Script executed:

#!/bin/bash
# Search for QPXFile or related parquet references in pyOpenMS
echo "=== Searching for QPXFile in pyOpenMS files ==="
rg "QPXFile\|qpx\|parquet" src/pyOpenMS/ --type pyx --type pxd -i

echo "=== Checking if QPXFile should be in FileHandler ==="
grep -A5 -B5 "QPXFile\|QPX" src/openms/include/OpenMS/FORMAT/FileHandler.h 2>/dev/null || echo "Not found in FileHandler.h"

echo "=== Checking QPXFile.h for public API ==="
head -50 src/openms/include/OpenMS/FORMAT/QPXFile.h

Repository: OpenMS/OpenMS

Length of output: 1633


Add QPXFile.pxd for pyOpenMS bindings to match the pattern of other file format classes.

The new QPXFile class in src/openms/include/OpenMS/FORMAT/QPXFile.h is a public API for exporting to parquet format and requires a corresponding .pxd file for pyOpenMS support. Similar file format classes (e.g., DTAFile, FeatureXMLFile, ConsensusXMLFile) all have .pxd bindings. Since QPXFile is conditionally compiled with #ifdef WITH_PARQUET, the .pxd file should include the same conditional guards.

🤖 Prompt for AI Agents
In `@src/openms/source/APPLICATIONS/ToolHandler.cpp` around lines 162 - 164, Add a
pyOpenMS binding stub named QPXFile.pxd for the new public class QPXFile so
Python bindings match other file format classes; create the .pxd with the same
conditional compilation guards (`#ifdef` WITH_PARQUET ... `#endif`) and declare the
QPXFile class signature (matching src/openms/include/OpenMS/FORMAT/QPXFile.h) so
the bindings are generated when WITH_PARQUET is enabled and omitted otherwise.

Comment thread src/openms/source/FORMAT/QPXFile.cpp Resolved
Comment thread src/openms/source/FORMAT/QPXFile.cpp Resolved
…MS .pxd

- Replace std::gmtime/std::random with DateTime::now() and UniqueIdGenerator
- Add NaN guard for observed_mz matching RT handling
- Fix ProForma test assertion to check for bracket notation
- Add QPXFile.pxd for pyOpenMS bindings

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/openms/source/FORMAT/QPXFile.cpp`:
- Around line 674-684: The "uuid" metadata is currently set from
UniqueIdGenerator::getUniqueId() producing a numeric UInt64 string; replace that
with a proper RFC 4122 UUID string so the metadata matches Python's uuid.uuid4()
format. Locate the uuid entry in the metadata construction (the "uuid" key and
the call String(UniqueIdGenerator::getUniqueId())) and change it to generate an
RFC4122 UUID (for example using boost::uuids::random_generator() and
boost::uuids::to_string()) and use that string for the "uuid" metadata; add the
necessary includes and ensure the generated string is used when calling
table->ReplaceSchemaMetadata(metadata).
🧹 Nitpick comments (4)
src/openms/source/FORMAT/QPXFile.cpp (3)

52-655: Consider decomposing exportToArrow into smaller helper functions.

CodeFactor flags this as "Very Complex Method" (~600 lines). While the logic is largely linear (sequential column building), extracting logical groups into helpers — e.g., buildModifications(hit, ...), buildAdditionalScores(hit, ...), buildMetavalues(...) — would improve readability and testability of individual concerns.


241-321: Nested builder Append statuses are silently discarded.

While simple builders had capacity reserved (lines 146–181), nested builders like modification_struct_b, positions_list_b, as_struct_b, etc., were not reserved. Their Append() calls could fail under memory pressure and the (void) cast discards the error status. This is consistent with the ConsensusMapArrowExport pattern in the codebase, but worth noting as a reliability gap.


735-746: Output file stream is never explicitly closed.

outfile (a FileOutputStream shared_ptr) relies on destructor-based cleanup. If Close() fails silently in the destructor, the Parquet file could be truncated. Explicitly closing and checking the status ensures data integrity.

♻️ Proposed fix
   if (!write_status.ok())
   {
     OPENMS_LOG_ERROR << "QPXFile: Failed to write Parquet: "
                      << write_status.ToString() << std::endl;
     return false;
   }
 
+  auto close_status = outfile->Close();
+  if (!close_status.ok())
+  {
+    OPENMS_LOG_ERROR << "QPXFile: Failed to close Parquet file: "
+                     << close_status.ToString() << std::endl;
+    return false;
+  }
+
   return true;
src/tests/class_tests/openms/source/QPXFile_test.cpp (1)

349-400: Consider adding an edge-case test for NaN RT/MZ and missing charge.

The modifications test is good. The broader test suite could benefit from a small section exercising nullable column handling — e.g., a PeptideIdentification with NaN RT/MZ or a PeptideHit with charge ≤ 0 — to cover the null-append code paths in exportToArrow (lines 354–375, 459–468 in the implementation).

Comment thread src/openms/source/FORMAT/QPXFile.cpp Resolved
QPXFile.h was missing from the header sources.cmake (WITH_PARQUET block),
causing pyOpenMS wheel builds to fail with "No such file or directory".
Also update the pxd exclusion filter to skip QPXFile.pxd when WITH_PARQUET
is disabled.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@timosachsenberg

Copy link
Copy Markdown
Contributor Author

@copilot In @src/openms/source/FORMAT/QPXFile.cpp around lines 674 - 684, The "uuid"
metadata is currently set from UniqueIdGenerator::getUniqueId() producing a
numeric UInt64 string; replace that with a proper RFC 4122 UUID string so the
metadata matches Python's uuid.uuid4() format. Locate the uuid entry in the
metadata construction (the "uuid" key and the call
String(UniqueIdGenerator::getUniqueId())) and change it to generate an RFC4122
UUID (for example using boost::uuids::random_generator() and
boost::uuids::to_string()) and use that string for the "uuid" metadata; add the
necessary includes and ensure the generated string is used when calling
table->ReplaceSchemaMetadata(metadata).

Copilot AI commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

@timosachsenberg I've opened a new pull request, #8757, to work on those changes. Once the pull request is ready, I'll request review from you.

* Initial plan

* Replace numeric UUID with RFC 4122 UUID using Boost

Co-authored-by: timosachsenberg <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: timosachsenberg <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/openms/source/FORMAT/QPXFile.cpp`:
- Around line 682-690: The metadata creation_date currently calls
DateTime::now() (local time) and formats as "yyyy-MM-ddThh:mm:ss" which lacks a
timezone; change the call to produce UTC and include the timezone indicator
(e.g., use the DateTime API that returns UTC or convert to UTC) so the value is
an ISO 8601 UTC timestamp (e.g., replace DateTime::now() with a UTC variant or
convert to UTC, and append "Z" or include timezone in the format) for the
creation_date entry in the metadata initialization where DateTime::now() and the
"creation_date" key are set.
🧹 Nitpick comments (5)
src/openms/source/FORMAT/QPXFile.cpp (5)

706-725: Missing default case in compression switch.

If ParquetWriteConfig::Compression is extended with a new variant, this switch will silently skip setting compression, defaulting to whatever Arrow uses internally. Add a default case that either maps to a sensible fallback or logs a warning.

Proposed fix
     case ParquetWriteConfig::Compression::ZSTD:
       builder.compression(arrow::Compression::ZSTD);
       builder.compression_level(config.compression_level);
       break;
+    default:
+      OPENMS_LOG_WARN << "QPXFile: Unknown compression type, using SNAPPY" << "\n";
+      builder.compression(arrow::Compression::SNAPPY);
+      break;
   }

380-405: Hit metavalue keys are iterated twice per hit.

hit.getKeys(keys) is called once for additional_scores (line 383) and again for psm_metavalues (line 508), repeating the key enumeration and Scores::isKnownScoreType() lookup for every key on every hit. Consider iterating once and partitioning into scores vs. non-score metavalues.

Also applies to: 505-531


346-355: Case-sensitive decoy detection may miss uppercase conventions.

td.substr(0, 5) == "decoy" will not match "DECOY" or "Decoy", which some search engines produce. If interoperability with diverse search engines is intended, a case-insensitive comparison would be safer.

Proposed fix
       std::string td = hit.getMetaValue("target_decoy").toString();
-      (void)is_decoy_builder.Append(td.substr(0, 5) == "decoy" ? 1 : 0);
+      String td_lower = String(td).toLower();
+      (void)is_decoy_builder.Append(td_lower.hasPrefix("decoy") ? 1 : 0);

54-658: Static analysis flags exportToArrow as very complex (~600 lines).

This single method handles builder setup, capacity reservation, per-hit field extraction (modifications, scores, metavalues, RT, m/z, etc.), array finalization, and schema construction. Consider extracting cohesive blocks into private helpers — e.g., buildModifications(...), buildAdditionalScores(...), reserveBuilders(...), finalizeArrays(...) — to improve readability and testability.


149-184: Highly repetitive Reserve/Finish blocks.

Each builder has an identical status = X.Reserve(n); if (!status.ok()) { log; return nullptr; } pattern repeated ~18 times for Reserve and ~22 times for Finish. A small helper lambda or macro (e.g., ARROW_RETURN_NULL_IF_FAIL(builder.Reserve(n), "builder_name")) would reduce boilerplate and the risk of copy-paste errors.

Example helper approach
// Helper lambda at the top of exportToArrow
auto check = [](arrow::Status s, const char* name) -> bool {
  if (!s.ok())
  {
    OPENMS_LOG_ERROR << "QPXFile: " << name << " failed: " << s.ToString() << "\n";
    return false;
  }
  return true;
};

// Usage:
if (!check(sequence_builder.Reserve(num_rows), "sequence_builder Reserve")) return nullptr;
if (!check(sequence_builder.Finish(&arr_sequence), "sequence_builder Finish")) return nullptr;

Also applies to: 572-617

Comment on lines +682 to +690
auto metadata = arrow::key_value_metadata({
{"qpx_version", "1.0"},
{"creator", "OpenMS"},
{"file_type", "psm"},
{"creation_date", DateTime::now().toString("yyyy-MM-ddThh:mm:ss")},
{"uuid", uuid_str},
{"scan_format", "scan"},
{"software_provider", "OpenMS"}
});

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

🧩 Analysis chain

🏁 Script executed:

# Search for DateTime::now() implementation and usage
rg -n "class DateTime" --type=cpp -A 20 | head -60

Repository: OpenMS/OpenMS

Length of output: 3385


🏁 Script executed:

# Check DateTime::now() specifically
rg -n "now()" src/openms --type=cpp -B 2 -A 2 | head -80

Repository: OpenMS/OpenMS

Length of output: 5751


🏁 Script executed:

# Look for any timezone-related code in DateTime
rg -n "timezone|UTC|gmtime|localtime" src/openms/source/DATASTRUCTURES --type=cpp -B 1 -A 1

Repository: OpenMS/OpenMS

Length of output: 350


🏁 Script executed:

# Search for Python to_psm_qpx implementation to see how it handles creation_date
fd "*.pyx" -o "*.py" | xargs rg -l "to_psm_qpx|creation_date" 2>/dev/null | head -5

Repository: OpenMS/OpenMS

Length of output: 429


🏁 Script executed:

# Check the compression switch in QPXFile for missing default
rg -n "switch.*compression" src/openms/source/FORMAT/QPXFile.cpp -A 25

Repository: OpenMS/OpenMS

Length of output: 1014


🏁 Script executed:

# Find DateTime class definition and now() method
fd "DateTime" --extension h -o --extension cpp | xargs grep -l "class DateTime" | head -3

Repository: OpenMS/OpenMS

Length of output: 173


🏁 Script executed:

# Get the DateTime::now() implementation
rg -n "DateTime.*now\(\)" src/openms/include --type=cpp -A 5

Repository: OpenMS/OpenMS

Length of output: 1807


🏁 Script executed:

# Check Python implementation of creation_date
rg -n "creation_date" src/pyOpenMS/tests/unittests/test_psm_dataframe.py -B 3 -A 3

Repository: OpenMS/OpenMS

Length of output: 343


🏁 Script executed:

# Look at the to_psm_qpx function in Python if it exists
fd "to_psm_qpx" --extension pyx --extension py

Repository: OpenMS/OpenMS

Length of output: 39


🏁 Script executed:

# Check if there's a direct implementation or if it references C++
rg -n "to_psm_qpx\|creation_date" src/pyOpenMS/addons --type pyx -B 2 -A 2 | head -40

Repository: OpenMS/OpenMS

Length of output: 84


🏁 Script executed:

# Get DateTime::now() implementation
rg -n "DateTime::now" src/openms/source/DATASTRUCTURES/DateTime.cpp -A 15

Repository: OpenMS/OpenMS

Length of output: 390


🏁 Script executed:

# Check if DateTime uses localtime or gmtime
rg -n "localtime|gmtime|timezone|UTC" src/openms/source/DATASTRUCTURES/DateTime.cpp -B 2 -A 2

Repository: OpenMS/OpenMS

Length of output: 259


🏁 Script executed:

# Look for any datetime formatting in QPXFile to understand the context better
rg -n "toString\|getDate\|getTime" src/openms/source/FORMAT/QPXFile.cpp -B 1 -A 1

Repository: OpenMS/OpenMS

Length of output: 39


🏁 Script executed:

# Check DateTime class for timezone info in header
cat src/openms/include/OpenMS/DATASTRUCTURES/DateTime.h | head -100

Repository: OpenMS/OpenMS

Length of output: 2367


🏁 Script executed:

# Check if Python test or implementation validates/expects UTC
rg -n "datetime|UTC|timezone|iso" src/pyOpenMS/tests/unittests/test_psm_dataframe.py -i

Repository: OpenMS/OpenMS

Length of output: 147


🏁 Script executed:

# Look for any Python implementation of QPXFile or creation_date handling
rg -n "QPXFile\|ParquetFile\|arrow" src/pyOpenMS --type=pyx --type=py | head -20

Repository: OpenMS/OpenMS

Length of output: 84


🏁 Script executed:

# Check if QDateTime::currentDateTimeUtc exists in codebase - to understand intent
rg -n "currentDateTimeUtc" src/openms

Repository: OpenMS/OpenMS

Length of output: 39


creation_date uses local time instead of UTC, breaking expected ISO 8601 format.

DateTime::now() returns local time via QDateTime::currentDateTime(), while the previous implementation used gmtime (UTC). This creates interoperability issues with clients expecting UTC timestamps. The format string "yyyy-MM-ddThh:mm:ss" also lacks a timezone indicator, making the timestamp ambiguous.

Either use QDateTime::currentDateTimeUtc() directly or append "Z" to the timestamp to explicitly indicate UTC, per ISO 8601 conventions.

🤖 Prompt for AI Agents
In `@src/openms/source/FORMAT/QPXFile.cpp` around lines 682 - 690, The metadata
creation_date currently calls DateTime::now() (local time) and formats as
"yyyy-MM-ddThh:mm:ss" which lacks a timezone; change the call to produce UTC and
include the timezone indicator (e.g., use the DateTime API that returns UTC or
convert to UTC) so the value is an ISO 8601 UTC timestamp (e.g., replace
DateTime::now() with a UTC variant or convert to UTC, and append "Z" or include
timezone in the format) for the creation_date entry in the metadata
initialization where DateTime::now() and the "creation_date" key are set.

timosachsenberg and others added 3 commits February 13, 2026 08:02
The creation_date field in QPX parquet metadata now uses UTC with an
ISO 8601 'Z' suffix instead of ambiguous local time.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Boost's uuid::random_generator requires bcrypt.lib on Windows, causing
LNK2019 linker errors. Use standard C++ <random> for UUID v4 generation.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@timosachsenberg
timosachsenberg merged commit d482820 into develop Feb 13, 2026
41 checks passed
@timosachsenberg
timosachsenberg deleted the feature/rename-quantmsio-to-qpxfile branch February 13, 2026 19:36
timosachsenberg added a commit that referenced this pull request Sep 25, 2026
Fixes the documentation findings of the 3.6.0 release-readiness check
that need no decision:
- CHANGELOG: ParquetConverter under New tools (#8970). QuantmsIOConverter,
  the name 3.5.0 users knew, under Removed tools (renamed QPXConverter in
  #8756, removed in #9693), with the tools that write QPX now. The
  removed SwathWizard and FLASHDeconvWizard (#9472). The five pyOpenMS
  types that are no longer bound, and the methods that fail without them.
- TransitionListEvidenceFilter's page includes its command-line and INI
  parameters, ProteomicsLFQ's page has a @brief, and MetaProSIP is
  listed once in the TOPP index.
- The TOPPAS getting-started page no longer points at the removed
  GenericWrapper.
- installation-on-gnu-linux.md links the DEBs of the GitHub release,
  states the glibc 2.38 requirement, installs with apt and drops the
  Qt5/Xenial and ICU troubleshooting. It and
  common-cmake-parameters.doxygen no longer say that Linux/aarch64 has
  no Thermo reader, which #10206 made wrong.


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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants