Skip to content

Merge main into dev. - #119

Merged
ypriverol merged 7 commits into
bigbio:devfrom
Shen-YuFei:dev
Sep 30, 2025
Merged

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

Conversation

@Shen-YuFei

@Shen-YuFei Shen-YuFei commented Sep 30, 2025 •

Copy link
Copy Markdown
Collaborator

User description

Summary

Merge main branch into dev branch, including the following updates:

Main Changes

  • Added new fragment annotation array fields to PSM schema:
    • charge_array: Charge array for fragment ions
    • ion_type_array: Ion type array (b/y ions)
    • ion_mobility_array: Ion mobility array for fragments
  • Updated core modules (FragPipe, MaxQuant) to support new fields
  • Added comprehensive test cases to validate new field functionality
  • Fixed floating-point precision comparison issues in tests

Files Changed

  • quantmsio/core/fragpipe/fragpipe.py - Added new field support
  • quantmsio/operate/tools.py - Updated utility functions
  • tests/test_fragment_annotations.py - New test file added

Tests Passed

All existing tests continue to pass, and new fragment annotation tests have been added to ensure schema compatibility and data integrity.


PR Type

Enhancement


Description

  • Add fragment annotation arrays to PSM schema

  • Support charge, ion type, and ion mobility arrays

  • Initialize new fields for backward compatibility

  • Add comprehensive test coverage for new fields


Diagram Walkthrough

flowchart LR
  A["PSM Schema"] --> B["Fragment Annotation Arrays"]
  B --> C["charge_array"]
  B --> D["ion_type_array"] 
  B --> E["ion_mobility_array"]
  F["FragPipe Module"] --> B
  G["Tools Module"] --> B
  H["Test Suite"] --> B
Loading

File Walkthrough

Relevant files
Enhancement
fragpipe.py
Add fragment annotation arrays to FragPipe                             

quantmsio/core/fragpipe/fragpipe.py

  • Add three new PyArrow array fields for fragment annotations
  • Initialize charge_array, ion_type_array, and ion_mobility_array
  • Return new fields in to_arrow method dictionary
+12/-0   
tools.py
Initialize fragment arrays for compatibility                         

quantmsio/operate/tools.py

  • Initialize new fragment annotation arrays as None
  • Ensure backward compatibility for existing code
+4/-0     
Tests
test_fragment_annotations.py
Comprehensive tests for fragment annotation arrays             

tests/test_fragment_annotations.py

  • Test PSM schema contains new fragment annotation fields
  • Validate field types and nullability
  • Test table creation with fragment annotations
  • Verify field descriptions and metadata
+201/-0 

@coderabbitai

coderabbitai Bot commented Sep 30, 2025

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.

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

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🧪 Early access (Sonnet 4.5): enabled

We are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-code-review

Copy link
Copy Markdown

You are nearing your monthly Qodo Merge usage quota. For more information, please visit here.

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Schema Consistency

Verify that the new returned keys ('charge_array', 'ion_type_array', 'ion_mobility_array') match the canonical PSM schema field names (e.g., 'number_peaks' vs 'num_peaks') and metadata expectations across the codebase to prevent downstream mismatches.

return {
    "precursor_charge": pa.array(precursor_charge, type=pa.int32()),
    "observed_mz": pa.array(observed_mz, type=pa.float32()),
    "rt": pa.array(retention_time, type=pa.float32()),
    "scan": pa.array(scan_number, type=pa.string()),
    "source_file": pa.array(source_file, type=pa.string(), from_pandas=True),
    "ion_mobility": pa.array(ion_mobility, type=pa.float32(), from_pandas=True),
    "num_peaks": num_peaks_array,
    "mz_array": mz_arrays,
    "intensity_array": intensity_arrays,
    "charge_array": charge_arrays,
    "ion_type_array": ion_type_arrays,
    "ion_mobility_array": ion_mobility_arrays,
}
Nullable Initialization

Confirm that initializing new arrays as None aligns with table writing logic and Parquet schema inference, ensuring correct list types are preserved and not coerced to null type during write/read.

# Initialize new fragment annotation arrays as None for backward compatibility
table["charge_array"] = None
table["ion_type_array"] = None
table["ion_mobility_array"] = None
pqwriters, pqwriter_no_part = save_parquet_file(

@qodo-code-review

qodo-code-review Bot commented Sep 30, 2025 •

Copy link
Copy Markdown

You are nearing your monthly Qodo Merge usage quota. For more information, please visit here.

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
New schema fields are never populated

The PR adds new fields to the PSM schema but fails to implement any logic to
populate them with data. The suggestion is to add this missing data population
logic to make the feature complete.

Examples:

quantmsio/core/fragpipe/fragpipe.py [281-289]
        charge_arrays = pa.array(
            [None] * len(precursor_charge), type=pa.list_(pa.int32())
        )
        ion_type_arrays = pa.array(
            [None] * len(precursor_charge), type=pa.list_(pa.string())
        )
        ion_mobility_arrays = pa.array(
            [None] * len(precursor_charge), type=pa.list_(pa.float32())
        )
quantmsio/operate/tools.py [64-66]
        table["charge_array"] = None
        table["ion_type_array"] = None
        table["ion_mobility_array"] = None

Solution Walkthrough:

Before:

# In quantmsio/core/fragpipe/fragpipe.py
class Spectrum:
    @classmethod
    def to_arrow(cls, batch):
        # ...
        charge_arrays = pa.array(
            [None] * len(precursor_charge), type=pa.list_(pa.int32())
        )
        ion_type_arrays = pa.array(
            [None] * len(precursor_charge), type=pa.list_(pa.string())
        )
        ion_mobility_arrays = pa.array(
            [None] * len(precursor_charge), type=pa.list_(pa.float32())
        )
        return {
            # ...
            "charge_array": charge_arrays,
            "ion_type_array": ion_type_arrays,
            "ion_mobility_array": ion_mobility_arrays,
        }

After:

# In a data processing module (conceptual)
def process_psms(psm_data):
    # ...
    fragment_charges = []
    fragment_ion_types = []
    fragment_ion_mobilities = []

    for psm in psm_data:
        # Logic to parse fragment annotations from source data
        annotations = parse_fragment_annotations(psm.source_data)
        fragment_charges.append(annotations.charges)
        fragment_ion_types.append(annotations.ion_types)
        fragment_ion_mobilities.append(annotations.ion_mobilities)

    # ...
    # Create PyArrow table with populated arrays
    table = pa.table({
        # ...
        "charge_array": pa.array(fragment_charges),
        "ion_type_array": pa.array(fragment_ion_types),
        "ion_mobility_array": pa.array(fragment_ion_mobilities),
    })
    return table
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a critical omission; the PR adds new schema fields but includes no logic to populate them, rendering the new feature incomplete and unusable for storing actual data.

High
  • Update

@ypriverol
ypriverol merged commit 213e709 into bigbio:dev Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants