Skip to content

Fix various issues in converters, metadata, and OpenMS handling - #234

Merged
ypriverol merged 30 commits into
bigbio:devfrom
Shen-YuFei:dev
Aug 5, 2026
Merged

ypriverol merged 30 commits into
bigbio:devfrom
Shen-YuFei:dev

Conversation

@Shen-YuFei

Copy link
Copy Markdown
Collaborator

Summary

This PR hardens the current QPX dev branch before the dev → main release in #227. It consolidates converter-correctness fixes, output-integrity checks, OpenMS consensusXML improvements, and follow-up fixes for the mandatory identity implementation introduced in #232.

Changes

Converter correctness

  • Normalize modification annotations before upper-casing peptidoforms.
  • Exclude FragPipe MaxLFQ columns from experiment detection.
  • Deduplicate repeated MaxQuant evidence Features.
  • Exclude ambiguous CDAP PSMs from Feature aggregation.
  • Merge DIA-NN scan metadata using both scan and retention time.
  • Improve mzIdentML protein-group run attribution and q-value handling.
  • Normalize run filenames, raw-data extensions, and protein annotations consistently.
  • Propagate converter row-transformation failures instead of silently producing partial output.

OpenMS consensusXML

  • Recognize label-free consensus maps correctly.
  • Integrate the single-pass streaming conversion path.
  • Preserve protein-group run fallback behavior.
  • Attribute assigned PSMs using the run context of their parent ConsensusFeature, rather than resolving local id_merge_index values as global map indexes.

Output and validation integrity

  • Prevent failed automatic MuData exports from leaving incomplete .h5mu artifacts.
  • Enforce run, protein-group, and QPX layout invariants.
  • Validate converter run mappings and protein-group counts.
  • Remove the deprecated QuantMS mzTab/MSstats integration.
  • Correct QPX 1.1 data-model relationships and compatibility handling.

Mandatory identity follow-up

Addresses the findings tracked in #233:

  • Do not flush an incomplete writer buffer when the context body raises.
  • Preserve the original exception on failed writer exits.
  • Stamp primary_key footer metadata only when a single derived-id field exists, while retaining identity_composite for multi-column keys.
  • Fail early when override_provided_ids=True but cv_params is unavailable to preserve the producer ID.
  • Pass parent Feature run context through consensus_psms_to_records.

The reported read_parquet(?) concern was also verified against the supported DuckDB versions: bound file paths work correctly, so no SQL interpolation or escaping workaround was introduced.

Validation

  • 74 targeted tests passed across OpenMS, OpenMS consensusXML, writers, identity, and schema validation.
  • pre-commit, Bandit, and Prospector passed with no new findings.
  • Real-data validation used PXD020815:
    • the first 30,000 ConsensusFeature records exposed 12,856 legacy PSM run-attribution mismatches;
    • the updated helper matched the parent Feature run context;
    • failed writes did not leave a partial Parquet file;
    • Feature identity footer metadata and producer-ID preservation behaved correctly.

Related work

@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 66953070-57d5-46e6-bb14-87840a5db15c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 53 complexity · -7 duplication

Metric Results
Complexity 53
Duplication -7

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@Shen-YuFei
Shen-YuFei requested a review from ypriverol August 5, 2026 13:30
@Shen-YuFei
Shen-YuFei marked this pull request as ready for review August 5, 2026 13:31
Copilot AI lite review requested due to automatic review settings August 5, 2026 13:31
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

Copilot AI 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.

Pull request overview

This PR hardens QPX conversion and validation paths ahead of the dev → main release, focusing on converter correctness, identity/writer robustness, and improved OpenMS consensusXML handling and metadata normalization.

Changes:

  • Improves converter correctness and integrity (e.g., OpenMS consensusXML PSM run attribution, MaxQuant evidence deduplication, FragPipe experiment detection, DIA-NN scan metadata merging).
  • Hardens writer/export behavior (identity footer stamping for composite PKs, buffer discard on context-body errors, safer muData export that avoids partial artifacts).
  • Normalizes and validates run naming and PG layout/version compatibility (shared run_file_stem, stricter PG layout guards, additional validation tests).

Reviewed changes

Copilot reviewed 37 out of 37 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unit/test_writers.py Adds writer regression tests for composite PK footer handling and buffer discard on context failure.
tests/unit/test_version.py Expands PG layout compatibility tests and S3 discovery soft-fail behavior expectations.
tests/unit/test_validate.py Adds validation regression test for grouped_runs duplicate handling.
tests/unit/test_mudata.py Adds muData export tests for failure modes, temp cleanup, and modality requirements.
tests/unit/test_identity.py Adds test ensuring override mode requires cv_params to preserve producer IDs.
tests/unit/test_data.py Ensures strict validation promotes skipped cross-structure checks to errors.
tests/converters/test_ptm.py Adds coverage for stripping modifications safely before upper-casing sequences.
tests/converters/test_openms_consensus.py Adds OpenMS consensusXML conversion tests (structure validation, SDRF requirements, run attribution, LFQ labels, SQL param binding).
tests/converters/test_maxquant_converter.py Adds MaxQuant PG/feature correctness tests (mapping failures, total intensity rejection, evidence dedup preference).
tests/converters/test_converters.py Updates FragPipe peptide TSV fixture to include MaxLFQ intensity columns.
tests/converters/test_converter_utils.py Adds unit tests for run_file_stem preserving meaningful dots and stripping known suffixes.
tests/converters/test_channel_labels.py Adds test ensuring multi-dot run names survive SDRF mapping and run output.
qpx/writers/base.py Fixes footer stamping for composite PKs, enforces override preconditions, and discards buffered rows on context exceptions.
qpx/version.py Tightens PG layout guard: grouped_runs requires flattened label/intensity columns.
qpx/mudata.py Uses shared run-stem normalization for run/sample joins in MuData assembly.
qpx/dataset.py Drops incompatible S3-registered views safely via validated identifiers; adjusts strict-check behavior.
qpx/core/sdrf.py Switches SDRF run-name normalization to shared run_file_stem.
qpx/core/files.py Introduces shared run_file_stem helper for consistent run filename normalization across inputs.
qpx/converters/sdrf.py Makes SDRF converter outputs optional (run/sample independently) and uses run_file_stem for run derivation.
qpx/converters/ptm.py Adds strip_modifications helper to avoid modification-name letters leaking into sequences.
qpx/converters/orchestrator.py Makes muData export atomic (tmp + replace) and avoids leaving stale/partial artifacts.
qpx/converters/openms_consensus/streaming.py Minor streaming parser cleanup (unused iterparse event binding).
qpx/converters/openms_consensus/psm_adapter.py Ensures assigned PSMs inherit parent ConsensusFeature run context for correct run attribution.
qpx/converters/openms_consensus/pg_adapter.py Reuses shared run resolver for unassigned peptide run attribution in PG mapping.
qpx/converters/openms_consensus/feature_adapter.py Uses shared run_file_stem and removes duplicated local run-stem logic.
qpx/converters/openms_consensus/converter.py Validates requested structures/SDRF needs and writes only requested SDRF-backed outputs.
qpx/converters/mzidentml/psm_adapter.py Normalizes spectra-data run stems using shared run_file_stem.
qpx/converters/mzidentml/pg_adapter.py Improves run attribution and q-value extraction for mzIdentML protein groups.
qpx/converters/maxquant/psm_adapter.py Stops swallowing row-transform errors (fail fast instead of partial output).
qpx/converters/maxquant/pg_adapter.py Validates experiment→run mappings early and removes unsafe fallback grouped_runs behavior.
qpx/converters/maxquant/feature_adapter.py Adds evidence dedup query (prefer identified over MBR duplicates) and propagates transform failures.
qpx/converters/fragpipe/feature_adapter.py Excludes MaxLFQ intensity columns from experiment detection.
qpx/converters/diann/feature_adapter.py Improves scan metadata merge by using scan+RT logic and bounded nearest matching.
qpx/converters/channel_labels.py Uses shared run_file_stem for SDRF-derived run naming and signature collection.
qpx/converters/cdap/feature_adapter.py Excludes ambiguous CDAP PSMs from feature-level quant aggregation when flagged.
qpx/cli/convert.py Improves CLI help formatting for OpenMS consensus options.
docs/spec/data-model.md Updates data model doc wording for peptidoform/charge identity semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread qpx/core/sdrf.py
Comment on lines 146 to +147
sdrf = self.sdrf_table[["source name", "comment[data file]", "comment[label]"]].copy()
sdrf["comment[data file]"] = sdrf["comment[data file]"].str.split(".").str[0]
sdrf["comment[data file]"] = sdrf["comment[data file]"].map(run_file_stem)
Comment thread qpx/converters/sdrf.py
Comment on lines 297 to 299
sdrf_df = sdrf_df.copy()
sdrf_df["_run_file"] = sdrf_df[_COL_DATA_FILE].astype(str).str.split(".").str[0]
sdrf_df["_run_file"] = sdrf_df[_COL_DATA_FILE].map(run_file_stem)
sdrf_df["_file_name"] = sdrf_df[_COL_DATA_FILE].astype(str).str.strip()
@ypriverol
ypriverol merged commit 5b5cefd into bigbio:dev Aug 5, 2026
8 checks passed
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.

identity ids: follow-up hardening from CodeRabbit review (writer close/footer/override + openms-consensus PSM runs)

3 participants