Repository navigation
[Feature] Export ion annotations for MSSpectrum DataFrame - #7489
Conversation
|
looks good! I think we don't have a function annotate_spectrum_with_peak_annotations or similar name, yet. It could take a MSSpectrum and a vector of PeakAnnotations and fill the string data array ?@matteopilz or @Arslan-Siraj Or how do we currently plot this e.g., in NuXL web app? |
|
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. PR Reviewer Guide 🔍
|
|
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. PR Code Suggestions ✨
|
Adds support for extracting ion annotations from StringDataArray named 'IonNames'. This feature was originally added by Axel Walter in PR #7489 for spectral library work. The ion_annotation column contains per-peak annotation strings like "y1", "b2", "y3-H2O", etc. that are populated by tools like TheoreticalSpectrumGenerator. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
* Added get_df() Dataframe * expose the get_df() * Remove duplicate get_df implementation * Add metadata method declarations and docstrings * Fix metadata handling with type-safe DataValue unwrapping * Remove redundant MSSpectrumDF subclass after Cython integration * removed getpeaks() * fixes the issue as suggested by CodeRabbit * refactor(MSSpectrum): Replace pandas DataFrame with NumPy dict for dependency-free metadata export && change np into _np * added unit test * Updated the Code and also added tests * Fix MSSpectrum.get_df() implementation for pyOpenMS This commit fixes the implementation of get_df() and get_data_dict() methods for MSSpectrum, addressing issue #7966. Key changes: 1. MSSpectrum.pxd: Removed incorrect C++ method declarations (DataFrame get_df() and void get_data_dict()) - these methods are implemented in Python/Cython, not in C++. 2. MSSpectrum.pyx addon: - Removed incorrect 'cdef class MSSpectrum:' declaration - Fixed get_data_dict() to use Python type introspection instead of Cython cdef DataValue (which doesn't work in def methods) - Changed precursor_charge dtype to int16 (can be negative) - Improved documentation and code formatting 3. _dataframes.py: - Added _MSSpectrumDF wrapper class that provides get_df() method - get_df() calls get_data_dict() and converts to pandas DataFrame - Added MSSpectrum and PeakSpectrum aliases for the DF wrapper class - Follows same pattern as _MSChromatogramDF 4. Tests: - Comprehensive tests for get_data_dict() covering basic spectra, ion mobility, precursors, meta values, empty spectra - Tests for get_df() DataFrame export functionality - Fixed NaN comparison issues (use np.isnan instead of ==) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Add ion_annotation column to MSSpectrum.get_data_dict() Adds support for extracting ion annotations from StringDataArray named 'IonNames'. This feature was originally added by Axel Walter in PR #7489 for spectral library work. The ion_annotation column contains per-peak annotation strings like "y1", "b2", "y3-H2O", etc. that are populated by tools like TheoreticalSpectrumGenerator. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Fix MSSpectrum.get_data_dict() Cython issues and tests - Change numpy import alias from _np to np (matching autowrap generated code) - Use len() instead of .size() for Python lists returned by autowrap - Use sda.size() for StringDataArray (has .size() method, no __len__) - Fix KDTreeFeatureNode.pxd wrap-doc annotation (add blank comment terminator) - Fix test expectation for DriftTimeUnit string (VSSC -> 1/K0) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Add __len__ to data array classes for Pythonic API - Add __len__ method to StringDataArray, FloatDataArray, IntegerDataArray - Update MSSpectrum.pyx to use len() instead of .size() for consistency - Enables Python's built-in len() function on these container classes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Remove redundant to_dataframe/to_pandas helper functions Following the standard Python library pattern (PyArrow, Polars, BioPandas), DataFrame conversion should be done via methods on objects (.get_df()) rather than standalone helper functions. - Delete pandas_utils.py (contained to_dataframe helper) - Remove to_pandas() from _dataframes.py (redundant with pd.DataFrame) - Clean up converters/__init__.py imports 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Fix _add_meta_values to handle native Python types from getMetaValue() - getMetaValue() returns native Python types (float, int, str), not DataValue objects, causing valueType() calls to fail and fall back to string conversion - Now check for native Python types first before trying DataValue methods - Also fix testMSSpectrum expected shape from (2,10) to (2,11) for ion_annotation column 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: ChandraDevs1 <[email protected]> Co-authored-by: Claude <[email protected]>
…types (#8436) * Added get_df() Dataframe * expose the get_df() * Remove duplicate get_df implementation * Add metadata method declarations and docstrings * Fix metadata handling with type-safe DataValue unwrapping * Remove redundant MSSpectrumDF subclass after Cython integration * removed getpeaks() * fixes the issue as suggested by CodeRabbit * refactor(MSSpectrum): Replace pandas DataFrame with NumPy dict for dependency-free metadata export && change np into _np * added unit test * Updated the Code and also added tests * Fix MSSpectrum.get_df() implementation for pyOpenMS This commit fixes the implementation of get_df() and get_data_dict() methods for MSSpectrum, addressing issue #7966. Key changes: 1. MSSpectrum.pxd: Removed incorrect C++ method declarations (DataFrame get_df() and void get_data_dict()) - these methods are implemented in Python/Cython, not in C++. 2. MSSpectrum.pyx addon: - Removed incorrect 'cdef class MSSpectrum:' declaration - Fixed get_data_dict() to use Python type introspection instead of Cython cdef DataValue (which doesn't work in def methods) - Changed precursor_charge dtype to int16 (can be negative) - Improved documentation and code formatting 3. _dataframes.py: - Added _MSSpectrumDF wrapper class that provides get_df() method - get_df() calls get_data_dict() and converts to pandas DataFrame - Added MSSpectrum and PeakSpectrum aliases for the DF wrapper class - Follows same pattern as _MSChromatogramDF 4. Tests: - Comprehensive tests for get_data_dict() covering basic spectra, ion mobility, precursors, meta values, empty spectra - Tests for get_df() DataFrame export functionality - Fixed NaN comparison issues (use np.isnan instead of ==) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Add ion_annotation column to MSSpectrum.get_data_dict() Adds support for extracting ion annotations from StringDataArray named 'IonNames'. This feature was originally added by Axel Walter in PR #7489 for spectral library work. The ion_annotation column contains per-peak annotation strings like "y1", "b2", "y3-H2O", etc. that are populated by tools like TheoreticalSpectrumGenerator. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Fix MSSpectrum.get_data_dict() Cython issues and tests - Change numpy import alias from _np to np (matching autowrap generated code) - Use len() instead of .size() for Python lists returned by autowrap - Use sda.size() for StringDataArray (has .size() method, no __len__) - Fix KDTreeFeatureNode.pxd wrap-doc annotation (add blank comment terminator) - Fix test expectation for DriftTimeUnit string (VSSC -> 1/K0) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Add __len__ to data array classes for Pythonic API - Add __len__ method to StringDataArray, FloatDataArray, IntegerDataArray - Update MSSpectrum.pyx to use len() instead of .size() for consistency - Enables Python's built-in len() function on these container classes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Remove redundant to_dataframe/to_pandas helper functions Following the standard Python library pattern (PyArrow, Polars, BioPandas), DataFrame conversion should be done via methods on objects (.get_df()) rather than standalone helper functions. - Delete pandas_utils.py (contained to_dataframe helper) - Remove to_pandas() from _dataframes.py (redundant with pd.DataFrame) - Clean up converters/__init__.py imports 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Fix _add_meta_values to handle native Python types from getMetaValue() - getMetaValue() returns native Python types (float, int, str), not DataValue objects, causing valueType() calls to fail and fall back to string conversion - Now check for native Python types first before trying DataValue methods - Also fix testMSSpectrum expected shape from (2,10) to (2,11) for ion_annotation column 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Add column selection for MSSpectrum/MSChromatogram get_df() - Add get_df_columns() method to discover available columns - Add columns parameter to get_df() for selective export - Support custom data arrays via prefixed names: - float_array:<name>, int_array:<name>, string_array:<name> - Keep ion_mobility and ion_annotation as aliases for default arrays - Add comprehensive tests for column selection feature 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Standardize DataFrame column names and add get_data_dict() to MSChromatogram - Standardize column naming to lowercase snake_case across all DataFrame exports: - RT → rt, time → rt, inty → intensity - mzarray → mz_array, intarray → intensity_array - IM → ion_mobility, RTstart/RTend → rt_start/rt_end - MZstart/MZend → mz_start/mz_end - Add Cython-level get_data_dict() and get_df_columns() to MSChromatogram following MSSpectrum pattern for pandas-optional access with column selection - Add get_data_mv() to IntegerDataArray for zero-copy memory view access (consistency with FloatDataArray API) - Update tests for new column names 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * Add Pythonic methods to Mobilogram and StringDataArray, improve column selection - Mobilogram: Add __len__, __str__, __repr__, get_df_columns(), get_data_dict() - StringDataArray: Add get_data() returning list of Python strings - ConsensusMap/FeatureMap: Improve column selection efficiency by pre-filtering (skip computation of unused data sources) - _dataframes.py: Add Mobilogram DataFrame wrapper class 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * Add development patterns documentation to pyOpenMS README - Document snake_case naming convention for Python-facing names - Explain get_data_dict() → get_df() layering pattern for optional pandas - Add examples for addon and wrapper implementation - Document common Pythonic methods (__len__, __repr__, etc.) - Include rebuild instructions for addon changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * Fix docstring column names and add breaking change to CHANGELOG - Update get_metadata_df() docstring to show actual lowercase column names (rt, mz, quality instead of RT/mz) - Add BREAKING change note to CHANGELOG documenting snake_case column rename 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * Fix incorrect column name in get_chromatogram_df() example Change example from columns=['time', 'intensity'] to columns=['rt', 'intensity'] to match actual column names. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> --------- Co-authored-by: ChandraDevs1 <[email protected]> Co-authored-by: Claude <[email protected]>

User description
Description
Export ion annotations for MSSpectrum DataFrame. This information is required for plotting of mirror spectra.
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 buildsPR Type
Enhancement, Tests
Description
_MSSpectrumDFclass to export ion annotations in the DataFrame.export_ion_mobilityandexport_peptide_identificationsarguments from theget_dfmethod.ion_annotationfor ion annotations.Changes walkthrough 📝
_dataframes.py
Enhance MSSpectrum DataFrame export with ion annotationssrc/pyOpenMS/pyopenms/_dataframes.py
export_ion_mobilityandexport_peptide_identificationsarguments.
ion_annotation.test000.py
Add unit tests for ion annotations in DataFramesrc/pyOpenMS/tests/unittests/test000.py