Skip to content

Pjones/refactor plfq - #8192

Merged
timosachsenberg merged 3 commits into
developfrom
pjones/refactor-plfq
Sep 2, 2025
Merged

timosachsenberg merged 3 commits into
developfrom
pjones/refactor-plfq

Conversation

@pjones

@pjones pjones commented Sep 1, 2025 •

Copy link
Copy Markdown
Contributor

Description

Simple refactoring moving some variables around, removing code that is never executed (dead code), and removing variables that are never used.

Note to reviewers: It's probably easier to review each commit separately.

Checklist

  • Make sure that you are listed in the AUTHORS file

Summary by CodeRabbit

  • Improvements

    • Alignment and linking are now always performed during quantification for more consistent results.
    • Identification runs now use isolated local containers to avoid unintended side effects.
  • Refactor

    • Alignment and linking logic consolidated into the quantification flow, simplifying control paths.
    • Internal data handling unified to use a single local feature container throughout processing.
  • Chores

    • Call sites updated to match the streamlined quantification interface.

@coderabbitai

coderabbitai Bot commented Sep 1, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Quantification was refactored to perform alignment internally using a local transformations vector; alignAndLink_ now returns void. quantifyFraction_ no longer accepts alignment out-parameters and uses a local FeatureMap for FFI output, randomization, filtering, and quantification.

Changes

Cohort / File(s) Summary of changes
Quantification & alignment refactor
src/topp/ProteomicsLFQ.cpp
- alignAndLink_ return type changed from double to void and now always performs alignment/linking internally
- quantifyFraction_ signature simplified: removed transformations and max_alignment_diff out-parameters; now accepts fixed_modifications and variable_modifications only
- FeatureFinderIdentification invocation updated to populate a local FeatureMap (fm) and use locally-scoped ext_protein_ids/ext_peptide_ids
- Replaced temporary tmp FeatureMap usage with a dedicated local fm across selection, randomization, filtering, scoring, and final move into feature_maps
- Removed is_already_aligned branching; alignment/linking is performed unconditionally inside the new flow
- Call sites adjusted to the new signatures and local handling of transformations

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant ProteomicsLFQ as ProteomicsLFQ::quantifyFraction_
  participant FFI as FeatureFinderIdentification
  participant Align as ProteomicsLFQ::alignAndLink_

  Caller->>ProteomicsLFQ: quantifyFraction_(ms_files, mzfile2idfile, in_db, median_fwhm, consensus_fraction, fixed_mods, var_mods)
  activate ProteomicsLFQ

  note over ProteomicsLFQ: create local FeatureMap fm\ncreate local `transformations` vector

  ProteomicsLFQ->>FFI: run(fm, ext_protein_ids={}, ext_peptide_ids={})
  activate FFI
  FFI-->>ProteomicsLFQ: fm populated
  deactivate FFI

  note over ProteomicsLFQ: process fm (randomize, filter, score)

  ProteomicsLFQ->>Align: alignAndLink_(feature_maps, consensus_fraction, transformations, median_fwhm)
  activate Align
  Align-->>ProteomicsLFQ: consensus_fraction updated (no return value)
  deactivate Align

  ProteomicsLFQ-->>Caller: ExitCodes result
  deactivate ProteomicsLFQ
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I hop through code with whiskered cheer,
Out-params trimmed, the path is clear.
A local map, alignments made,
No forks remain along the glade.
I thump my foot — the build draws near! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pjones/refactor-plfq

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@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: 0

🧹 Nitpick comments (2)
src/topp/ProteomicsLFQ.cpp (2)

1016-1016: Localize or reserve transformations (minor).

Declaring transformations here is fine. Optionally, declare it just before the alignAndLink_ call (where it’s first used) or reserve capacity to the number of maps to slightly tighten lifetime/allocations.


1337-1338: Document ignored return value from alignAndLink_.

The return value (max alignment diff) is intentionally unused. Cast to void to make this explicit (or consider changing the helper to return void in a follow-up).

-    alignAndLink_(feature_maps, consensus_fraction, transformations, median_fwhm);
+    (void)alignAndLink_(feature_maps, consensus_fraction, transformations, median_fwhm);

If any downstream logic depends on the max diff, confirm it’s not needed here after the refactor.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0702587 and aca32e8.

📒 Files selected for processing (1)
  • src/topp/ProteomicsLFQ.cpp (3 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms

Applied to files:

  • src/topp/ProteomicsLFQ.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)

Applied to files:

  • src/topp/ProteomicsLFQ.cpp
📚 Learning: 2025-08-14T10:19:54.371Z
Learnt from: jpfeuffer
PR: OpenMS/OpenMS#8167
File: src/topp/Digestor.cpp:200-226
Timestamp: 2025-08-14T10:19:54.371Z
Learning: In OpenMS (C++ bioinformatics framework), use boost random libraries instead of std library random distributions for cross-platform reproducible random number generation, as std library distributions are not reproducible across platforms.

Applied to files:

  • src/topp/ProteomicsLFQ.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes

Applied to files:

  • src/topp/ProteomicsLFQ.cpp
🧬 Code graph analysis (1)
src/topp/ProteomicsLFQ.cpp (2)
src/topp/MapAlignerIdentification.cpp (2)
  • transformations (183-198)
  • transformations (183-184)
src/topp/MapAlignerTreeGuided.cpp (6)
  • transformations (123-135)
  • transformations (123-123)
  • transformations (219-219)
  • feature_maps (108-121)
  • feature_maps (108-108)
  • feature_maps (181-181)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
  • GitHub Check: build-and-test (macos-14, xcode, 15.0.1)
  • GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
  • GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
  • GitHub Check: build-and-test (macos-13, xcode, 14.2)
🔇 Additional comments (1)
src/topp/ProteomicsLFQ.cpp (1)

1114-1131: Remove unused fm and simplify tmp initialization
FeatureMap tmp; replaces both FeatureMap fm; and FeatureMap tmp = fm; // WTF?. The call to ffi.run(peptide_ids, protein_ids, ext_peptide_ids, ext_protein_ids, tmp, seeds, mz_file) already matches the documented signature (features→seeds→spectra_file order)(pyopenms-docs.readthedocs.io, pyopenms.readthedocs.io).

Comment thread src/topp/ProteomicsLFQ.cpp Resolved

@timosachsenberg timosachsenberg 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.

look good to me. I think I once tried a few things that used the max_alignment_diff and the transfomration - but seems I forgot to remove them later

@pjones

pjones commented Sep 1, 2025

Copy link
Copy Markdown
Contributor Author

look good to me. I think I once tried a few things that used the max_alignment_diff and the transfomration - but seems I forgot to remove them later

It looks like I can remove the return value from the alignAndLink_ function too.

@pjones
pjones force-pushed the pjones/refactor-plfq branch from aca32e8 to ff5fe7f Compare September 1, 2025 14:24

@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: 0

🧹 Nitpick comments (5)
src/topp/ProteomicsLFQ.cpp (5)

701-706: Remove stale @return in doc; signature change to void looks good

The function no longer returns a value, but the doc still claims it returns a maximum alignment difference. Please drop or update the stale comment. Call sites in this file are already adapted.

Apply this diff to clean up the doc:

-  /// Align and link.
-  /// @return maximum alignment difference observed (to guide linking)
+  /// Align and link.
   void alignAndLink_(

1014-1014: Inline transformations into alignAndLink_ to shrink scope

transformations is only used to feed alignAndLink_ and never referenced afterwards. Create it inside alignAndLink_ and drop the parameter and local in quantifyFraction_ to simplify the API and avoid accidental future misuse.

Apply this diff:

--- a/src/topp/ProteomicsLFQ.cpp
+++ b/src/topp/ProteomicsLFQ.cpp
@@
-  void alignAndLink_(
-    vector<FeatureMap> & feature_maps, 
-    ConsensusMap & consensus_fraction,
-    vector<TransformationDescription>& transformations,
-    const double median_fwhm)
+  void alignAndLink_(
+    vector<FeatureMap> & feature_maps, 
+    ConsensusMap & consensus_fraction,
+    const double median_fwhm)
   {
-    double max_alignment_diff(0.0);
+    double max_alignment_diff(0.0);
+    vector<TransformationDescription> transformations;
@@
   }
@@
-    vector<TransformationDescription> transformations;
@@
-    // Align all features of this fraction
-    alignAndLink_(feature_maps, consensus_fraction, transformations, median_fwhm);
+    // Align all features of this fraction
+    alignAndLink_(feature_maps, consensus_fraction, median_fwhm);

Also applies to: 1334-1336


1142-1147: Shuffle randomized_indices (currently never randomized)

Comment says “randomize selection” but randomized_indices isn’t shuffled. Use Math::RandomShuffler to ensure reproducible shuffling across platforms.

Apply this diff:

   Math::RandomShuffler shuffler;
   std::vector<size_t> randomized_indices(fm.size());
   std::iota(randomized_indices.begin(), randomized_indices.end(), 0);
+  shuffler.randomize(randomized_indices.begin(), randomized_indices.end());

1214-1262: LGTM: erase-remove filtering is correct and efficient

The lambda captures and counters are fine, and the second pass removing OffsetPeptide is clear.

Minor: consider guarding percentage prints later when denominators are zero to avoid inf/NaN in logs. No functional impact.


1334-1336: Verify linking tolerance uses an appropriate FWHM summary

median_fwhm is computed per MS file inside the loop; the last run’s value is passed to linking for all maps. Ensure this is intentional. If you want a fraction-level tolerance, consider aggregating across all runs (e.g., median of per-run medians) before calling alignAndLink_.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between aca32e8 and ff5fe7f.

📒 Files selected for processing (1)
  • src/topp/ProteomicsLFQ.cpp (10 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms

Applied to files:

  • src/topp/ProteomicsLFQ.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)

Applied to files:

  • src/topp/ProteomicsLFQ.cpp
📚 Learning: 2025-08-14T10:19:54.371Z
Learnt from: jpfeuffer
PR: OpenMS/OpenMS#8167
File: src/topp/Digestor.cpp:200-226
Timestamp: 2025-08-14T10:19:54.371Z
Learning: In OpenMS (C++ bioinformatics framework), use boost random libraries instead of std library random distributions for cross-platform reproducible random number generation, as std library distributions are not reproducible across platforms.

Applied to files:

  • src/topp/ProteomicsLFQ.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes

Applied to files:

  • src/topp/ProteomicsLFQ.cpp
🧬 Code graph analysis (1)
src/topp/ProteomicsLFQ.cpp (2)
src/topp/MapAlignerIdentification.cpp (2)
  • transformations (183-198)
  • transformations (183-184)
src/topp/MapAlignerTreeGuided.cpp (6)
  • transformations (123-135)
  • transformations (123-123)
  • transformations (219-219)
  • feature_maps (108-121)
  • feature_maps (108-108)
  • feature_maps (181-181)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: build-and-test (macos-13, xcode, 14.2)
  • GitHub Check: build-and-test (macos-14, xcode, 15.0.1)
  • GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
  • GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
  • GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
  • GitHub Check: cppcheck-test
🔇 Additional comments (5)
src/topp/ProteomicsLFQ.cpp (5)

1112-1128: Good: scoped temporaries for ffi.run and clear ownership of outputs

Switching to a local FeatureMap fm and tightly scoping the unused ext ID containers is cleaner and reduces lifetime/aliasing risks.


1195-1198: LGTM: consistent switch from tmp→fm

Indexing and assignment now consistently use fm.


1282-1297: LGTM: metadata cleanup and subordinate/hull stripping

This reduces memory footprint and downstream I/O.


1299-1301: LGTM: resolve top-PSM policy early

Running IDConflictResolverAlgorithm::resolve on the per-run fm is appropriate before grouping.


1302-1303: Nice: move-construct into feature_maps

Using std::move(fm) avoids an extra copy.

Two variables are created and passed to `quantifyFraction_` but then
never used again.  Move these variables into the function itself and
remove dead code (`is_already_aligned`) since the code now knows that
the `transformations` vector is always empty.
And put them in a proper scope since they are not used after the call
to `ffi.run`.
@pjones
pjones force-pushed the pjones/refactor-plfq branch from ff5fe7f to 3a6688d Compare September 1, 2025 14:50

@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

🧹 Nitpick comments (3)
src/topp/ProteomicsLFQ.cpp (3)

1281-1296: Consider retaining p_quant for diagnostics

All meta except OffsetPeptide is stripped; keeping p_quant (behind a debug flag) can aid QC and regressions.

Example:

-      unordered_set<String> keep_meta = {"OffsetPeptide"};
+      unordered_set<String> keep_meta = {"OffsetPeptide"
+        #if 0 // set to 1 or gate on debug_level_
+        , "p_quant"
+        #endif
+      };

1064-1065: Median FWHM aggregation across runs

median_fwhm is overwritten per file, then one value (from the last run) is used for the fraction’s linking tolerance. Consider aggregating over all runs in the fraction (median of medians) for more robust RT tolerance.

Also applies to: 1333-1335


1139-1146: Shuffle the index vector before sampling
After std::iota(randomized_indices.begin(), randomized_indices.end(), 0);, add

shuffler.seed(UniqueIdGenerator::getUniqueId());            // or use the existing seed
shuffler.portable_random_shuffle(
  randomized_indices.begin(),
  randomized_indices.end()
);

to ensure unbiased, reproducible randomization (see FFIDAlgoExternalIDHandler.cpp:332).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ff5fe7f and 3a6688d.

📒 Files selected for processing (1)
  • src/topp/ProteomicsLFQ.cpp (10 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms

Applied to files:

  • src/topp/ProteomicsLFQ.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)

Applied to files:

  • src/topp/ProteomicsLFQ.cpp
📚 Learning: 2025-08-14T10:19:54.371Z
Learnt from: jpfeuffer
PR: OpenMS/OpenMS#8167
File: src/topp/Digestor.cpp:200-226
Timestamp: 2025-08-14T10:19:54.371Z
Learning: In OpenMS (C++ bioinformatics framework), use boost random libraries instead of std library random distributions for cross-platform reproducible random number generation, as std library distributions are not reproducible across platforms.

Applied to files:

  • src/topp/ProteomicsLFQ.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes

Applied to files:

  • src/topp/ProteomicsLFQ.cpp
🧬 Code graph analysis (1)
src/topp/ProteomicsLFQ.cpp (2)
src/topp/MapAlignerIdentification.cpp (2)
  • transformations (183-198)
  • transformations (183-184)
src/topp/MapAlignerTreeGuided.cpp (6)
  • transformations (123-135)
  • transformations (123-123)
  • transformations (219-219)
  • feature_maps (108-121)
  • feature_maps (108-108)
  • feature_maps (181-181)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: build-and-test (macos-14, xcode, 15.0.1)
  • GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
  • GitHub Check: build-and-test (macos-13, xcode, 14.2)
  • GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
  • GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
  • GitHub Check: cppcheck-test
🔇 Additional comments (5)
src/topp/ProteomicsLFQ.cpp (5)

1111-1127: Local fm + scoped FFI run: LGTM

Switch to a local FeatureMap fm and passing empty external ID containers into ffi.run is clear and self-contained.


1213-1216: Filtering pipeline: in-place erase is correct

Two-stage erase (thresholding then removing OffsetPeptide) is correct and efficient.

Also applies to: 1258-1261


1301-1301: Move into feature_maps: LGTM

emplace_back(std::move(fm)) is appropriate; avoids extra copy.


700-705: All alignAndLink_ call-sites now void; no callers expect a return. Verified with repository-wide rg search showing only the definition and a single invocation that doesn’t use a return value.


1298-1300: Incorrect inversion; update the comment instead of the code.
The mapping is deliberate: keep_matching is set to true when keep_feature_top_psm_only == "false", causing lower-ranked PSMs with the top sequence to be retained. The inline comment “keep only best peptide per feature per file” is therefore misleading—please revise it to reflect the actual behavior.

Likely an incorrect or invalid review comment.

set<String>& fixed_modifications,
set<String>& variable_modifications)
{
vector<TransformationDescription> transformations;

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.

💡 Verification agent

🧩 Analysis chain

Pre-size transformations before alignment

Map aligners typically expect transformations.size() == feature_maps.size(); we currently pass an empty vector. Pre-sizing avoids API assumptions and empty-stats edge cases.

Apply right before calling alignAndLink_:

@@
-    // Align all features of this fraction
-    alignAndLink_(feature_maps, consensus_fraction, transformations, median_fwhm);
+    // Align all features of this fraction
+    transformations.resize(feature_maps.size());
+    alignAndLink_(feature_maps, consensus_fraction, transformations, median_fwhm);

And verify aligners’ expectations in-tree:

Also applies to: 1333-1335


🏁 Script executed:

#!/bin/bash
rg -nP 'align\([^,]+,\s*std::vector<\s*TransformationDescription' -C3

Length of output: 989


🏁 Script executed:

#!/bin/bash
# Locate and inspect the implementation of alignAndLink_ to see how 'transformations' is used
rg -nP 'alignAndLink_\s*\(' -C5 src/topp/ProteomicsLFQ.cpp

Length of output: 850


🏁 Script executed:

#!/bin/bash
# Extract the full implementation of alignAndLink_ for inspection
rg -nP 'void alignAndLink_\\s*\\(' -C200 src/topp/ProteomicsLFQ.cpp

# Search for direct indexing into transformations
rg -n 'transformations\\[' -C5 src/topp/ProteomicsLFQ.cpp

Length of output: 299


🏁 Script executed:

#!/bin/bash
# Extract the full implementation of alignAndLink_ for inspection
rg -nP 'void\s+alignAndLink_\s*\(' -C200 src/topp/ProteomicsLFQ.cpp

# Search for any direct indexing into transformations
rg -nF 'transformations[' -C5 src/topp/ProteomicsLFQ.cpp

Length of output: 17748


Pre-size transformations before each alignAndLink_ call
Insert

transformations.resize(feature_maps.size());

immediately before

alignAndLink_(feature_maps, consensus_fraction, transformations, median_fwhm);

at both call sites in src/topp/ProteomicsLFQ.cpp (around lines 1013 and 1334) to guarantee transformations.size() == feature_maps.size() and avoid out-of-bounds access in transform_ and during alignment statistics.

🤖 Prompt for AI Agents
In src/topp/ProteomicsLFQ.cpp around lines 1013 and 1334, the local
vector<TransformationDescription> transformations must be pre-sized to match
feature_maps before calling alignAndLink_ to avoid out-of-bounds access;
immediately before each call to alignAndLink_(feature_maps, consensus_fraction,
transformations, median_fwhm) insert a statement that resizes transformations to
feature_maps.size() (i.e., transformations.resize(feature_maps.size())) so
transformations.size() == feature_maps.size() when passed into alignAndLink_.

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