Repository navigation
fix small bug and some refactoring - #8096
Conversation
WalkthroughThis update refactors and simplifies peptide and protein quantification logic in the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ProteinQuantifier
participant PeptideAndProteinQuant
participant ExperimentalDesign
User->>ProteinQuantifier: Run quantification (input file)
ProteinQuantifier->>ProteinQuantifier: process*Input_()
ProteinQuantifier->>ExperimentalDesign: Load experimental design
ProteinQuantifier->>PeptideAndProteinQuant: Read quant data
PeptideAndProteinQuant->>PeptideAndProteinQuant: quantifyPeptides()
PeptideAndProteinQuant->>PeptideAndProteinQuant: quantifyProteins()
PeptideAndProteinQuant->>PeptideAndProteinQuant: transferPeptideDataToProteins_()
PeptideAndProteinQuant->>PeptideAndProteinQuant: calculateFileAndChannelLevelProteinAbundances_()
ProteinQuantifier->>ProteinQuantifier: writeProteinTableHeader_()
ProteinQuantifier->>ProteinQuantifier: writeProteinTable_()
ProteinQuantifier->>User: Output quantification results
Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp (2)
932-932: Remove redundant blank line.- }
1177-1277: Complex but necessary implementation for detailed protein quantification.This method handles the intricate task of calculating file and channel-level protein abundances. While the static analysis correctly identifies this as a complex method due to the nested loops, the complexity stems from the multi-dimensional nature of the quantification data.
Consider future refactoring opportunities to break down this method into smaller, more focused helper functions to improve maintainability.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h(7 hunks)src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp(17 hunks)src/tests/topp/ProteinQuantifier_17_output.txt(1 hunks)src/tests/topp/ProteinQuantifier_2_output2.txt(1 hunks)src/topp/ProteinQuantifier.cpp(11 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: FreezB11
PR: OpenMS/OpenMS#7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:1-3
Timestamp: 2025-06-16T15:49:26.504Z
Learning: In OpenMS Python bindings (.pxd files), derived quantitation method classes like TMTThirtyTwoPlexQuantitationMethod only need to declare their constructors. All other public methods (getName, getChannelInformation, getNumberOfChannels, getIsotopeCorrectionMatrix, getReferenceChannel) are inherited from the base IsobaricQuantitationMethod class and don't need to be redeclared explicitly.
src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp (1)
Learnt from: FreezB11
PR: OpenMS/OpenMS#7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:1-3
Timestamp: 2025-06-16T15:49:26.504Z
Learning: In OpenMS Python bindings (.pxd files), derived quantitation method classes like TMTThirtyTwoPlexQuantitationMethod only need to declare their constructors. All other public methods (getName, getChannelInformation, getNumberOfChannels, getIsotopeCorrectionMatrix, getReferenceChannel) are inherited from the base IsobaricQuantitationMethod class and don't need to be redeclared explicitly.
src/topp/ProteinQuantifier.cpp (2)
Learnt from: FreezB11
PR: OpenMS/OpenMS#7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:1-3
Timestamp: 2025-06-16T15:49:26.504Z
Learning: In OpenMS Python bindings (.pxd files), derived quantitation method classes like TMTThirtyTwoPlexQuantitationMethod only need to declare their constructors. All other public methods (getName, getChannelInformation, getNumberOfChannels, getIsotopeCorrectionMatrix, getReferenceChannel) are inherited from the base IsobaricQuantitationMethod class and don't need to be redeclared explicitly.
Learnt from: FreezB11
PR: OpenMS/OpenMS#7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:4-4
Timestamp: 2025-06-16T15:48:09.667Z
Learning: In OpenMS .pxd files, the established pattern for extern from statements is to include angle brackets inside the string literal, like `cdef extern from "<OpenMS/PATH/TO/FILE.h>" namespace "OpenMS":`. This is consistent across all existing quantitation method .pxd files and other .pxd files in the OpenMS codebase.
src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h (1)
Learnt from: FreezB11
PR: OpenMS/OpenMS#7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:1-3
Timestamp: 2025-06-16T15:49:26.504Z
Learning: In OpenMS Python bindings (.pxd files), derived quantitation method classes like TMTThirtyTwoPlexQuantitationMethod only need to declare their constructors. All other public methods (getName, getChannelInformation, getNumberOfChannels, getIsotopeCorrectionMatrix, getReferenceChannel) are inherited from the base IsobaricQuantitationMethod class and don't need to be redeclared explicitly.
🧬 Code Graph Analysis (1)
src/topp/ProteinQuantifier.cpp (2)
src/openms/include/OpenMS/APPLICATIONS/TOPPBase.h (2)
getFlag_(785-785)getStringOption_(722-722)src/openms/source/FORMAT/FileHandler.cpp (2)
stripExtension(127-148)stripExtension(127-127)
🪛 GitHub Check: CodeFactor
src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp
[notice] 932-932: src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp#L932
Redundant blank line at the end of a code block should be deleted. (whitespace/blank_line)
[notice] 1177-1278: src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp#L1177-L1278
Complex Method
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
- GitHub Check: build-and-test (macos-13, xcode, 14.2)
- GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
- GitHub Check: build-and-test (macos-14, xcode, 15.0.1)
- GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
- GitHub Check: cppcheck-test
🔇 Additional comments (9)
src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h (3)
43-43: Good type correction for PSM counts.Changing from
doubletoUInt64is appropriate since PSM counts are discrete values that should be represented as integers.
72-77: Well-structured additions for detailed quantification tracking.The new data members for channel-level abundances and file-level PSM counts enable more granular tracking of quantification data, which aligns with the enhanced output functionality.
174-177: Excellent API improvements.The simplification of
quantifyProteinsand the refactoring ofmapAccessionToLeaderto return a map instead of using an output parameter improve const-correctness and API clarity.src/topp/ProteinQuantifier.cpp (4)
384-387: Critical fix: Corrected channel indexing from 0-based to 1-based.The change from
c = 0; c < ed.getNumberOfLabels()toc = 1; c <= ed.getNumberOfLabels()correctly aligns with how channels/labels are numbered in the experimental design (starting from 1). This fixes a potential off-by-one error throughout the code.Also applies to: 432-433, 497-499, 635-636
478-545: Excellent modularization of header writing logic.Extracting the header writing logic into a separate method
writeProteinTableHeader_improves code organization and reusability.
873-978: Outstanding refactoring with dedicated input processing methods.The introduction of
processFeatureXMLInput_,processIdXMLInput_, andprocessConsensusXMLInput_significantly improves code organization by:
- Eliminating code duplication
- Providing clear separation of concerns for each input type
- Making the main method more readable and maintainable
639-652: Indexing Verified:channel_level_abundancesUses 1-Based Labels ConsistentlyAll usages of channels in
channel_level_abundancesstem fromExperimentalDesign::MSFileSectionEntry::label, which is defined as 1-based. Both peptide‐ and protein‐level quantification store and aggregate abundances using this label, and the output loop inProteinQuantifier.cppiterates from 1 toed.getNumberOfLabels(). The map keys and loop indices therefore align, and no changes are required.src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp (2)
309-327: Important fix for PSM counting in multiplexed experiments.The updated logic correctly handles multiplexed designs (e.g., TMT) where a single PSM is associated with all samples measured in different channels. The 1-based channel indexing (
channel = 1; channel <= experimental_design_.getNumberOfLabels()) is consistent with the rest of the codebase.
796-947: Comprehensive enhancement of protein annotation with detailed quantification data.The refactored annotation logic now properly handles:
- File and channel-level abundance data with proper array sizing
- Defensive error checking for invalid channel 0
- Consistent 1-based channel indexing
- Proper organization of data according to experimental design
The added complexity is justified by the enhanced functionality.
Description
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
Refactor
Bug Fixes
Tests