Repository navigation
Conversation
timosachsenberg
left a comment
There was a problem hiding this comment.
Looks pretty much straight forward.
|
ok then I can refactor the modmap building and uncomment the rest of the tests. |
|
Don't know how busy you are with other stuff but having one function for Digesting and Modifying a Protein would finally give us proper support for protein terminal modifications. But not high prio |
|
Yes and you can save computations by continuing enumeration in the presence of missed cleavages. |
| mod_compatibility[C_TERM_MODIFICATION_INDEX].push_back(v); | ||
| } | ||
| } | ||
| else if (peptide_is_n_terminal && v->getTermSpecificity() == ResidueModification::PROTEIN_N_TERM) |
There was a problem hiding this comment.
this has been added by me...
| else if (term_spec == ResidueModification::C_TERM && residue_index == (peptide.size() - 1)) | ||
| { | ||
| mod_compatibility[C_TERM_MODIFICATION_INDEX].push_back(v); | ||
| } | ||
| else if (term_spec == ResidueModification::N_TERM && residue_index == 0) | ||
| { | ||
| mod_compatibility[N_TERM_MODIFICATION_INDEX].push_back(v); | ||
| } |
There was a problem hiding this comment.
not sure why this is also handled here e.g. if this could lead to
two modifications (e.g., "Amidated (C-term)" and "Amidated (Protein C-term)" being applied redundantly...
| // test protein-terminal modifications | ||
| seq = AASequence::fromString("FAAAFFAAF"); // first residue will be target site | ||
| modNames.clear(); | ||
| modNames << "Deamidated (Protein N-term F)"; | ||
| variable_mods = ModifiedPeptideGenerator::getModifications(modNames); | ||
| is_c_terminal_peptide = false; | ||
| is_n_terminal_peptide = true; | ||
| ModifiedPeptideGenerator::generateVariableModifiedPeptidesWithMasses(variable_mods, seq, is_n_terminal_peptide, is_c_terminal_peptide, 3, modified_peptides, false); | ||
| TEST_EQUAL(modified_peptides.size(), 1); // modified peptide | ||
| TEST_EQUAL(modified_peptides[0].sequence.toString(), ".(Deamidated)FAAAFFAAF"); | ||
| TEST_EQUAL(modified_peptides[0].mass, modified_peptides[0].sequence.getMonoWeight()); | ||
| modified_peptides.clear(); | ||
|
|
||
| is_c_terminal_peptide = false; | ||
| is_n_terminal_peptide = false; | ||
| ModifiedPeptideGenerator::generateVariableModifiedPeptidesWithMasses(variable_mods, seq, is_n_terminal_peptide, is_c_terminal_peptide, 3, modified_peptides, false); | ||
| TEST_EQUAL(modified_peptides.size(), 0); | ||
| modified_peptides.clear(); | ||
|
|
||
| // Amidation is "C-term" and "Protein C-term" without AA preference in unimod | ||
| modNames.clear(); | ||
| modNames << "Amidated (C-term)"; | ||
| variable_mods = ModifiedPeptideGenerator::getModifications(modNames); | ||
| is_c_terminal_peptide = false; | ||
| is_n_terminal_peptide = false; | ||
| ModifiedPeptideGenerator::generateVariableModifiedPeptidesWithMasses(variable_mods, seq, is_n_terminal_peptide, is_c_terminal_peptide, 3, modified_peptides, false); | ||
| TEST_EQUAL(modified_peptides.size(), 1); | ||
| TEST_EQUAL(modified_peptides[0].sequence.toString(), "FAAAFFAAF.(Amidated)"); // always assigned because it is C-term of the peptide | ||
| TEST_EQUAL(modified_peptides[0].mass, modified_peptides[0].sequence.getMonoWeight()); | ||
| modified_peptides.clear(); | ||
|
|
||
| modNames.clear(); | ||
| modNames << "Amidated (Protein C-term)"; | ||
| variable_mods = ModifiedPeptideGenerator::getModifications(modNames); | ||
| is_c_terminal_peptide = false; | ||
| is_n_terminal_peptide = false; | ||
| ModifiedPeptideGenerator::generateVariableModifiedPeptidesWithMasses(variable_mods, seq, is_n_terminal_peptide, is_c_terminal_peptide, 3, modified_peptides, false); | ||
| TEST_EQUAL(modified_peptides.size(), 0); // not assigned because it is an internal peptide | ||
| modified_peptides.clear(); | ||
| } |
There was a problem hiding this comment.
added a few tests that indicate that it works
|
TODO in this PR:
Follow up:
|
|
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. CI Failure Feedback 🧐
✨ CI feedback usage guide:The CI feedback tool (
In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR: where Configuration options
See more information about the |
|
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. CI Failure Feedback 🧐
✨ CI feedback usage guide:The CI feedback tool (
In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR: where Configuration options
See more information about the |
|
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. CI Failure Feedback 🧐
✨ CI feedback usage guide:The CI feedback tool (
In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR: where Configuration options
See more information about the |
|
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. CI Failure Feedback 🧐
✨ CI feedback usage guide:The CI feedback tool (
In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR: where Configuration options
See more information about the |
|
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. CI Failure Feedback 🧐
✨ CI feedback usage guide:The CI feedback tool (
In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR: where Configuration options
See more information about the |
|
I think this might not be 100% finshed so please don't merge yet |
📝 WalkthroughWalkthroughThis PR extends the ModifiedPeptideGenerator class with mass-tracking capabilities and introduces a new DigestAndModify utility class for streamlined peptide digestion and modification generation. New functions generate modified peptide variants while tracking associated masses, and a helper method variant supports SequenceMassPair operations. Changes
Sequence Diagram(s)sequenceDiagram
actor Client
participant DAM as DigestAndModify
participant PD as ProteaseDigestion
participant MPG as ModifiedPeptideGenerator
participant ModDB as Modification Database
Client->>DAM: getPeptides(protein_sequence)
activate DAM
DAM->>PD: digest(protein_sequence)
activate PD
PD-->>DAM: peptide_fragments[]
deactivate PD
loop for each peptide fragment
DAM->>MPG: generateVariableModifiedPeptidesWithMasses(var_mods, peptide)
activate MPG
MPG->>ModDB: lookup modification specs
activate ModDB
ModDB-->>MPG: modification deltas
deactivate ModDB
MPG->>MPG: enumerate modifications up to max limit
MPG->>MPG: compute mass for each variant
MPG-->>DAM: SequenceMassPair[]
deactivate MPG
end
DAM-->>Client: modified_peptides[]
deactivate DAM
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Fix all issues with AI agents
In `@src/openms/include/OpenMS/CHEMISTRY/ModifiedPeptideGenerator.h`:
- Around line 92-116: The Doxygen for generateVariableModifiedPeptidesWithMasses
is out of sync with the declaration: reorder the `@param` entries to match the
function signature order (var_mods, peptide, peptide_is_n_terminal,
peptide_is_c_terminal, max_variable_mods_per_peptide, all_modified_peptides,
keep_original) and rename the final `@param` from keep_unmodified to keep_original
(and update its description accordingly) so the doc parameters exactly match the
function parameter names and order.
- Around line 55-74: The Doxygen parameter name for applyVariableModifications
is inconsistent with the function declaration: the doc uses keep_unmodified
while the signature uses keep_original; update either the declaration parameter
name in applyVariableModifications to keep_unmodified or change the Doxygen to
document keep_original so they match, and ensure the `@param` description remains
accurate for the chosen symbol (applyVariableModifications, var_mods, peptide,
max_variable_mods_per_peptide, all_modified_peptides,
keep_original/keep_unmodified).
- Around line 76-90: Add a Doxygen `@brief` block for the public struct
SequenceMassPair and update its constructors: remove noexcept from the lvalue
copy constructor SequenceMassPair(const AASequence& s, double m) (since copying
AASequence may throw) but keep noexcept on the move constructor
SequenceMassPair(AASequence&& s, double m), and ensure the member initializer
lists follow the declaration order (mass then sequence) to avoid warnings;
reference SequenceMassPair, its two constructors, and members mass and sequence
when making these changes.
- Around line 165-187: In getPeptides, the terminal flags are swapped and the
C-terminal check is wrong: set peptide_is_n_terminal = (start == 0) (keep as is)
and set peptide_is_c_terminal = (end == protein_sequence.size()) (not
peptide.size()-1), then call
ModifiedPeptideGenerator::generateVariableModifiedPeptidesWithMasses with the
arguments in the correct order (pass peptide_is_n_terminal as the 3rd parameter
and peptide_is_c_terminal as the 4th) so N- and C-terminal variable mods are
applied correctly.
In `@src/tests/class_tests/openms/source/ModifiedPeptideGenerator_test.cpp`:
- Line 90: Update the test's START_SECTION description to match the actual
function signature for generateVariableModifiedPeptidesWithMasses: replace the
incorrect std::vector< AASequence > &all_modified_peptides reference with
std::vector<SequenceMassPair>& all_modified_peptides (and remove any lingering
AASequence-only wording); ensure the signature in the START_SECTION exactly
matches "static void generateVariableModifiedPeptidesWithMasses(const
ModifiedPeptideGenerator::MapToResidueType& var_mods, const AASequence& peptide,
Size max_variable_mods_per_peptide, std::vector<SequenceMassPair>&
all_modified_peptides, bool keep_unmodified=true)" so the test metadata aligns
with the actual function.
🧹 Nitpick comments (5)
src/openms/include/OpenMS/CHEMISTRY/ModifiedPeptideGenerator.h (2)
140-163:DigestAndModifyclass is missing Doxygen documentation and is defined entirely inline in the header.The class, its constructor, and
getPeptideslack@briefDoxygen documentation. Per coding guidelines, new public classes and methods require Doxygen with@brief. Also, the class body and all method implementations are fully inline in the header — guidelines recommend pairing each.hwith a.cppand keeping one class per file. I understand from PR comments that moving this to a separate file is a known TODO, so flagging this as a reminder.As per coding guidelines: "Add Doxygen comments for new public methods and classes", "One class per file; pair each
.hheader file with a corresponding.cppimplementation file".
224-224: Redundant blank line before closing brace.Static analysis (CodeFactor) flagged this.
Suggested fix
const ModifiedPeptideGenerator::MapToResidueType& getFixedMods() const { return fixed_mods_; - } - + } };src/openms/source/CHEMISTRY/ModifiedPeptideGenerator.cpp (2)
268-421: Significant code duplication withapplyVariableModifications.This function is nearly identical to
applyVariableModifications(lines 132–266), differing only in:
- Operating on
SequenceMassPairinstead ofAASequence- Computing and propagating the initial mass
- Handling
PROTEIN_N_TERM/PROTEIN_C_TERMin the terminal-mods loop (lines 325–338)The PROTEIN_N_TERM/PROTEIN_C_TERM handling is a genuine improvement over the existing function. Consider backporting that logic to
applyVariableModificationsas well, and refactoring both functions to share the common compatibility-map construction logic to reduce duplication. CodeFactor also flagged this as a complex method.
362-366: Stale TODO comment copied from existing function.The comment on lines 362–365 says "currently no explicit support in OpenMS for protein C-term and protein N-term" followed by "TODO This is not true anymore!" — but this new function does handle
PROTEIN_N_TERMandPROTEIN_C_TERMin the terminal-mods section above (lines 325–338). The TODO was copied verbatim fromapplyVariableModificationsand is misleading here. Consider removing or updating the comment.src/tests/class_tests/openms/source/ModifiedPeptideGenerator_test.cpp (1)
90-195: Good test coverage for the new mass-tracking function, but missing multi-modification combinatoric tests andDigestAndModifytests.The existing
applyVariableModificationstest section includes extensive multi-site tests (2 sites with combinatorics, 3 sites with 2 mods, 3 sites with 3 mods, occupied sites, terminal + residue mods). The newgenerateVariableModifiedPeptidesWithMassestests stop at single-site scenarios and terminal mods, missing the combinatoric cases where mass tracking is most likely to have subtle bugs (accumulated mass deltas across multiple mods).Additionally, there are no tests for the new
DigestAndModifyclass at all — itsgetPeptidesmethod, terminal detection logic, and interaction with digestion + modification are untested.I understand from PR comments that tests may be re-enabled after refactoring, but flagging for tracking.
Based on learnings: "Write unit tests for new functionality" and "Always run and extend tests when making code changes; do not skip tests".
| /** | ||
| * @brief Apply variable modifications to a peptide. | ||
| * | ||
| * This function applies variable modifications to a given peptide based on the provided mapping | ||
| * of modifications to residue types. It generates all possible modified peptide variants | ||
| * considering the specified constraints such as the maximum number of variable modifications | ||
| * allowed per peptide and whether unmodified peptides should be retained. | ||
| * | ||
| * @param var_mods A mapping of modifications to residue types. | ||
| * @param peptide The original peptide to which modifications will be applied. | ||
| * @param max_variable_mods_per_peptide The maximum number of variable modifications allowed per peptide. | ||
| * @param all_modified_peptides Output container. Generated modified peptides are appended. | ||
| * @param keep_unmodified Flag indicating whether unmodified peptides should be retained. | ||
| */ | ||
| static void applyVariableModifications( | ||
| const MapToResidueType& var_mods, | ||
| const AASequence& peptide, | ||
| Size max_variable_mods_per_peptide, | ||
| std::vector<AASequence>& all_modified_peptides, | ||
| bool keep_original=true); |
There was a problem hiding this comment.
Parameter name mismatch between Doxygen and declaration.
The Doxygen documents @param keep_unmodified (line 67) but the function declaration uses keep_original (line 74). This inconsistency can confuse callers.
Suggested fix
- * `@param` keep_unmodified Flag indicating whether unmodified peptides should be retained.
+ * `@param` keep_original Flag indicating whether unmodified peptides should be retained.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /** | |
| * @brief Apply variable modifications to a peptide. | |
| * | |
| * This function applies variable modifications to a given peptide based on the provided mapping | |
| * of modifications to residue types. It generates all possible modified peptide variants | |
| * considering the specified constraints such as the maximum number of variable modifications | |
| * allowed per peptide and whether unmodified peptides should be retained. | |
| * | |
| * @param var_mods A mapping of modifications to residue types. | |
| * @param peptide The original peptide to which modifications will be applied. | |
| * @param max_variable_mods_per_peptide The maximum number of variable modifications allowed per peptide. | |
| * @param all_modified_peptides Output container. Generated modified peptides are appended. | |
| * @param keep_unmodified Flag indicating whether unmodified peptides should be retained. | |
| */ | |
| static void applyVariableModifications( | |
| const MapToResidueType& var_mods, | |
| const AASequence& peptide, | |
| Size max_variable_mods_per_peptide, | |
| std::vector<AASequence>& all_modified_peptides, | |
| bool keep_original=true); | |
| /** | |
| * `@brief` Apply variable modifications to a peptide. | |
| * | |
| * This function applies variable modifications to a given peptide based on the provided mapping | |
| * of modifications to residue types. It generates all possible modified peptide variants | |
| * considering the specified constraints such as the maximum number of variable modifications | |
| * allowed per peptide and whether unmodified peptides should be retained. | |
| * | |
| * `@param` var_mods A mapping of modifications to residue types. | |
| * `@param` peptide The original peptide to which modifications will be applied. | |
| * `@param` max_variable_mods_per_peptide The maximum number of variable modifications allowed per peptide. | |
| * `@param` all_modified_peptides Output container. Generated modified peptides are appended. | |
| * `@param` keep_original Flag indicating whether unmodified peptides should be retained. | |
| */ | |
| static void applyVariableModifications( | |
| const MapToResidueType& var_mods, | |
| const AASequence& peptide, | |
| Size max_variable_mods_per_peptide, | |
| std::vector<AASequence>& all_modified_peptides, | |
| bool keep_original=true); |
🤖 Prompt for AI Agents
In `@src/openms/include/OpenMS/CHEMISTRY/ModifiedPeptideGenerator.h` around lines
55 - 74, The Doxygen parameter name for applyVariableModifications is
inconsistent with the function declaration: the doc uses keep_unmodified while
the signature uses keep_original; update either the declaration parameter name
in applyVariableModifications to keep_unmodified or change the Doxygen to
document keep_original so they match, and ensure the `@param` description remains
accurate for the chosen symbol (applyVariableModifications, var_mods, peptide,
max_variable_mods_per_peptide, all_modified_peptides,
keep_original/keep_unmodified).
| struct SequenceMassPair | ||
| { | ||
| SequenceMassPair(const AASequence& s, double m) noexcept : | ||
| mass(m), | ||
| sequence(s) | ||
| {} | ||
|
|
||
| SequenceMassPair(AASequence&& s, double m) noexcept : | ||
| mass(m), | ||
| sequence(std::move(s)) | ||
| {} | ||
|
|
||
| double mass{}; | ||
| AASequence sequence; | ||
| }; |
There was a problem hiding this comment.
SequenceMassPair: member initialization order differs from declaration order.
The constructors initialize mass before sequence, but mass is declared before sequence (lines 88-89), so the initialization order happens to match here. However, the Doxygen @brief documentation is missing for this public struct, which is required per coding guidelines.
Also, the noexcept on the lvalue constructor (line 78) is potentially incorrect — copying an AASequence may allocate and could throw. Only the move constructor (line 83) should be noexcept.
Suggested fix
+ /// `@brief` Pairs an AASequence with its monoisotopic mass.
struct SequenceMassPair
{
- SequenceMassPair(const AASequence& s, double m) noexcept :
+ SequenceMassPair(const AASequence& s, double m) :
mass(m),
sequence(s)
{}As per coding guidelines: src/openms/include/OpenMS/**/*.h: "Add Doxygen comments for new public methods and classes" and use @brief tag (required).
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| struct SequenceMassPair | |
| { | |
| SequenceMassPair(const AASequence& s, double m) noexcept : | |
| mass(m), | |
| sequence(s) | |
| {} | |
| SequenceMassPair(AASequence&& s, double m) noexcept : | |
| mass(m), | |
| sequence(std::move(s)) | |
| {} | |
| double mass{}; | |
| AASequence sequence; | |
| }; | |
| /// `@brief` Pairs an AASequence with its monoisotopic mass. | |
| struct SequenceMassPair | |
| { | |
| SequenceMassPair(const AASequence& s, double m) : | |
| mass(m), | |
| sequence(s) | |
| {} | |
| SequenceMassPair(AASequence&& s, double m) noexcept : | |
| mass(m), | |
| sequence(std::move(s)) | |
| {} | |
| double mass{}; | |
| AASequence sequence; | |
| }; |
🤖 Prompt for AI Agents
In `@src/openms/include/OpenMS/CHEMISTRY/ModifiedPeptideGenerator.h` around lines
76 - 90, Add a Doxygen `@brief` block for the public struct SequenceMassPair and
update its constructors: remove noexcept from the lvalue copy constructor
SequenceMassPair(const AASequence& s, double m) (since copying AASequence may
throw) but keep noexcept on the move constructor SequenceMassPair(AASequence&&
s, double m), and ensure the member initializer lists follow the declaration
order (mass then sequence) to avoid warnings; reference SequenceMassPair, its
two constructors, and members mass and sequence when making these changes.
| /** | ||
| * @brief Apply variable modifications to a peptide to obtain the modified sequence and mass. | ||
| * | ||
| * This function applies variable modifications to a given peptide based on the provided mapping | ||
| * of modifications to residue types. It generates all possible modified peptide variants | ||
| * considering the specified constraints such as the maximum number of variable modifications | ||
| * allowed per peptide and whether unmodified peptides should be retained. Additionally, it | ||
| * calculates and stores the monoisotopic mass of each modified peptide. | ||
| * | ||
| * @param var_mods A mapping of modifications to residue types. | ||
| * @param peptide The original peptide to which modifications will be applied. | ||
| * @param max_variable_mods_per_peptide The maximum number of variable modifications allowed per peptide. | ||
| * @param peptide_is_n_terminal Whether the peptide is N-terminal in the protein sequence. Needed to correctly apply terminal modifications. | ||
| * @param peptide_is_c_terminal Whether the peptide is C-terminal. Needed to correctly apply terminal modifications. | ||
| * @param all_modified_peptides Output container. Generated modified peptides with their masses are appended. | ||
| * @param keep_unmodified Flag indicating whether unmodified peptides should be retained. | ||
| */ | ||
| static void generateVariableModifiedPeptidesWithMasses( | ||
| const MapToResidueType& var_mods, | ||
| const AASequence& peptide, | ||
| bool peptide_is_n_terminal, | ||
| bool peptide_is_c_terminal, | ||
| Size max_variable_mods_per_peptide, | ||
| std::vector<SequenceMassPair>& all_modified_peptides, | ||
| bool keep_original=true); |
There was a problem hiding this comment.
Doxygen parameter order doesn't match the function signature.
In the Doxygen block (lines 101-107), @param peptide_is_n_terminal appears before @param peptide_is_c_terminal, which matches the signature. However, @param max_variable_mods_per_peptide is listed before the terminal params in the signature but after them in the doc. Minor, but the param doc order should follow the declaration order for clarity.
Also note the last param is documented as keep_unmodified but the declaration uses keep_original — these should be consistent.
🤖 Prompt for AI Agents
In `@src/openms/include/OpenMS/CHEMISTRY/ModifiedPeptideGenerator.h` around lines
92 - 116, The Doxygen for generateVariableModifiedPeptidesWithMasses is out of
sync with the declaration: reorder the `@param` entries to match the function
signature order (var_mods, peptide, peptide_is_n_terminal,
peptide_is_c_terminal, max_variable_mods_per_peptide, all_modified_peptides,
keep_original) and rename the final `@param` from keep_unmodified to keep_original
(and update its description accordingly) so the doc parameters exactly match the
function parameter names and order.
| void getPeptides(const StringView& protein_sequence, std::vector<ModifiedPeptideGenerator::SequenceMassPair>& modified_peptides) | ||
| { | ||
| std::vector<std::pair<Size, Size>> output; | ||
| digestor_.digestUnmodified(protein_sequence, output, min_length_, max_length_); | ||
|
|
||
| for (const auto&[start, end] : output) | ||
| { | ||
| AASequence peptide = AASequence::fromString(protein_sequence.substr(start, end - start).getString()); | ||
| ModifiedPeptideGenerator::applyFixedModifications(fixed_mods_, peptide); // this could be done on protein level. not sure if worth the rewrite | ||
|
|
||
| // determine if peptide is C-terminal, N-terminal, both (or none of them) and pass it to ensure modifications are correctly applied | ||
| bool peptide_is_n_terminal = (start == 0); | ||
| bool peptide_is_c_terminal = (end == peptide.size() - 1); | ||
| ModifiedPeptideGenerator::generateVariableModifiedPeptidesWithMasses(variable_mods_, | ||
| peptide, | ||
| peptide_is_c_terminal, | ||
| peptide_is_n_terminal, | ||
| max_variable_mods_per_peptide_, | ||
| modified_peptides, | ||
| true); | ||
| } | ||
| return; | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify the parameter order of generateVariableModifiedPeptidesWithMasses declaration
# and check what digestUnmodified returns (start, end semantics)
echo "=== Declaration of generateVariableModifiedPeptidesWithMasses ==="
rg -n "generateVariableModifiedPeptidesWithMasses" --type cpp --type-add 'cpp:*.h' -A 8
echo ""
echo "=== digestUnmodified signature and documentation ==="
rg -n "digestUnmodified" --type cpp --type-add 'cpp:*.h' -B 5 -A 10Repository: OpenMS/OpenMS
Length of output: 50369
Critical: swapped peptide_is_n_terminal / peptide_is_c_terminal arguments and incorrect C-terminal check.
The function generateVariableModifiedPeptidesWithMasses expects peptide_is_n_terminal as the 3rd argument and peptide_is_c_terminal as the 4th (declared at lines 109–116), but the call at lines 178–181 passes them in reverse order. This silently swaps the terminal flags, causing protein N-terminal modifications to be applied to C-terminal peptides and vice versa.
Additionally, the C-terminal check on line 177 compares end (a position in the protein sequence) against peptide.size() - 1 (the peptide length minus one). Since end is exclusive (as shown by the substr(start, end - start) usage on line 172), it should compare against protein_sequence.size() to determine if the peptide extends to the end of the protein.
Proposed fix
// determine if peptide is C-terminal, N-terminal, both (or none of them) and pass it to ensure modifications are correctly applied
bool peptide_is_n_terminal = (start == 0);
- bool peptide_is_c_terminal = (end == peptide.size() - 1);
+ bool peptide_is_c_terminal = (end == protein_sequence.size());
ModifiedPeptideGenerator::generateVariableModifiedPeptidesWithMasses(variable_mods_,
peptide,
- peptide_is_c_terminal,
peptide_is_n_terminal,
+ peptide_is_c_terminal,
max_variable_mods_per_peptide_,
modified_peptides,
true);🤖 Prompt for AI Agents
In `@src/openms/include/OpenMS/CHEMISTRY/ModifiedPeptideGenerator.h` around lines
165 - 187, In getPeptides, the terminal flags are swapped and the C-terminal
check is wrong: set peptide_is_n_terminal = (start == 0) (keep as is) and set
peptide_is_c_terminal = (end == protein_sequence.size()) (not peptide.size()-1),
then call ModifiedPeptideGenerator::generateVariableModifiedPeptidesWithMasses
with the arguments in the correct order (pass peptide_is_n_terminal as the 3rd
parameter and peptide_is_c_terminal as the 4th) so N- and C-terminal variable
mods are applied correctly.
| } | ||
| END_SECTION | ||
|
|
||
| START_SECTION((static void generateVariableModifiedPeptidesWithMasses(const ModifiedPeptideGenerator::MapToResidueType& var_mods, const AASequence& peptide, Size max_variable_mods_per_peptide, std::vector< AASequence > &all_modified_peptides, bool keep_unmodified=true))) |
There was a problem hiding this comment.
START_SECTION description does not match the actual function signature.
The section description references std::vector< AASequence > &all_modified_peptides but the function under test uses std::vector<SequenceMassPair>&. This was likely copy-pasted from the applyVariableModifications test section.
Suggested fix
-START_SECTION((static void generateVariableModifiedPeptidesWithMasses(const ModifiedPeptideGenerator::MapToResidueType& var_mods, const AASequence& peptide, Size max_variable_mods_per_peptide, std::vector< AASequence > &all_modified_peptides, bool keep_unmodified=true)))
+START_SECTION((static void generateVariableModifiedPeptidesWithMasses(const ModifiedPeptideGenerator::MapToResidueType& var_mods, const AASequence& peptide, bool peptide_is_n_terminal, bool peptide_is_c_terminal, Size max_variable_mods_per_peptide, std::vector<ModifiedPeptideGenerator::SequenceMassPair>& all_modified_peptides, bool keep_original=true)))📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| START_SECTION((static void generateVariableModifiedPeptidesWithMasses(const ModifiedPeptideGenerator::MapToResidueType& var_mods, const AASequence& peptide, Size max_variable_mods_per_peptide, std::vector< AASequence > &all_modified_peptides, bool keep_unmodified=true))) | |
| START_SECTION((static void generateVariableModifiedPeptidesWithMasses(const ModifiedPeptideGenerator::MapToResidueType& var_mods, const AASequence& peptide, bool peptide_is_n_terminal, bool peptide_is_c_terminal, Size max_variable_mods_per_peptide, std::vector<ModifiedPeptideGenerator::SequenceMassPair>& all_modified_peptides, bool keep_original=true))) |
🤖 Prompt for AI Agents
In `@src/tests/class_tests/openms/source/ModifiedPeptideGenerator_test.cpp` at
line 90, Update the test's START_SECTION description to match the actual
function signature for generateVariableModifiedPeptidesWithMasses: replace the
incorrect std::vector< AASequence > &all_modified_peptides reference with
std::vector<SequenceMassPair>& all_modified_peptides (and remove any lingering
AASequence-only wording); ensure the signature in the START_SECTION exactly
matches "static void generateVariableModifiedPeptidesWithMasses(const
ModifiedPeptideGenerator::MapToResidueType& var_mods, const AASequence& peptide,
Size max_variable_mods_per_peptide, std::vector<SequenceMassPair>&
all_modified_peptides, bool keep_unmodified=true)" so the test metadata aligns
with the actual function.
|
To keep our PR queue easier to manage, we will start closing stale PRs more frequently. This also makes it easier to automate handling of PRs that are still work in progress. Please do not take this personally—closed PRs can always be reopened or continued in a fresh PR when needed. |
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